class - Need help with Classes in Python -
i'm making program imports custom widget class (it inherits tkinter frame widget). works great until binding. reduce confusion we'll call main application app, module it's importing widget lib, , widget that's being imported app called cwid.
basically need somehow reference function in app, may bound widget in lib.
the function i'm trying bind widget within cwid element_click (the function element_click in app.):
lambda event: element_click(event, elementinfo[3])
so binding in lib (element canvas widget within cwid)
element.bind('<buttonrelease-1>', lambda event: element_click(event, elementinfo[3]))
the above line wont work seeing element_click in app. tried work around doesn't seem working.
import app loc = app.eog element.bind('<buttonrelease-1>', lambda event: loc.element_click( event, elementinfo[3]))
when try above following error:
typeerror: unbound method element_click() must called eog instance first argument (got event instance instead)
eog class in app contains element_click.
also, of above bits of code snippets.
edit:
tried loc = app.eog(), , go following error:
attributeerror: eog instance has no attribute '__nonzero__'
i think want:
loc = app.eog()
then, loc
instance of eog, , loc.element_click
bound method, works intended.
Comments
Post a Comment