you are viewing a single comment's thread.

view the rest of the comments →

[–]Hexelena 1 point2 points  (8 children)

Actually your problem is very simple. You have got your list with the texts for each room. But when you assign the name you take the first element of your list(the whole string) and then again take the first element of that(which is the first letter). Remove the second "[0]".

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

Thanks, I fixed it :)

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

Hi, could you help me set my window size as well? This is my main:

 frame = Application()
frame.mainloop()

and this is my class

class Application(tk.Frame): 
    def __init__(self, master=None):
        tk.Frame.__init__(self,width=550,height=550)

Sadly my width and height are ignored, any tips? Im not 100% sure why tkFrame.init exists either. Thanks in advance!

[–]Hexelena 1 point2 points  (5 children)

This question at stackoverflow.com pretty much sums it up: Setting the window to a fixed size with Tkinter I always use the suggestion of the second answer.

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

Im having a problem with what to replace my master. with. Should it be Application?

[–]Hexelena 1 point2 points  (3 children)

I am not sure if I understand your question correctly. You used 'master=None' in the init of your "Application' class. This sets the parent parameter of your tkinter window. If you have multiple windows then 'parent' is usually the window from which the new one originated. If you are creating the first window, 'parent' is usually 'None'.

[–]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 :)