Can't set the focus on text part of a SpinCtrl on a wxPopupWindow.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Can't set the focus on text part of a SpinCtrl on a wxPopupWindow.

Nathanael Zitter
Hello,

I am creating a couple of PopupWindows for my application that hold some controls for changing things on the main panel. Now I want to be able to type numbers in a SpinCtrl but I can't set the focus on the text part of the SpinCtrl and so I can't input any text. The spin buttons themselves work just fine though.

I based my work on the demo (PopupWindow.py in the demo directory of the source code download) which conveniently has a SpinCtrl too. This demo has the exact same behaviour as my own code.
Just to see and test what happens I also added a TextCtrl(1) to the demo to see if it was just SpinCtrl which does not work. But alas, I can't type anything into this TextCtrl either.

Has anybody got an idea on how I can properly type text into these two controls? (And probably every control that uses a text field as part of its make-up.)

I am using wxPython 4.0.1 and Python 2.7. Both installed via Visual Studio 2017's installer and its pypi installer.

Thanks in advance,

Nathanael


(1) I added two lines to the demo in the __init__ function. It looks like this now:
class TestTransientPopup(wx.PopupTransientWindow):
   
"""Adds a bit of text and mouse movement to the wx.PopupWindow"""
   
def __init__(self, parent, style, log):
        wx
.PopupTransientWindow.__init__(self, parent, style)
       
self.log = log
        panel
= wx.Panel(self)
        panel
.SetBackgroundColour("#FFB6C1")


        st
= wx.StaticText(panel, -1,
                         
"wx.PopupTransientWindow is a\n"
                         
"wx.PopupWindow which disappears\n"
                         
"automatically when the user\n"
                         
"clicks the mouse outside it or if it\n"
                         
"(or its first child) loses focus in \n"
                         
"any other way.")
        btn
= wx.Button(panel, -1, "Press Me")
        spin
= wx.SpinCtrl(panel, -1, "Hello", size=(100,-1))
        entry
= wx.TextCtrl(panel, value="Put text in me." ) #Added line
        btn
.Bind(wx.EVT_BUTTON, self.OnButton)


        sizer
= wx.BoxSizer(wx.VERTICAL)
        sizer
.Add(st, 0, wx.ALL, 5)
        sizer
.Add(btn, 0, wx.ALL, 5)
        sizer
.Add(spin, 0, wx.ALL, 5)
        sizer
.Add(entry, 0, wx.ALL, 5) #Added line
        panel
.SetSizer(sizer)


        sizer
.Fit(panel)
        sizer
.Fit(self)
       
self.Layout()

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.