Tkinter: using a Listbox

Discussion in 'Python' started by Ebba Cecilia Ovesdotter Alm, Jan 7, 2005.

  1. Hello,

    I'm learning how to use the Tkinter module. I would like to
    use an element similar to a drop-down form,
    where the user can select one option out of many. I thought
    that a Listbox item could do just this. The following extract
    from my code (with the listbox part basically mirroring
    http://effbot.org/books/tkinterbook/listbox.htm),
    does, however, not create a visable Listbox. Am I
    interpreting the Listbox incorrectly? Ideas or suggestions are
    appreciated.

    #Frame & label for the listbox
    self.selectFrame = Frame(self.root)
    self.selectFrame.pack(side=TOP, fill=X, padx=10)
    Label(self.selectFrame, text='Primary choice').pack(side=LEFT)
    #Listbox
    self.listbox = Listbox(self.selectFrame)
    self.listbox.insert(END, "a list entry")
    for item in ["A","B","C"]:
    self.listbox.insert(END, item)

    Thanks,
    Cecilia
     
    Ebba Cecilia Ovesdotter Alm, Jan 7, 2005
    #1
    1. Advertising

  2. Ebba Cecilia Ovesdotter Alm

    Steve Guest

    > #Listbox
    > self.listbox = Listbox(self.selectFrame)
    > self.listbox.insert(END, "a list entry")
    > for item in ["A","B","C"]:
    > self.listbox.insert(END, item)


    Don't forget to pack the listbox.

    You may find this useful...
    http://www.ferg.org/thinking_in_tkinter/index.html
     
    Steve, Jan 7, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. blenderdude
    Replies:
    0
    Views:
    1,154
    blenderdude
    Aug 3, 2003
  2. DC Gringo
    Replies:
    0
    Views:
    423
    DC Gringo
    Apr 6, 2004
  3. kent
    Replies:
    1
    Views:
    910
    Andrew de la Harpe
    May 3, 2004
  4. Replies:
    6
    Views:
    622
    Hendrik van Rooyen
    May 31, 2007
  5. Terry Reedy
    Replies:
    5
    Views:
    532
    Robert Kern
    Nov 30, 2010
Loading...

Share This Page