Mohammed Hassan
Mohammed Hassan

Reputation: 11

Tkinter button if statements

Can you use an if statement within the lambda:command part of a button declaration, examaple: HalondrusButton = Button(mainFrame,text="Halondrus",command= lambda:[mainFrame.pack_forget(), raise_frame(bossFrame),currentBoss.set("Halondrus"),if GuildMasterPresent=="yes":changeRosterButton.pack()])

I want to only show a specific item on the frame if the variable is equal to a certain value

Upvotes: 1

Views: 218

Answers (1)

emely_pi
emely_pi

Reputation: 681

You can use either a function or a lambda command in a tkinter button. If you want to use an if statement in a lambda command, you must define a function that implements the lambda command with the if statement and then replace the lambda command with the function in your tkinter button.

See this tutorial for a simple example: Tkinter Tutorial

Upvotes: 1

Related Questions