【问题标题】:wxPython clearing hinted text causes crashwxPython清除提示文本导致崩溃
【发布时间】:2013-09-18 15:52:53
【问题描述】:

正如标题所说,当我实现代码以清除提示文本并运行时,应用程序崩溃了。

据我所知,这仅适用于 Mac OS X 10.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]

【问题讨论】:

    标签: python macos wxpython wxwidgets


    【解决方案1】:

    如果它崩溃了,那是 wxWidgets 中的一个错误,所以唯一要做的就是:

    1. 如果您可以自己构建,请尝试使用更高版本,即 2.9.5 或 svn/git。
    2. 如果错误仍然存​​在,请在usual guidelines 之后报告错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多