I have a wxPython app with three listboxes. I'd like to make it so something can only be selected in one of them at a time. I thought I could use an event when the listbox is clicked to deselect the other boxes, but there are no events listed for wx.ListBox at wxpython.org. Is there another way to do this?
I think what you want is EVT_LISTBOX
Related
I am working on a project that is going to use tkinter. I was wondering if there was any way to display a different set of widgets based on a radio button selection and it update as soon as it is clicked
You could, for example, put your sets of widgets in different tkinter Frames and show/hide them on demand as you select different radio buttons.
I am using a SearchCtrl with a dropdown menu and I'm having some trouble with the events. When I click the little arrow next to the search button, the EVT_SEARCHCTRL_SEARCH_BTN is triggered, which is not what I want. I only want the EVT_MENU_RANGE to be triggered after I clicked an item, and not also the EVT_SEARCHCTRL_SEARCH_BTN before i click it.
self.search_ctrl = wx.SearchCtrl(self.panel_1, -1,
style=wx.TE_PROCESS_ENTER)
self.search_menu = wx.Menu()
self.search_items = {"text1":"value1", "text2":"value2"}
for txt in self.search_items:
self.search_menu.Append(-1, txt)
self.search_ctrl.SetMenu(self.search_menu)
self.Bind(wx.EVT_SEARCHCTRL_SEARCH_BTN, self.search, self.search_ctrl)
self.Bind(wx.EVT_MENU_RANGE, self.onSearchMenu)
Although I should probably add id's to the menu bind, this isn't causing the problem. The code works as expected when I comment out the search button bind.
UPDATE
Apparently this isn't a problem, but a 'feature' of the searchctrl. I tried the wxpython demo and the menu also showed up if I just clicked the search button, and not the arrow. It is apparently one button, instead of the two i thought it was.
Is there a way to accomplish my original request? Do i have to manually modify a textctrl, or is there an other solution?
All the examples I've seen suggest you need to specify a range of IDs when you call your menu bind.
Maybe by default it binds to something unexpected... ?
Edit - In light of your update, it seems likely that you're going to need to make a custom control to me..
I am developing a GUI in Vizard in which i am using radio buttons to select correct options, but I have a problem that I cannot solve.
In every group of radio buttons the 1st button always appears to be selected, but is actually not selected. The only way to select it is by choosing another button and then choosing the 1st button again.
Does anyone know how to solve this? I would like that in the beginning none of the buttons are selected.
I don't know Vizard but radio buttons probably have a method or another way of deselecting them similar to radiobutton.deselect() method of Tkinter. Have you looked at their documentation?
Also someone have done this trick, may be you should try it:
Create another radio button in that group, let it be selected by default and make it invisible
QuestionBox = vizinfo.add("") #Add the vizinfo object
#Create an invisible Radio button to be the default selected one, so that one of the visible ones must be chosen by the user
invisibleRadio = QuestionBox.add(viz.RADIO, 0, "")
invisibleRadio.visible(0) #invisible
source: http://forum.worldviz.com/showthread.php?t=1611
Wondering if there's a menu event I can bind to that's related to the currently selected menu item? By menu item I mean the items that show up in a popup menu like New, Open, Save, etc.
Use case: I would like to update a statusbar area of our application with a description of the currently selected menu item.
Any ideas appreciated.
Thank you,
Malcolm
You need to bind to the <<MenuSelect>> event.
There's an <Enter> event that is triggered when the mouse pointer enters a widget's space. Depending on how you're building your menu, you may be able to use it.
See http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.htm for more
I am using wxPython to create a taskbar menu. The menu contains some menu items (obviously).
Now I would like to update/change some of these items when a particular item is clicked, while still displaying the menu.
How can I prevent the taskbar menu from disappearing after clicking an item?
The only method I've found that could be useful is wxMenu.UpdateUI(), but that doesn't prevent the menu from disappearing.
Although I never got around to trying it myself, I remember attempting a similar effect with a popup menu & textctrl. You might want to consider trying wx.lib.agw.flatmenu.FlatMenuBar, it provides an event handler OnMenuDismissed(self, event), as well as a few others, which by name appear to be what you need. You would need to create your own OnMenuDismissed() and override the event.