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.

Advanced widgetshttp://www.zetcode.com/wxpython/advanced/hbox.Add(close, 0)header.SetSizer(hbox)vbox2.Add(header, 0, wx.EXPAND)help = html.HtmlWindow(self.panelRight, -1, style=wx.NO_BORDER)help.LoadPage('help.html')vbox2.Add(help, 1, wx.EXPAND)self.panelRight.SetSizer(vbox2)self.panelLeft.SetFocus()self.splitter.SplitVertically(self.panelLeft, self.panelRight)self.splitter.Unsplit()self.Bind(wx.EVT_BUTTON, self.CloseHelp, id=close.GetId())self.Bind(wx.EVT_TOOL, self.OnClose, id=1)self.Bind(wx.EVT_TOOL, self.OnHelp, id=2)self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressed)self.CreateStatusBar()self.Centre()self.Show(True)def OnClose(self, event):self.Close()def OnHelp(self, event):self.splitter.SplitVertically(self.panelLeft, self.panelRight)self.panelLeft.SetFocus()def CloseHelp(self, event):self.splitter.Unsplit()self.panelLeft.SetFocus()def OnKeyPressed(self, event):keycode = event.GetKeyCode()if keycode == wx.WXK_F1:self.splitter.SplitVertically(self.panelLeft, self.panelRight)self.panelLeft.SetFocus()app = wx.App()HelpWindow(None, -1, 'HelpWindow')app.MainLoop()<strong>The</strong> help window is hidden in the beginning. We can show it by clicking onthe help button on the toolbar or by pressing F1. <strong>The</strong> help window appearson the right side of the application. To hide the help window, we click on theclose button.self.splitter.SplitVertically(self.panelLeft, self.panelRight)self.splitter.Unsplit()We create left a right panels and split them vertically. After that, we call theUnsplit() method. By default the method hides the right or bottom panes.We divide the right panel into two parts. <strong>The</strong> header and the body of thepanel. <strong>The</strong> header is an adjusted wx.Panel. <strong>The</strong> header consists of a statictext and a bitmap button. We put wx.html.Window into the body of thepanel.7 de 21 27/04/2008 1:05

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

Saved successfully!

Ooh no, something went wrong!