By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

[TKinter] Options menu with scroll arrows?

P: 2
Hello everyone,

I am trying to make a small GUI with TKinter for python. One widget is an option menu with a large number of items (+50). My code works but shows a large option list with as many items as fit on the screen when I click on the option menu. I'd like that it shows me only a few items (e.g. 5) and allow the user to scroll up and down.

Thanks in advance for your help

The following code can be used for testing:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/python
  2. from Tkinter import *
  3.  
  4. class App(object):
  5.     def __init__(self,parent):
  6.         fSize = 10
  7.         self.f = Frame(parent,width=fSize,height=fSize)
  8.         self.f.pack(padx=15,pady=15)
  9.  
  10.         self.Options = ["Todos", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56"]
  11.         self.textInfo1 = StringVar(self.f)
  12.         self.textInfo1.set(self.Options[0])
  13.         self.labelInfo1 = apply(OptionMenu, (self.f , self.textInfo1) + tuple(self.Options))
  14.         self.labelInfo1.pack(side=TOP)
  15.  
  16. root = Tk()
  17. root.title('Title')
  18. app = App(root)
  19.  
  20. root.mainloop()
Jan 30 '14 #1
Share this Question
Share on Google+
1 Reply


bvdet
Expert Mod 2.5K+
P: 2,851
You cannot do that with an OptionMenu. You can do it with a Listbox though.
Jan 30 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.