正如标题所说,当我实现代码来清除暗示的文本时,它运行时应用程序崩溃。在
据我所知,这只在macosx10.8上运行,但这也是我能运行它的全部功能。在
在其他代码上,它确实在运行,只有当我在其中输入文本(在给予焦点之后)它才会崩溃。但这个应用程序立即崩溃(我认为这与其他小部件无关,因此它会立即获得关注)。更新了示例,使其不再立即崩溃,现在您必须单击组合框并尝试键入它,使其崩溃。在
但是,如果文本不是“看起来”的话,则不会出现这种情况。在
编码
import wx
class MyCrashyPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent, -1)
# another widget to take focus at first otherwise it crashes instantly!
sizer = wx.BoxSizer(wx.VERTICAL)
self.text_ctrl = wx.TextCtrl(self, -1, value = "There are major problems here.\nWithout this to auto take focus this will crash immediatly just by trying to clear the hint.\nNow you have to click on the combo ctrl and try to type.", style = wx.TE_MULTILINE)
self.search_ctrl = wx.ComboBox(self, -1)
self.search_ctrl.SetMinSize((650, -1))
self.search_ctrl.SetSize((650, -1))
self.search_ctrl.SetHint("This is are hint text; once it is clear and you try to type something in it it will crash on Mac OS X")
sizer.Add(self.text_ctrl, flag = wx.EXPAND)
sizer.Add(self.search_ctrl)
self.SetSizer(sizer)
self.FirstTimeSearchGetsFocus = True
self.Bind(wx.EVT_BUTTON, lambda e: e.Skip(), self.text_ctrl)
self.search_ctrl.Bind(wx.EVT_SET_FOCUS, self.OnSearchFocus)
self.text_ctrl.SetFocus()
def OnSearchFocus(self, event):
print "Search Focus"
if 1==1:
print "First time"
# clear the hinted text
self.search_ctrl.SetHint("")
self.search_ctrl.Clear()
self.search_ctrl.Refresh()
self.FirstTimeSearchGetsFocus = False
event.Skip()
if __name__ == "__main__":
app = wx.App(False)
f = wx.Frame(None, -1)
MyCrashyPanel(f)
f.Show()
app.MainLoop()
事故报告
[太大了,过来http://pastebin.com/9B1Sgh3P]
如果崩溃,这是wxWidgets中的一个bug,因此只需执行以下操作:
相关问题 更多 >
编程相关推荐