Changing the size of a Button

Miki miki.tebeka at gmail.com
Sun Mar 9 14:11:12 EDT 2008


Hello Konrad,

> How do i change the size of a Button
> (using Tkinter), other than to set it
> during construction?
In Tkinter, usually the geometry managers (such as pack) are the ones
who size the widgets.
If you run something like:
    import Tkinter as tk

    root = tk.Tk()
    def change_size():
        b["text"] = "More text"

    b = tk.Button(root, text="Text", command=change_size)
    b.pack()

    root.mainloop()

You'll see that the button changes size to accommodate the new text.

HTH,
--
Miki <miki.tebeka at gmail.com>
http://pythonwise.blogspot.com



More information about the Python-list mailing list