Passing variables to Tkinter geometry method
17:36 19 Dec 2014

I've been trying for a while now to find out if there is a way to pass variables to the geometry method in Tkinter.

I know the geometry method accepts a string:

root = Tk()
root.geometry("1200X1024")

I want to open the window based in the screen width.

root = Tk()
w = root.winfo_screenwidth()
h = root.winfo_screenheight()

What I've tried is this:

geometry = "%dX%d" % (w,h)
root.geometry(geometry)

or

root.geometry(("%dX%d" % (w,h)))

No matter how I concatenate the variables it gives this error:

TlcError: bad geometry specifier "1280X1024"

So is it possible to pass variables to the geometry method?

python tkinter