By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

Tkinter: How do I change the actual width of a widget?

P: n/a
I am trying to change the width of a widget based on pixel size and not
on characters. I can't figure out how to do this.

Normally to change to the size of a widget it looks like:

widget.configure(width = x)

However that is in characters, not in pixels. To retrieve the actual
size of a widget, I believe it is done with:

x = widget.winfo_width()

Obviously that value can not be used in the configure statement. Is
there a way to dynamically change the width (and height) of a widget
using the winfo data?

Thanks,
Marc

Nov 10 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Mudcat wrote:
I am trying to change the width of a widget based on pixel size and not
on characters. I can't figure out how to do this.

Normally to change to the size of a widget it looks like:

widget.configure(width = x)

However that is in characters, not in pixels. To retrieve the actual
size of a widget, I believe it is done with:

x = widget.winfo_width()

Obviously that value can not be used in the configure statement. Is
there a way to dynamically change the width (and height) of a widget
using the winfo data?
look for "pack_propagate" on this page for one way to do it:

http://effbot.org/tkinterbook/button.htm

</F>

Nov 11 '06 #2

P: n/a
Fredrik Lundh wrote:
>
look for "pack_propagate" on this page for one way to do it:

http://effbot.org/tkinterbook/button.htm

</F>

Thanks!

I had actually seen this, but on the pythonware site where it looks
like this:

f = Frame(master, height=32, width=32)
f.pack_propagate(0) # don't shrink
b = Button(f, text="Sure!")
b.pack(fill=BOTH, expand=1)

I guess somewhere along the way it became necessary to use the pack
function with propagate.As a result, I was having problems getting it
to work and thought I was doing something else wrong.

And I guess I also missed the fact that Tkinter doc updates are being
done on effbot. I just upgraded my python version after a long time,
and I'm finding out all kinds of interesting things.

Nov 11 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.