13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

http://www.zetcode.com/wxpython/tips/accordingly. If there is nothing to undo, the undo button isdisabled.a = stockUndo.pop()if len(stockUndo) == 0:self.toolbar.EnableTool(ID_UNDO, False)a.undo()stockRedo.append(a)If we click undo, we pop up an UndoText object from thestockUndo list. Call the undo() method and append theobject to the stockRedo list.Configuring application settingsMany applications allow users to configure their settings.Users can toggle tooltips on and of, change fonts, defaultdownload paths etc. Mostly they have a menu option calledpreferences. Application settings are saved to the hard disk,so that users do not have to change the settings each timethe application starts.In <strong>wxPython</strong> we have wx.Config class to do our job.On Linux, settings are stored in a simple hidden file. Thisfile is located in the home user directory by default. <strong>The</strong>location of the configuration file can be changed. <strong>The</strong> nameof the file is specified in the constructor of the wx.Configclass. In the following code example, we can cofigure thesize of the window. If there is no configuration file, theheight and the width of the window is set to the defaul 250px value. We can set these values to a range from 200 -500px. After we save our values and restart the application,the window size is set to our preffered values.#!/usr/bin/python# myconfig.pyimport wxclass MyConfig(wx.Frame):11 de 15 27/04/2008 1:09

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!