Python Forum
Need tkinter help with clicking buttons
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need tkinter help with clicking buttons
#3
Your other option is to use functools module and partial
import tkinter as tk
from functools import partial
class Yahtzee(tk.Frame):
    def __init__(self, parent=None):
        ....
    def make_dice(self):
        for pic in picture_list:
            btn=tk.Button(parent, image= pic, command= partial(when_clicked,arguments)
            btn.pack(side=left)
            ......
    def when_clicked(*args):
        ...
            
pretty sure I gave you a class template on your last post, search saving your photo images so they won't get garbage collected, Start making lists, use loops, zip list into dictionaries. Lists are static they won't change position. refract and simplify.
Reply


Messages In This Thread
RE: Need tkinter help with clicking buttons - by joe_momma - Jan-03-2020, 04:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Clicking on the button crashes the TK window ODOshmockenberg 1 2,255 Mar-10-2022, 05:18 PM
Last Post: deanhystad
  tkinter toggle buttons not working Nu2Python 26 7,040 Jan-23-2022, 06:49 PM
Last Post: Nu2Python
  TkInter Binding Buttons ifigazsi 5 4,437 Apr-06-2020, 08:30 AM
Last Post: ifigazsi
  Issue on tkinter with buttons Reldaing 1 2,455 Jan-07-2020, 08:21 AM
Last Post: berckut72
  Tkinter Buttons action d3fi 1 2,015 Nov-20-2019, 09:16 PM
Last Post: Larz60+
  Nesting menu buttons tkinter for python Mocap 1 2,732 Jul-18-2019, 11:46 AM
Last Post: metulburr
  tkinter- adding a new window after clicking a button built on the gui ShashankDS 2 6,636 Apr-18-2019, 12:48 PM
Last Post: ShashankDS
  [Tkinter] Adding New TAB to NoteBook Widget by Clicking Vicolas 0 2,622 Feb-15-2019, 06:03 PM
Last Post: Vicolas
  [Tkinter] Clicking a RadioButton in a for Loop & Getting the Appropriate Return Vicolas 1 5,175 Feb-02-2019, 01:53 AM
Last Post: woooee
  [Tkinter] Close Toplevel after clicking button jollydragon 3 10,663 Jul-12-2018, 06:22 AM
Last Post: jollydragon

Forum Jump:

User Panel Messages

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