Python Forum
Button not defined, why?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Button not defined, why?
#7
Let see if this clear it up
import tkinter as tk

def create_buttons():
    buttons_name = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']
    buttons = []
    
    for name in buttons_name:
        buttons.append(tk.Button(text=name))
        
    return buttons
    
def main():
    buttons = create_buttons()
    for button in buttons:
        print(button['text'])
    print('')
    print('button 3:', buttons[3]['text']) # four will be the answer
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,115 Jun-10-2021, 01:05 AM
Last Post: Tomli
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,043 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp
  [Tkinter] button not defined OldManProgrammer 2 4,523 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