Skip to main content
0 online
C
chuckthecloneOG 2002

ok well now im onto building the design for everything. i've kinda run into a problem. well its not really a problem but a question of proper programming techniques. i've started to program with tkinter(tcl or tk). at the moment im making a keyboard for my game. this is what i've written so far.

from Tkinter import *
root = Tk()
root.geometry('600x200')
c1 = "blue"
Button(root, text = "Q", fg = c1, borderwidth = 3, relief = 'raised', width = 5, command = exeQ).grid(row = 3, column = 0, columnspan = 19)
Button(root, text = "W", fg = c1, borderwidth = 3, relief = 'raised', width = 5, command = exeW).grid(row = 3, column = 20, columnspan = 19)
Button(root, text = "E", fg = c1, borderwidth = 3, relief = 'raised', width = 5, command = exeE).grid(row = 3, column = 40, columnspan = 19)
Button(root, text = "R", fg = c1, borderwidth = 3, relief = 'raised', width = 5, command = exeR).grid(row = 3, column = 60, columnspan = 19)
Button(root, text = "T", fg = c1, borderwidth = 3, relief = 'raised', width = 5, command = exeT).grid(row = 3, column = 80, columnspan = 19)
Button(root, text = "Y", fg = c1, borderwidth = 3, relief = 'raised', width = 5, command = exeY).grid(row = 3, column = 100, columnspan = 19)
root.mainloop()

now theres my problem. it is going to be very reptitious. is there anyway that i can make the buttons using a for loop? im not very familair with for or spelling familair so don't ask me to do either one of those. i was thinking i could use a for statement to save all of the letters to a list. then i could use a for statement to make all of the buttons. when you click the button it will run a command that saves the letter from the list to my program i have for hangman.

Welcome Back to eZabel

It's been a while. Here's what's new.

eZabel Lore

A complete history of our community — stats, Hall of Fame, legendary threads, and more.

View the Lore →

Everything Preserved

All 225,969 pieces of content from 2000–2014 are here — forums, messages, journals, photos, polls, and events.

💎

Gems

Spot something you love — a legendary comment, a classic thread, a great photo? Log in and click the diamond icon to mark it as a Gem. Add a note about why it's special. The best stuff surfaces on the Gems page.