Python TKinter Buttons Making Buttons
Go to solution
Solved by mail929,
You have several minor issues here:
- Global variables don't work in Python as you may expect. You must first call global [var name] when using one in a method.
- You forgot self. before master, easy mistake.
- You forgot to pass num to the string formatter.
Here's the working button() function:
def button(self): global num num = num + 1 self.new_button = Button(self.master, text = "Button {}".format(num), command = self.button) self.new_button.pack()
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now