Edit
Added more code to illustrate my problem better.
Added more examples of what I have tried
I am writing for several packages that require callback
functions to be passed as a string
. This works fine when I'm sticking to functions only, but I can't seem to find a way to pass self
into a function, when I use class
's, but still maintaining the string constraint
class MyClass():
def __init__():
#Code here
def UI(self):
tde4.setWidgetCallbackFunction(req, 'button_name', "function")
# tde4 is the 3Dequalizer base functions
def function(self, req, widget, action): # req, widget and action are passed from the 3DEqualizer function
# req - Is the 'Requester', basically the GUI Window
# widget - Is the gui element, in this case the button
# action - Not quite sure what this is, I never used it.
# Code here
I've tried using:
tde4.setWidgetCallbackFunction(req, 'button_name', "self.function")
but it just states that self cannot be found
tde4.setWidgetCallbackFunction(req, 'button_name', self.function)
but it states it requires a string
tde4.setWidgetCallbackFunction(req, 'button_name', getattr(self, 'function'))
but that doesn't like that a class instance was passed
tde4.setWidgetCallbackFunction(req, 'button_name', str(getattr(self,'function')))
this loads the UI, but when called it throws out a crazy unicode error
tde4.setWidgetCallbackFunction(req, 'button_name', getattr(self,'function')() )
this calls the function, but just uses the result from that function as the new method to call. As I'm not returning anything, it just throws a None type error
Many thanks in advance!