Hi,
How do i add a drop down box with few pre-populated strings in the same?
I could find list box and drop down menu in the HELP document of Python, but not drop down box.
Please help me in this.
Thanks,
BK
11 23934
Hi,
How do i add a drop down box with few pre-populated strings in the same?
I could find list box and drop down menu in the HELP document of Python, but not drop down box.
Please help me in this.
Thanks,
BK
Tkinter does not have a combobox. If you are using Tkinter, I can supply a module that requires Python Image Library to make a drop-down menu + a text entry + graphics look like a combo box, but it may need some work first. I now use wxPython for GUI.
Tkinter does not have a combobox. If you are using Tkinter, I can supply a module that requires Python Image Library to make a drop-down menu + a text entry + graphics look like a combo box, but it may need some work first. I now use wxPython for GUI.
If that is so, could u please help me in this regard. Are there any pre requisites for the issue?
Thanks,
BK
If that is so, could u please help me in this regard. Are there any pre requisites for the issue?
Thanks,
BK
I am unclear on which issue you want help with.
Hi,
My intention is to have a drop down box (with edit facility) which would have several ip addresses. The user either can select an existing one or else type a new ip.
I could find spinbox option but thats not editable.
So how do i create such a drop down box?
Thanks,
Badri
Hi,
My intention is to have a drop down box (with edit facility) which would have several ip addresses. The user either can select an existing one or else type a new ip.
I could find spinbox option but thats not editable.
So how do i create such a drop down box?
Thanks,
Badri
You still have not said which GUI you are using. If you are using Tkinter, I can supply a class, but it will take me some time to make it work for you.
You still have not said which GUI you are using. If you are using Tkinter, I can supply a class, but it will take me some time to make it work for you.
Yes, I am using Tkinter.
Yes, I am using Tkinter.
Ok, I'll tweek my module to work for you.
Would you include the code so everyone could benefit?
Ok, I'll tweek my module to work for you.
Would you include the code so everyone could benefit?
Yep. I'll get right on it.
Yep. I'll get right on it.
As promised: -
from Tkinter import *
-
-
## I have a working ComboBox which is editable and
-
## has a button around here some where. I'll keep
-
## looking for that. In the mean time, this Entry
-
## subclass shares a StringVar with the menu item
-
## that are created form input list(s) to achive a
-
## simple ChoiceBox.
-
-
class ChoiceBox(Entry):
-
"""ComboBox(parent, itemList=[], *args, kwargs)
-
A simple ChoiceBox with checked menu items
-
itemList may be a mix of list of strings and lists of tuples of (label, list of strings)
-
for one level of sub menu items. *args and kwargs are passed to the Entry widget."""
-
-
def __init__(self, parent, itemList=[], *args, **kwargs):
-
Entry.__init__(self, parent, *args, **kwargs)
-
-
self.pyvar = pyvar = StringVar(self) # this is the sharing mechanism
-
self.config(textvariable=pyvar) # add the StringVar to self.
-
-
self.popup = popup = Menu(self, tearoff=0)
-
self.bind("<Button-1>", self.mousedown, add="+")
-
-
for item in itemList:
-
if type(item) == tuple:
-
submenu = self.GetSubMenu(item[0])
-
for subitem in item[1]:
-
self.AddCBMenuItem(submenu, subitem)
-
else:
-
self.AddCBMenuItem(popup, item)
-
-
def GetSubMenu(self, label):
-
menu = Menu(self, tearoff=0)
-
self.popup.add_cascade(menu=menu, label=label)
-
return menu
-
-
def AddCBMenuItem(self, menu, label):
-
menu.add_checkbutton(label=label,
-
command=self.MenuSelect,
-
variable=self.pyvar, # add the StringVar to a menu.
-
onvalue=label, offvalue='')
-
-
def mousedown(self, event):
-
x = event.x_root - event.x
-
y = event.y_root - event.y
-
self.popup.post(x, y)
-
return 'break'
-
-
def get(self):
-
return self.pyvar.get()
-
-
def clear(self):
-
self.pyvar.set('')
-
-
def MenuSelect(self):
-
pass
-
-
-
-
if __name__ == '__main__':
-
-
-
-
def _test():
-
root = Tk()
-
## cb = ChoiceBox(root, [('test', ['one', 'two', 'three'])])
-
cb = ChoiceBox(root, ['one', 'two', 'three'])
-
cb.pack()
-
root.mainloop()
-
-
_test()
-
Cool code, but I don't see how to enable typing in a new entry...?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: PT |
last post by:
I got a form with many text boxes, checkboxes and 3 drop downs. From
that 3, 2 are dependant. I can choose one drop down, and the next drop
down...
|
by: ehm |
last post by:
I am working on creating an editable grid (for use in adding,
deleting, and editing rows back to an Oracle database). I have a JSP
that posts back...
|
by: Don Wash |
last post by:
Hi There!
I have a Server-side Drop-down box in ASP.NET (VB) page. What do I do to
widen the Drop down box's Pull-Down list's width?
I'm not...
|
by: Yoshitha |
last post by:
hi
I have 2 drop down lists in my application.1st list ontains itmes like
java,jsp,swings,vb.net etc.2nd list contains percentage i.e it...
|
by: Alex Hunsley |
last post by:
Can anyone recommend some code for creating drop-down menus in tkinter?
To be absolutely clear, here's an example of a drop-down:
...
|
by: bruce |
last post by:
Hi...
Never used python, but I have a question regarding Drop Down Menus. Does
Python allow me to create a website, that will permit the user to...
|
by: callawayglfr |
last post by:
I am building a database in access where I have a drop down box that
relates to a text box, that part I have working but when someone
selects...
|
by: TycoonUK |
last post by:
Hi,
As I do not have IE7 on my computer, I was wondering if there is a
fault in my CSS Menu when using IE7.
Please can someone look at my site...
|
by: penny111 |
last post by:
Hi there,
For my application, i need to have 3 drop down lists
1. drop down list of folder names
2. drop down list of documents in the folder...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...
| |