oops!!! i forgot the app sample code. Here it is. The Problem and help request is copied at the bottom.
#!/usr/bin/env python
-- coding: iso-8859-15 --
generated by wxGlade 0.6.2 on Thu May 14 10:47:44 2009
import wx
begin wxGlade: extracode
end wxGlade
class MyFrame(wx.Frame):
def init(self, *args, **kwds):
# begin wxGlade: MyFrame.init
kwds[“style”] = wx.DEFAULT_FRAME_STYLE
wx.Frame.init(self, *args, **kwds)
self.panel_1 = wx.Panel(self, -1)
self.text_ctrl_1 = wx.TextCtrl(self.panel_1, -1, “”)
self.combo_box_1 = wx.ComboBox(self.panel_1, -1, choices=[], style=wx.CB_DROPDOWN)
self.__set_properties()
self.__do_layout()
# end wxGlade
self.combo_box_1.Bind(wx.EVT_SET_FOCUS, self.CombosSetFocus)
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("frame_1")
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_2 = wx.BoxSizer(wx.VERTICAL)
sizer_2.Add(self.text_ctrl_1, 0, 0, 0)
sizer_2.Add(self.combo_box_1, 0, 0, 0)
self.panel_1.SetSizer(sizer_2)
sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.Layout()
# end wxGlade
def CombosSetFocus(self, evt):
print "CombosSetFocus Fired"
evt.Skip()
end of class MyFrame
if name == “main”:
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, “”)
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()
Help please,
I put a txtCtrl and Combobox on a panel and tab from
the textCtrl to the combobox. I bound the wx.EVT_SET_FOCUS event to a
handler that just prints a line saying it fired, and then evt.Skip().
But it runs 2 times. This causes trouble in a larger program where i
want it to run only once. There the double run causes the combobox kill
focus evt to run and then the set focus runs its second time.
If i don’t use evt.Skip() then the combobox never gets the cursor in its textbox part.
In the larger program when 1 combobox gets enter pressed it sends
focus to the next combobox. The double focusing causes trouble because
some code and functions are running twice.
How to have a wx.EVT_SET_FOCUS for a combobox only run 1 time, even
with Evt.Skip(). Also any reason for this double running behaviour so i
might understand it better?
Many thanks, my head and desk already have dents from banging into each other. Markandeya