just need some advice on making a list containing values for Tkinter buttons. thankyou

:)

This may give you the hint you need ...

# create a list of buttons

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

def click(val):
    s = "Button " + val + " clicked"
    root.title(s)
    

root = tk.Tk()

# create the list of button objects
button_list = [
tk.Button(root, text=" 1 ", bg='red', command=lambda: click('1')),
tk.Button(root, text=" 2 ", bg='green', command=lambda: click('2')), 
tk.Button(root, text=" 3 ", bg='white', command=lambda: click('3'))
]

# show buttons
for button in button_list:
    button.pack(side='left', padx=25)

root.mainloop()

do you know maybe how to insert it into an entry screen

:)

do you know maybe how to insert it into an entry screen

:)

This should help ...

# create a list of buttons
# show click values in an entry

try:
    # Python2
    import Tkinter as tk
except ImportError:
    # Python3
    import tkinter as tk

def click(val):
    s = "Button " + val + " clicked"
    root.title(s)
    entry.insert('end', val)

root = tk.Tk()

# create the list of button objects
button_list = [
tk.Button(root, text=" 1 ", bg='red', command=lambda: click('1')),
tk.Button(root, text=" 2 ", bg='green', command=lambda: click('2')), 
tk.Button(root, text=" 3 ", bg='white', command=lambda: click('3'))
]

# show buttons
for button in button_list:
    button.pack(side='left', padx=10)

# create an entry to show button values
entry = tk.Entry(root)
entry.pack(padx=3, pady=3)

root.mainloop()

awesome thanks a bunch !!!

:):):):):):)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.