Python 3 Tkinter - How To Call A Function From Another Class
I am trying to get my save button to call a function from another class. I would like to click on the save button as much as I want and it should print 'hello people' every time. T
Solution 1:
In your documentMaker
class, change the test
method to a @staticmethod
:
classdocumentMaker():
@staticmethoddeftest(cls):
print ("hello people")
Then your saveButton
's command can be:
command = documentMaker.test
A staticmethod
is bound to the class, not to an instance of the class like an instance method. So, we can call it from the class's name directly. If you did not want it to be a staticmethod
, you could keep it an instance method and have the command line change to:
command = documentMaker().test
Post a Comment for "Python 3 Tkinter - How To Call A Function From Another Class"