Python Forum
Button not defined, why?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Button not defined, why?
#4
@Johnny
1. Don't use python keywords as variables.
list = ['btn1', 'btn2', etc]
2. You can't use string as variables and making variables in functions are local only.
You have to pass them to other functions.
Something like this. buttons[0] - buttons[8]
def button_creation():
    buttons = []
    # other code
    for n in xrange(9):
        #new button
        buttons.append(Button(etc))
        buttons[-1].grid(etc)
    return buttons
@Barrowman
3.
# this get replace by next line
myname = "button" + txt # string
mayname = Button(etc) # delete string and now a tk.Button
99 percent of computer problems exists between chair and keyboard.
Reply


Messages In This Thread
Button not defined, why? - by gb_johnny - Sep-12-2017, 07:31 AM
RE: Button not defined, why? - by Lux - Sep-12-2017, 11:29 PM
RE: Button not defined, why? - by Barrowman - Oct-23-2017, 09:40 PM
RE: Button not defined, why? - by Windspar - Nov-12-2017, 01:01 PM
RE: Button not defined, why? - by Barrowman - Nov-12-2017, 11:26 PM
RE: Button not defined, why? - by metulburr - Nov-13-2017, 12:06 AM
RE: Button not defined, why? - by Windspar - Nov-13-2017, 12:19 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Kivy] Acces atributes from a button defined in a class inside the .kv Tomli 2 2,150 Jun-10-2021, 01:05 AM
Last Post: Tomli
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,078 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [Tkinter] button not defined OldManProgrammer 2 4,544 Nov-21-2018, 07:53 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020