Seite 1 von 1

Toolbar ID

Verfasst: Mittwoch 29. August 2007, 14:44
von tomate

Code: Alles auswählen

import wx

class SimpleToolbar(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(300, 200))

        toolbar = self.CreateToolBar()
        toolbar.AddLabelTool(wx.ID_EXIT, '', wx.Bitmap('../icons/exit.png'))
	toolbar.Realize()

        self.Bind(wx.EVT_TOOL, self.OnExit, id=wx.ID_EXIT)

        self.Centre()
        self.Show(True)

    def OnExit(self, event):
        self.Close()


app = wx.App()
SimpleToolbar(None, -1, 'simple toolbar')
app.MainLoop()
Ist der Name der IDs (wx.ID_EXIT) nicht frei wählbar? Gibt es da vorgeschriebene Bezeichner?

Re: Toolbar ID

Verfasst: Mittwoch 29. August 2007, 15:03
von gerold
tomate hat geschrieben:Ist der Name der IDs (wx.ID_EXIT) nicht frei wählbar? Gibt es da vorgeschriebene Bezeichner?
Hallo tomate!

Verzichte auf die IDs, dann brauchst du dir keine Gedanken darüber machen.:

Code: Alles auswählen

        toolbar = self.CreateToolBar()
        
        #exit_tool = toolbar.AddSimpleTool(-1, wx.Bitmap('../icons/exit.png'))
        exit_tool = toolbar.AddSimpleTool(-1, wx.ArtProvider_GetBitmap(wx.ART_QUIT))
        self.Bind(wx.EVT_TOOL, self.OnExit, exit_tool)
        
        toolbar.Realize()
mfg
Gerold
:-)

Verfasst: Mittwoch 29. August 2007, 15:04
von tomate
Danke
wx.ArtProvider_GetBitmap()
Gibt es irgendwo eine Übersicht, was mir damit noch zur Verfügung steht?