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

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()

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

thankyou v.much:)

This question has already been answered. Start a new discussion instead.