#!/usr/bin/python """ Module : basicPyCrust.py Version : 1.0 Author : Andrew J Todd esq, Halfcooked Solutions Date : 18th December, 2002 Purpose : Simple example of how to embed PyCrust in a wxWindows application """ import sys, os from wxPython import wx from wxPython.lib.PyCrust import shell class PyCrustFrame(wx.wxFrame): def __init__(self, parent, ID, title, pos, size, parentApp): wx.wxFrame.__init__(self, parent, ID, title, pos, size) parentApp.shell = shell.Shell(self, -1) parentApp.shell.interp.locals['pcapp'] = parentApp self.parentApp = parentApp if sys.platform[0:3] == "win": self.SetSize((size[0]-1, size[1])) self.SetSize(size) wx.EVT_CLOSE(self, self.onCloseMe) def onCloseMe(self, evt): self.Show(0) class myFrame(wx.wxFrame): def __init__(self, parent, ID, title, pos, size, parentApp): wx.wxFrame.__init__(self, parent, ID, title, pos, size) # A text field self.textFld = wx.wxTextCtrl(self, -1, size=(500,300), style=wx.wxTE_MULTILINE) # A slider self.slider = wx.wxSlider(self, -1, 0, 0, 100, point=(10,350), size=(100, -1), style= wx.wxSL_HORIZONTAL|wx.wxSL_AUTOTICKS| \ wx.wxSL_LABELS) self.slider.SetTickFreq(5, 1) # Finally, a toggle button self.button = wx.wxToggleButton(self, -1, "Toggle", pos=(250,350)) # Add in the crust, hmm self.crustFrame = PyCrustFrame(self, -1, "Shell", (200,701), (500,200), parentApp) self.crustFrame.Show(wx.TRUE) class myApp(wx.wxApp): def OnInit(self): self.frame = myFrame(None, -1, "A Basic Application", (200,200), (500,500), self) self.frame.Show(wx.TRUE) self.SetTopWindow(self.frame) return wx.TRUE if __name__ == "__main__": app = myApp(0) app.MainLoop()