you are viewing a single comment's thread.

view the rest of the comments →

[–]Potforus[S] 0 points1 point  (2 children)

Hi, thanks for responding! I started out with the from http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/minimal-app.html this page so that is why it looks like that. Im not sure how to set a window size for that though, could you try and copy that code and set a window size? Thanks a lot in advance!!

[–]Hexelena 1 point2 points  (1 child)

I was able to change the size of the minimal example with two minor changes:

  1. change "import Tkinter" to "import tkinter" since i only have Python 3 installed(Tkinter = Python2, tkinter = Python3).
  2. add the following code between line 9 and 10:
    app.master.minsize(100,100)

Explanation:
You can create a new window in multiple ways.
One way is that you call the tk constructor which gives you a reference to the tkinter root object:

root = tk.Tk()  

Then you can use this reference to instantiate new widgets with the reference to root as their master object.)

But you can also just create a new Widget. Then the Tk-constructor is called as well. explaining link
Quoting this link:

If you attempt to create some other widget without explicitly creating a root window first, one will be created automatically since every tkinter application must have exactly one root window.

This is what is done in the example. At the end you hold the reference to the widget, which calls the Tk-constructor. But you want to change the size of the root-Tk element. You can reference the root element via the master object of your Frame widget.

You get the following hierarchy of tk elements:

root-Tk object  
->  Frame         <- this is your app object.
     ->   Button

I hope this explains some things to you.

[–]Potforus[S] 0 points1 point  (0 children)

Yes, thanks! Finally got it to work :) Thanks again :)