[wxpython-users] Re: Gtk: SetMark on Combobox

Franz Steinhaeusler franz.steinhaeusler at gmx.at
Wed Apr 2 03:41:59 PDT 2008


On Tue, 01 Apr 2008 14:44:44 -0700, Robin Dunn wrote:

> Franz Steinhäusler wrote:
>> On Tue, 01 Apr 2008 10:19:24 -0700, Robin Dunn <robin at alldunn.com>
>> wrote:
>> 
>>> Franz Steinhäusler wrote:
>>>> On Tue, 25 Mar 2008 09:20:36 +0100, Franz Steinhaeusler
>>>> <franz.steinhaeusler at gmx.at> wrote:
>>>>
>>>>> On Sat, 22 Mar 2008 15:30:41 -0700, Robin Dunn <robin at alldunn.com>
>>>>> wrote:
>>>>>
>>>>>> Franz Steinhäusler wrote:
>>>>> [...]
>>>>>>> (wxgtk, unicode, gtk2, wx-assertions off, SWIG 1.3.29)
>>>>>>>
>>>>>> Please try 2.8.7.1
>>>>> Thanks, I will do.
>>>> I finally successfully compiled wxwidgets and wxpyhton from trunk
>>>> svn, but no SetMark is working. :(
>>>> (gtk2)
>>>>
>>>> Could gtk be the reason?
>>> Did you try it like I did in the screen shot where you interactively
>>> do it from a PyShell, or did you try it in a real program?  If the
>>> former then it may have just been a fluke of my current theme that
>>> allowed the selection to be seen when another window had the focus.  I
>>> wasn't expecting it to work that way.
>> 
>> Strange. I tried it after your screenshot. Very good tool this
>> inspector, anyway. I tried it also with the sample alone, with .SetMark
>> and wx.CallAfter (SetMark, x, y). None of that things worked.
>> 
>> Anyway, in the demo, after starting the combobox sample, the whole Text
>> in the combobox is selected. But then, I didn't got it to show the
>> SetMark Selection. Also I'm not 100% sure, but after call SetMark(4,7)
>> afterwards (no selection was shown)I called GetMark and it outputs
>> (7,7).
>> 
>> 
> The initial select-all when it gets the focus may be getting in your
> way.  IIRC it happens after the EVT_SET_FOCUS event happens, so you need
> to get a little tricky to make it work if you want to set some other
> selection upon focus because the wx.CallAfter happens too soon.  Try
> doing it with a short timer instead.

Hello, you meant future call? Hm it doesn't work
Here my small sample app:


import wx



class MyApp(wx.App):

    def OnInit(self):

        frame = wx.Frame(None, title="Test SetMark on Combobox")

        panel = wx.Panel(frame)

        b = wx.Button(panel)

        b.SetPosition ((0, 0))

        self.cb = wx.ComboBox(panel)

        self.cb.SetValue("Hello Combobox")

        b.SetPosition ((0, 30))

        b.Bind(wx.EVT_BUTTON, self.OnButton)

        frame.Show(True)

        return True



    def OnButton(self, evt):

        #self.cb.SetMark (2,5)

        #wx.CallAfter(self.cb.SetMark,2,5)

        wx.FutureCall(3000, self.cb.SetMark,2,5)

        evt.Skip()



app = MyApp(redirect=False)

app.MainLoop() 

-- 
Franz Steinhaeusler



More information about the wxpython-users mailing list