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.

Application skeletons in <strong>wxPython</strong>http://www.zetcode.com/wxpython/skeletons/bookmark2 = wx.BitmapButton(toolbar2, -1, wx.Bitmap('icons/books.png'),style=wx.NO_BORDER)bookmark3 = wx.BitmapButton(toolbar2, -1, wx.Bitmap('icons/sound.png'),style=wx.NO_BORDER)hbox2.Add(bookmark1, flag=wx.RIGHT, border=5)hbox2.Add(bookmark2, flag=wx.RIGHT, border=5)hbox2.Add(bookmark3)toolbar2.SetSizer(hbox2)vbox.Add(toolbar2, 0, wx.EXPAND)line = wx.StaticLine(panel)vbox.Add(line, 0, wx.EXPAND)panel.SetSizer(vbox)self.CreateStatusBar()self.Centre()self.Show(True)app = wx.App(0)Browser(None, -1, 'Browser')app.MainLoop()<strong>The</strong> question was, how to create a sizeable combo box, that is used inboth Firefox and Opera? We cannot use a wx.Toolbar. It is not possibleto create such a functionality with wx.Toolbar. Confirmed with RobinDunn. So we must do a workaround.toolbar1 = wx.Panel(panel, -1, size=(-1, 40))<strong>The</strong> trick is simple. We create a plain wx.Panel.hbox1 = wx.BoxSizer(wx.HORIZONTAL)...hbox1.Add(back)hbox1.Add(forward)hbox1.Add(refresh)We create a horizontal sizer and add all necessary buttons.hbox1.Add(address, 1, wx.TOP, 4)<strong>The</strong>n we add the combo box to the sizer. This kind of combo box isusually called an address bar. Notice, that it is the only widget, that hasthe proportion set to 1. This was necessary to make it resizable.<strong>The</strong> second toolbar was created in a similar way. <strong>The</strong> toolbars areseparated by a line. First I thought, it was some kind of a panel border.I tested all possible borders, but it wasn't quite what I expected.line = wx.StaticLine(panel)<strong>The</strong>n I suddently got it. It is a simple static line!Sometimes, we must create a solution, for which we don't have a10 de 11 27/04/2008 1:07

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

Saved successfully!

Ooh no, something went wrong!