13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

http://www.zetcode.com/wxpython/tips/toolbar = wx.ToolBar(self, -1)self.tc = wx.TextCtrl(toolbar, -1, size=(100, -1))btn = wx.Button(toolbar, ID_BUTTON, 'Ok', size=(40, 28))toolbar.AddControl(self.tc)toolbar.AddSeparator()toolbar.AddControl(btn)toolbar.Realize()self.SetToolBar(toolbar)self.Bind(wx.EVT_BUTTON, self.OnLaunchCommandOk, id=ID_BUTTON)self.Bind(wx.EVT_MENU, self.OnAbout, id=ID_ABOUT)self.Bind(wx.EVT_MENU, self.OnExit, id=ID_EXIT)self.Bind(wx.EVT_TIMER, self.OnTimer, id=ID_TIMER)self.panel = wx.Panel(self, -1, (0, 0), (500 , 300))self.panel.SetBackgroundColour('GRAY')self.sizer=wx.BoxSizer(wx.VERTICAL)self.sizer.Add(self.panel, 1, wx.EXPAND)self.SetSizer(self.sizer)self.statusbar = self.CreateStatusBar()self.statusbar.SetStatusText('Welcome to Isabelle')self.Centre()def OnExit(self, event):dlg = wx.MessageDialog(self, 'Are you sure to quit Isabelle?', 'Pleasewx.NO_DEFAULT | wx.ICON_QUESTION)if dlg.ShowModal() == wx.ID_YES:self.Close(True)def OnAbout(self, event):dlg = wx.MessageDialog(self, 'Isabelle\t\n' '2004\t', 'About',wx.OK | wx.ICON_INFORMATION)dlg.ShowModal()dlg.Destroy()def OnLaunchCommandOk(self, event):input = self.tc.GetValue()if input == '/bye':self.OnExit(self)elif input == '/about':self.OnAbout(self)elif input == '/bell':wx.Bell()else:self.statusbar.SetBackgroundColour('RED')self.statusbar.SetStatusText('Unknown Command')self.statusbar.Refresh()self.timer.Start(50)self.tc.Clear()def OnTimer(self, event):4 de 15 27/04/2008 1:09

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

Saved successfully!

Ooh no, something went wrong!