REVISED: Sunday, March 3, 2013
In this tutorial, you will learn how to change the title and size of a wxPython GUI frame.
I. wxPYTHON EXAMPLE PROGRAM
Start the Python 2.7.3 interpreter shell by "double left mouse clicking" the Python icon on your desktop. When the "Python Shell" window opens select "File", then select "New Window".
# Imports wx
# Allows us to use the wxPython GUI toolkit
import wx
# Creates a class named bright
# Frame is a class in wx
class bright(wx.Frame):
# Tells wx to build the frame
# Creates a frame constructor method
# Frame is named "Bright Frame"
# Frame size is 800 pixels wide and 400 pixels tall
def __init__(self,parent,id):
wx.Frame.__init__(self,parent,id,'Bright Frame', size=(800,400))
# Tells wx to show the frame
if __name__=='__main__':
# Application object runs the program
app=wx.PySimpleApp()
# Frame object displays the program
frame=bright(parent=None,id=-1)
# Shows the frame
frame.Show()
# Runs the main loop
app.MainLoop()
From the "New Window", do a "File Save As" and save the above Python program, using the file name brightFrame.py to the same path which your computer used to download Python 2.7.3. For example, I saved my brightFrame.py file to my Python27 folder using the following path:
C:\Python27\brightFrame.py
From the "New Window", do a "Run" and then a "Run Module F5" and a wxPython GUI toolkit frame with the title "Bright Frame" in the top left corner will open. The comments which start with a hash, #, sign explain how this wxPython program works. Also, notice some of the underscores are double underscores; e.g., __init__, __name__, and __main__ all have double underscores before and after them .
In this tutorial, you have learned how to change the title and size of a wxPython GUI frame.
Elcric Otto Circle
Elcric Otto Circle
-->
-->
-->
How to Link to My Home Page
It will appear on your website as:"Link to ELCRIC OTTO CIRCLE's Home Page"
No comments:
Post a Comment