Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter issue
#1
Photo 
Hi guys,

I'm having a problem creating multiple buttons in tkinter using a for loop. I just can't figure out how to make each button unique. First task is to fill a 9x9 grid with buttons, which is successfully acomplished by the command below.
def grid_fill():
    a=14
    b=15
    for j in range(9):
        for i in range(9):
            buttons = Button(main, text = 0, width = 7, height = 3)
            buttons.place(x = a, y = b)
            a+=76.7
        a = 14
        b+=76.7
But my goal is not only to place these buttons but also assign each one a different command. The code above just places 81 buttons which are all the same. Any suggestions?

Thank you very much for all of your help in advance. Big Grin
Larz60+ write Dec-06-2020, 10:26 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Fixed for you this time. Please use bbcode tags in future posts.
Reply


Messages In This Thread
tkinter issue - by mate - Dec-06-2020, 07:13 PM
RE: tkinter issue - by deanhystad - Dec-06-2020, 07:27 PM
RE: tkinter issue - by mate - Dec-06-2020, 07:43 PM
RE: tkinter issue - by deanhystad - Dec-06-2020, 08:08 PM
RE: tkinter issue - by mate - Dec-06-2020, 09:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb [Tkinter] Tkinter Class Import Module Issue AaronCatolico1 6 3,227 Sep-06-2022, 03:37 PM
Last Post: AaronCatolico1
  Super basic tkinter arduino issue Kurta 3 2,462 Jan-07-2021, 05:22 PM
Last Post: deanhystad
  Issue in Tkinter with winfo_class() and LabelFrame ReDefendeur 1 2,780 Oct-05-2020, 05:52 AM
Last Post: Jeff900
  [Tkinter] tkinter: after issue edwin6938 1 3,450 Aug-25-2020, 04:37 PM
Last Post: Larz60+
  Tkinter: increasing numbers and Radiobutton issue PeroPuri 1 2,192 Apr-13-2020, 05:48 PM
Last Post: deanhystad
  [Tkinter] tkinter issue with variables carrying over between functions PengEng 1 1,784 Apr-06-2020, 06:13 PM
Last Post: deanhystad
  Issue on tkinter with buttons Reldaing 1 2,475 Jan-07-2020, 08:21 AM
Last Post: berckut72
  [Tkinter] Tkinter window issue frequency 4 3,407 Dec-24-2018, 10:49 AM
Last Post: frequency
  Tkinter positional information issue thatguy14 4 3,475 Jul-05-2018, 06:49 PM
Last Post: woooee

Forum Jump:

User Panel Messages

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