سؤال

I've written the following snippet to display a simple window.

It however neither does show the window nor reports any error:

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()
هل كانت مفيدة؟

المحلول

You have some few problems in your code.
You may want to start from the following code:

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()

If you run the code you get an empty frame. From here you can try different styles if you want.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top