TextCtrl not working with hint when disabling visual effects on the system

I noticed that if you set a hint for TextCtrl in Windows 7, then the widget behaves incorrectly with certain settings of visual effects.

If visual effects are disabled in the system, and a hint is set for the widget, then after entering the text, the GetValue method always returns an empty string.


import wx

class Frame(wx.Frame):

    def __init__(self):

        box = wx.BoxSizer(wx.VERTICAL)

        box.Add(wx.StaticText(self, label='textCtrl'), 0, wx.ALL, 5)
        textCtrl = wx.TextCtrl(self, size=(300, -1), style=wx.TE_CENTRE, name='textCtrl')
        box.Add(textCtrl, 0, wx.ALL, 5)
        textCtrl.Bind(wx.EVT_TEXT, self.OnTextChanged)

        box.Add(wx.StaticText(self, label='textCtrlHint'), 0, wx.ALL, 5)
        textCtrlHint = wx.TextCtrl(self, size=(300, -1), style=wx.TE_CENTRE, name='textCtrlHint')
        box.Add(textCtrlHint, 0, wx.ALL, 5)
        textCtrlHint.Bind(wx.EVT_TEXT, self.OnTextChanged)


    def OnTextChanged(self, event):
        textCtrl = event.GetEventObject()
        print(f'{textCtrl.GetName()} value:', repr(textCtrl.GetValue()))

app = wx.App()

Visual effects settings and program output (sequentially I enter the text “Text” in each field):

Visual effects settings (best performance) and program output:

Doesn’t work when the “Use visual styles on windows and buttons” flag is disabled.

What could be the problem? Is it possible to solve it?

System parameters:

  • Windows 7 x32 (VirtualBox)
  • Python 3.7.9
  • wxPython 4.0.7.post2

P.S.: Everything works correctly on Windows 10.
P.P.S.: It works correctly in wxPython 4.1.1.