user6943017
user6943017

Reputation:

Python function doesn't get called I have tried debugger and print statements

I think it has something to do with the self object. I have tried print statements and the debugger and I haven't been able to find a solution. This is a simple Python GUI that will soon be starting a timer and stuff but I haven't quite gotten there yet. Here's the code: https://pastebin.com/QcAe8bEN

The function that isn't being called

 def beginDefault(self):
    initialTime = time.time()
    print("Hello World!")

The line where the button is created. Note that the function should be called when the button is clicked.

defaultButton = Button(createIntervalFrame, text="Default", command=self.beginDefault and createIntervalFrame.destroy)

Initial object is created here:

root = Tk()   # creating a blank window
interactive = WellRested(root) # Creates a Well Rested object

Upvotes: 0

Views: 64

Answers (1)

Novel
Novel

Reputation: 13729

and is a logical operator, you can't use it to call several functions. To do what you want you will need a third function which calls the first two:

def button_clicked(self):
    self.beginDefault()
    self.createIntervalFrame.destroy()
...
defaultButton = Button(createIntervalFrame, text="Default", command=self.button_clicked)

Upvotes: 3

Related Questions