I have been googling about this problem and couldn’t find any good websites….
I want to create buttons and entry widget looks like:
[A] [B] [C] [D] [E] [F]
[ENTRYWIDGET HERE] [OK]
My code looks like:
class Controller(Frame):
def __init__(self,parent): Frame.__init__(self, parent) self.parent = parent self.button1 = Button(parent, text = "A") self.button1.pack(side = TOP) self.button1 = Button(parent, text = "B") self.button1.pack(side = TOP) self.button1 = Button(parent, text = "C") self.button1.pack(side = TOP) self.button1 = Button(parent, text = "D") self.button1.pack(side = TOP) self.button1 = Button(parent, text = "E") self.button1.pack(side = TOP) self.button1 = Button(parent, text = "F") self.button1.pack(side = TOP) self.myentrybox = Entry(parent, width = 50) self.myentrybox.pack(side = LEFT) self.button = Button(parent, text = "OK") self.button.pack(side = RIGHT )
And this looks completely different with what i’m trying to create..
Any feedbacks would be so grateful thanks.
You can just put your buttons into another
Frame.Example:
Result:
Edit to answer your comments
If you want to stick with
forloop for creating the buttons, a good way to apply the event handler is to create a mapping ofbutton<=>function to callusing adict:This way, it’s easily extendable. If you don’t care about the order of the buttons, you can just use