Hi, > > Message: 1 > Date: Thu, 28 Feb 2008 14:34:12 +0530 > From: kNish <[EMAIL PROTECTED]> > Subject: [python-win32] createtoolbar > To: python-win32@python.org > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" > > Hi, > > #!/usr/bin/python > > # panels.py > > import wx > > > class Panels(wx.Frame): > def __init__(self, parent, id, title): > wx.Frame.__init__(self, parent, id, title) > > hbox = wx.BoxSizer(wx.HORIZONTAL) > splitter = wx.SplitterWindow(self, -1) > > vbox1 = wx.BoxSizer(wx.VERTICAL) > panel1 = wx.Panel(splitter, -1) > panel11 = wx.Panel(panel1, -1, size=(-1, 40)) > panel11.SetBackgroundColour('#53728c') > st1 = wx.StaticText(panel11, -1, 'Feeds', (5, 5)) > st1.SetForegroundColour('WHITE') > > panel12 = wx.Panel(panel1, -1, style=wx.BORDER_SUNKEN) > panel12.SetBackgroundColour('WHITE') > > vbox1.Add(panel11, 0, wx.EXPAND) > vbox1.Add(panel12, 1, wx.EXPAND) > > panel1.SetSizer(vbox1) > > vbox2 = wx.BoxSizer(wx.VERTICAL) > panel2 = wx.Panel(splitter, -1) > panel21 = wx.Panel(panel2, -1, size=(-1, 40), > style=wx.NO_BORDER) > st2 = wx.StaticText(panel21, -1, 'Articles', (5, 5)) > st2.SetForegroundColour('WHITE') > > panel21.SetBackgroundColour('#53728c') > panel22 = wx.Panel(panel2, -1, style=wx.BORDER_RAISED) > > panel22.SetBackgroundColour('WHITE') > vbox2.Add(panel21, 0, wx.EXPAND) > vbox2.Add(panel22, 1, wx.EXPAND) > > panel2.SetSizer(vbox2) > > toolbar = self.CreateToolBar(self) > toolbar.AddLabelTool(1, 'Exit', > wx.Bitmap('icons/stock_exit.png')) > toolbar.Realize() > self.Bind(wx.EVT_TOOL, self.ExitApp, id=1) > > hbox.Add(splitter, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) > self.SetSizer(hbox) > self.CreateStatusBar() > splitter.SplitVertically(panel1, panel2) > self.Centre() > self.Show(True) > > > def ExitApp(self, event): > self.Close() > > > app = wx.App() > Panels(None, -1, 'Panels') > app.MainLoop() > > > createToolbar gives an error. (Look at the Attachment). How > may I get this to work successfully. > > BRgds, > > kNish
First of all, this is a wxPython question, NOT a PyWin32 question. You should be posting there: http://wxpython.org/maillist.php Secondly, you sent code that does not work. You need to change line 41 from toolbar = self.CreateToolBar(self) to toolbar = self.CreateToolBar() And if you use images in your code, you need to provide them. I added the following line right after the one above: ico = wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_TOOLBAR, (16,16)) and then changed toolbar.AddLabelTool(1, 'Exit', wx.Bitmap('icons/stock_exit.png')) to toolbar.AddLabelTool(1, 'Exit', ico) See http://www.wxpython.org/docs/api/wx.ArtProvider-class.html for more information on generic icons for wxPython. So the full code with changes if below: <code> import wx class Panels(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title) hbox = wx.BoxSizer(wx.HORIZONTAL) splitter = wx.SplitterWindow(self, -1) vbox1 = wx.BoxSizer(wx.VERTICAL) panel1 = wx.Panel(splitter, -1) panel11 = wx.Panel(panel1, -1, size=(-1, 40)) panel11.SetBackgroundColour('#53728c') st1 = wx.StaticText(panel11, -1, 'Feeds', (5, 5)) st1.SetForegroundColour('WHITE') panel12 = wx.Panel(panel1, -1, style=wx.BORDER_SUNKEN) panel12.SetBackgroundColour('WHITE') vbox1.Add(panel11, 0, wx.EXPAND) vbox1.Add(panel12, 1, wx.EXPAND) panel1.SetSizer(vbox1) vbox2 = wx.BoxSizer(wx.VERTICAL) panel2 = wx.Panel(splitter, -1) panel21 = wx.Panel(panel2, -1, size=(-1, 40), style=wx.NO_BORDER) st2 = wx.StaticText(panel21, -1, 'Articles', (5, 5)) st2.SetForegroundColour('WHITE') panel21.SetBackgroundColour('#53728c') panel22 = wx.Panel(panel2, -1, style=wx.BORDER_RAISED) panel22.SetBackgroundColour('WHITE') vbox2.Add(panel21, 0, wx.EXPAND) vbox2.Add(panel22, 1, wx.EXPAND) panel2.SetSizer(vbox2) toolbar = self.CreateToolBar() ico = wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_TOOLBAR, (16,16)) toolbar.AddLabelTool(1, 'Exit', ico) toolbar.Realize() self.Bind(wx.EVT_TOOL, self.ExitApp, id=1) hbox.Add(splitter, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) self.SetSizer(hbox) self.CreateStatusBar() splitter.SplitVertically(panel1, panel2) self.Centre() self.Show(True) def ExitApp(self, event): self.Close() app = wx.App(0) Panels(None, -1, 'Panels') app.MainLoop() </code> In the future, be sure to post to the wxPython group if you have a question about that GUI toolkit. If you need help with Mark Hammond's win32 modules, drop us a line. Mike _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32