Hey,

I am trying to use Tkinter to provide a gui to a simple python script.

No matter what I try, my tkinter window always ends up maximised, filling the entire screen.

Specifying the height and width has no effect. I have tried a simple label, and tried putting the label inside a frame - in both cases specifying height and width - but to no avail.

To illustrate what I mean:

from tkinter import *

l = Label(text='testing')
l.pack()

root = Tk()
root.mainloop()

and

from tkinter import *

l = Label(width=50, height= 20, text='testing')
l.pack()

root = Tk()
root.mainloop()

both produce exactly the same thing - a tkinter window maximised, filling the screen, with 'testing' in the center.

Am I being really stupid here? (note: this is my first attempt at using tkinter, and I am not very confident with python generally yet)

The only thing I can think of is that I am doing this on a netbook running Ubuntu Netbook Remix, which includes a window manager called 'Maximus' that is supposed to make best use of the small screen by using as much space as possible for a window (e.g. it removes the usual titlebars). I know from experience that Maximus can mess windows up sometimes...

Help or thoughts much appreciated :)

No offence, but you are being slightly stupid :D
There should be no difference in window size in either of your attemps. This is because you are calling

root = Tk()

which is what makes the window.

You can use stuff like this:

root = Tk()
root.title('hello')
root.minsize(100, 100)
root.maxsize(400, 400)
root.geometry("231x326") #Not exactly sure how u do this 1!
root.wm_iconbitmap('icon.ico')
#etc.

That or ur window thingy is messin around wif it...

Many thanks, that does the trick :)

As I say, I am still very new to this!

Take an offensive term:
You are being stupid
Water it down:
You are being slightly stupid
Water it down some more with a smiley:
You are being slightly stupid :D
And more:
No offence, but you are being slightly stupid :D

It just seems to be a convoluted introduction of ambiguous tone?!

- But the solution seems to work for the OP.

haha lol :) ... smartass

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.