I have just started learning Python and have moved on to learning about Tkinter. This is likely to be a very easy question but I have no idea what is happening here.

I am trying to set up a GUI, separated into several frames. In a lower frame I have added a Listbox. I want the first item in the Listbox to be highlighted when the programme starts up. Before adding the ".selection_set" method, the GUI looked just fine. I used the propagate method to fix the frame dimensions in my original programme.

However, as soon as call the method: ListboxName.selection_set(0), the lower frame (containing the Listbox), ends up on the top row, covering the orginal top frame.

I tried a very small bit of code to replicate the basic elements and the same happens (see code below):

I am working using a mac and XCode, (cocoa-python project). Just as an additional point, I have diccovered that running the same programme through Terminal actually does just fine and displays the windows I want without a problem.

Thanks in advance for any help with this

Dave



Here's the experiment:


from Tkinter import *

class Application():
    def __init__(self, master):
        frame1 = Frame(master)
        frame1.grid()

        frame2 = Frame(master)
        frame2.grid()

        bttn = Button(frame1)
        bttn.grid()

        list = Listbox(frame2)
        list.grid()
        list.insert(END,"What's happening")

        list.selection_set(0)

root = Tk()
app = Application(root)
root.mainloop()

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to