【wxpython】py:603: wxPyDeprecationWarning: Using deprecated class PySimpleApp.

来源:互联网 发布:如何联系淘宝小二 编辑:程序博客网 时间:2024/06/01 19:25

提示错误:

py:603: wxPyDeprecationWarning: Using deprecated class PySimpleApp. Use :class:`App` instead. app = wx.PySimpleApp()

代码:

import wxclass MyFrame(wx.Frame):    def __init__(self):        wx.Frame.__init__(self, None, -1, "My Frame", size=(300, 300))        panel = wx.Panel(self, -1)        panel.Bind(wx.EVT_MOTION, self.OnMove)        wx.StaticText(panel, -1, "Pos:", pos=(10, 12))        self.posCtrl = wx.TextCtrl(panel, -1, "", pos=(40, 10))    def OnMove(self, event):        pos = event.GetPosition()        self.posCtrl.SetValue("%s, %s" % (pos.x, pos.y))if __name__ == '__main__':    app = wx.PySimpleApp()    frame = MyFrame()    frame.Show(True)    app.MainLoop()

解决方案:

app = wx.PySimpleApp()

修改为:

app = wx.App()

原因:
wx.PySimpleApp() 这个方法在wxPython2.9后已经被弃用。

阅读全文
0 0
原创粉丝点击