lec23_GUIintro -...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#!/Library/Frameworks/Python.framework/Versions/Current/bin/python # A simple GUI program using wxPython to take in a function or data # from a user and plot it using pylab # Illustrates use of: #Textboxes #Choice Menus #File Dialogs #Click Event Binding import wx, os from pylab import * #Function to be called upon click of "Plot it!" button def showplot(event): lineStyle=styleChoice.GetStringSelection() if fileName: data=np.loadtxt(fileName) x=data[:,0] y=data[:,1] plot(x,y,lineStyle) else: x=linspace( float(plotLow.GetValue()), float(plotHi.GetValue()), 300) plot(x,eval(plotEqn.GetValue()),lineStyle) xlabel("x") ylabel("f(x)") show() #Function to be called on click of "Load Data File" button def getFile(event): #Provide some default file types wildcards="Data file (*.dat)|*.dat|" \ "Text file (*.txt)|*.txt|" \ "All Files (*.*)|*.*" #Create the file Dialog box dlg=wx.FileDialog(win, message="Choose a data file . ..", defaultDir = os.getcwd(), defaultFile="", wildcard=wildcards, style=wx.OPEN | wx.CHANGE_DIR
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/05/2010 for the course PHYS phy503 taught by Professor Gladden during the Spring '09 term at Ole Miss.

Page1 / 2

lec23_GUIintro -...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online