The main problem with creating a simple window in wxPython is that the windowing system does not provide a default constructor for windows. This means that you must create a new window object each time you want to create a new window.
import wx class MyFrame(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, title=title) self.control = wx.TextCtrl(self) self.CreateStatusBar() # Setting up the menu. filemenu= wx.Menu() # wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets. menuAbout = filemenu.Append(wx.ID_ABOUT, "&About"," Information about this program") menuExit = filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program") # Creating the menubar and adding menus to it: menuBar = wx.MenuBar() menuBar.Append(filemenu,"&File") # Adding the "filemenu" to the MenuBar # Adding a panel so it looks correct on all platforms: self .panel = wx . Panel ( self ) # And put some text with a larger font on it: st = wx . StaticText ( self . panel , - 1 , "Hello World!" , ( 20 , 20 )) font = st . GetFont () font . PointSize += 10 font = font . Bold () st . SetFont ( font )
# A button:
self . button = wx . Button ( self . panel , – 1 , “Click me!” , ( 100 , 100 ))
# Bind an event to the button. When the user clicks on it, the
# method “OnClick” will be called.
self . button . Bind ( wx . EVT_BUTTON , self . OnClick )
# Adding the panel to the frame content:
self . sizer = wx . BoxSizer ()
self . sizer . Add ( self . panel , 1 , wx. EXPAND )
# Use some sizers to see layout options:
self.sizer0 = wx.BoxSizer(wx.HORIZONTAL)
self.sizer1 = wx.BoxSizer(wx.VERTICAL)
print(“Button was clicked!”)
d= AboutDialog ( None )
d. ShowModal ()
d. Destroy ()
Windows is a graphical operating system from Microsoft. It was first released in 1985 as a replacement for the MS-DOS operating system. Windows is built on the NT kernel and uses an object-oriented programming model. Windows also has a graphical user interface that allows users to interact with the computer through menus and icons.
Windows is a graphical user interface for computers. It was first released in 1985, and it is a part of the Microsoft Windows family of operating systems. Windows uses the graphical user interface model, which means that it uses icons on the desktop to represent files and folders. You can use the mouse to click on an icon to open the file or folder.
wxPython is a GUI toolkit for Python that provides a rich set of widgets and controls to create graphical user interfaces. It is released under the GNU General Public License.