[Tutor] tkinter message & button questions

Peter Otten __peter__ at web.de
Wed Nov 30 17:09:16 CET 2011


Cranky Frankie wrote:

> Peter thanks again. The msg_widget is still resizing vertically
> depending on the lenght of the quote, but at least now the horizontal
> sizing is staying the same. Ideally the msg_widget would be the *same
> size*, no matter what the quote length is, but since this program is
> really just a learning exercise and to show database adminstrators a
> simple Python GUI application I can live with it.

Well, you can place() everything yourself:

root = Tk()
win = Frame(root)
win.place(relheight=1, relwidth=1)

label_widget = Label(win, text="Welcome to Quote of the Day")
label_widget.place(width=300, height=20)

msg_widget = Message(
    win, anchor=NW, justify=LEFT, width=1000, bd=2,
    bg="white", relief=SOLID, text=choose_quote())
msg_widget.place(width=300, height=50, y=20)

next_button = Button(win, text="Next Quote", command=display_quote)
next_button.place(y=70)

quit_button = Button(win, text="QUIT", fg="red", command=quit)
quit_button.place(y=70, x=200)

root.geometry("400x100")
root.mainloop()

The disadvantage of that approach is of course that you have to place 
everything yourself ;)




More information about the Tutor mailing list