wxPython:聚焦TextCtrl

时间:2018-09-04 16:38:16

标签: wxpython wxpython-phoenix

关闭在EVT_SET_FOCUS事件处理程序中弹出的对话框似乎不会释放鼠标按钮。取消该对话框后,将鼠标移到TextCtrl中的文本上将突出显示该文本,看起来鼠标按钮始终保持按下状态。

一个示例更好地显示了问题:

import wx
def focus(evt):
    if wx.GetApp().n % 2 == 0:
        wx.MessageBox(
            'After dismissing this dialog, move mouse over text on the text in '
            'the 2nd TextCtrl and it seems the mouse button is not released.')
    wx.GetApp().n += 1
app = wx.App()
app.n = 0
frame = wx.Frame(None, title='Mousedown Bug', size=(400, 300))
tc1 = wx.TextCtrl(frame, value='Focusing on TextCtrl below pops dialog')
tc2 = wx.TextCtrl(frame, value='Move mouse over me after dismissing dialog')
tc2.Bind(wx.EVT_SET_FOCUS, focus)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(tc1, 0, wx.EXPAND)
sizer.Add(tc2, 0, wx.EXPAND)
frame.SetSizer(sizer)
frame.Show()
app.MainLoop()

这是一个已知的错误还是我错误地使用了事件处理程序?

0 个答案:

没有答案