[Tutor] Beginner issue with Tkinter Listbox

David Johnson david.johnson.ca at me.com
Wed Sep 3 13:42:37 CEST 2008

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


Here's the experiment:

from Tkinter import *

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

         frame2 = Frame(master)

         bttn = Button(frame1)

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


root = Tk()
app = Application(root)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080903/c111904d/attachment.htm>

More information about the Tutor mailing list