2014-03-25 52 views
0

我写了下面的代码片段来显示一个简单的窗口。WxPython窗口不弹出

它既不但是不显示窗口,也没有报告任何错误:

import wx  
class myFrame (wx.App) : 
     def __init__(self): 
      x = wx.Frame.__init__(self, "", size=(200,200), title="Thanks", style= wx.SYSTEM_MENU | wx.CLOSE_BOX | wx.CLOSE) 
      x.Show(True) 

    frm = wx.App(False) 
    things = myFrame 
    frm.MainLoop() 

回答

2

你在你的代码中的一些几个问题。
你可能想从下面的代码开始:

import wx 

class myFrame (wx.Frame):   #inherits from a Frame not from an Application 
     def __init__(self, parent): 
      wx.Frame.__init__(self, parent, -1, size=(200,200), title="Thanks") 
      # Note the order of the three positional arguments above 
      # Second one is the parent frame (None here) and the third the window ID 


frm = wx.App(False) 
things = myFrame(None)   # you must call the class to create an instance 
things.Show()     # this is the correct position to show it 
frm.MainLoop() 

如果您运行的代码,你得到一个空架。从这里你可以尝试不同的风格,如果你想。