0

Hi,

I'm wondering how your supposed to find out a widget's width in tkinter..

Little example code to explain (doesnt do anything at all)

class CustomWidget(Tkinter.Frame):
    def __init__(self, master, **kw):
        apply(Tkinter.Frame.__init__, (self, master), kw)

        self.masterWidth = # ???? Totally stuck, tried obvious things like master.width

class MainWindow(Tkinter.Toplevel):
    def __init__(self, master, **kw):
        apply(Tkinter.Toplevel.__init__, (self, master), kw)

        subwidget = CustomWidget(self)
        subWidget.pack()

thanks in advance
a1eio

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by a1eio
0

If you use frame as a parent you can do it easily ...

# using frame as the parent you can access its arguments
# (does not work with root itself)

import Tkinter as tk

root = tk.Tk()
frame = tk.Frame(width=500)

# test frame 'dictionary'
print frame['width']  # 500

root.mainloop()
0

oh my goodness that is all i needed to know!!

thankyou v.much:)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.