Crea una clase MyToolBar para reutilizarla en varios frames...
Código:
A la hora de usarla en un frame me da este errorclass MyToolBar(wx.ToolBar): def __init__(self, parent): wx.ToolBar.__init__(self, parent,-1, style=wx.TB_HORIZONTAL|wx.TB_3DBUTTONS|wx.TB_TEXT|wx.TB_HORZ_LAYOUT|wx.TB_HORZ_TEXT) self.AddLabelTool(1, "Agregar", wx.NullBitmap,wx.NullBitmap, wx.ITEM_NORMAL, "", "") self.AddLabelTool(2, "Modificar", wx.NullBitmap, wx.NullBitmap, wx.ITEM_NORMAL, "", "") self.AddLabelTool(3, "Guardar", wx.NullBitmap, wx.NullBitmap, wx.ITEM_NORMAL, "", "") self.AddLabelTool(4, "Cancelar", wx.NullBitmap, wx.NullBitmap, wx.ITEM_NORMAL, "", "") self.AddLabelTool(5, "Eliminar", wx.NullBitmap, wx.NullBitmap, wx.ITEM_NORMAL, "", "") self.AddSeparator() self.AddLabelTool(6, "Listar", wx.NullBitmap, wx.NullBitmap, wx.ITEM_NORMAL, "", "") self.AddLabelTool(7, "Elegir", wx.NullBitmap, wx.NullBitmap, wx.ITEM_NORMAL, "", "") self.SetToolBitmapSize((24, 24)) self.Realize()
Código:
El codigo del frame...Traceback (most recent call last): File "C:\Documents and Settings\podio\workspace\SMERP\src\form\frm_main.py", line 92, in Toolbar1_click f = form.frm_Articulos.frm_Articulos() File "C:\Documents and Settings\podio\workspace\SMERP\src\form\frm_Articulos.py", line 17, in __init__ self.toolbar = md.mdControles.MyToolBar(self) File "C:\Documents and Settings\podio\workspace\SMERP\src\md\mdControles.py", line 23, in __init__ self.Realize() File "C:\Python26\lib\site-packages\wx-2.8-msw-ansi\wx\_controls.py", line 3875, in Realize return _controls_.ToolBarBase_Realize(*args, **kwargs) wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed at ..\..\src\msw\tbar95.cpp(726) in wxToolBar::Realize(): invalid tool button bitmap
Código:
import wx import md.mdDB import md.mdControles class frm_Articulos(wx.Frame): def __init__(self, *args, **kwds): # begin wxGlade: frm_Articulos.__init__ kwds["style"] =wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, None,-1) self.panel_2 = wx.Panel(self, -1) self.notebook_1 = wx.Notebook(self, -1, style=0) self.list_ctrl_1 = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER) self.panel_1 = wx.Panel(self, -1, style=wx.DOUBLE_BORDER|wx.TAB_TRAVERSAL) self.notebook_1_pane_1 = wx.Panel(self.notebook_1, -1) self.bitmap_1 = wx.StaticBitmap(self.panel_2, -1, wx.Bitmap("C:\\Documents and Settings\\podio\\Escritorio\\PODIO\\podio.bmp", wx.BITMAP_TYPE_ANY)) self.toolbar = md.mdControles.MyToolBar(self) self.__set_properties() self.__do_layout() self.CargaRS() self.Show() # end wxGlade def __set_properties(self): # begin wxGlade: frm_Articulos.__set_properties self.SetTitle("ABM Articulos") self.list_ctrl_1.InsertColumn(1,"Cod") self.list_ctrl_1.InsertColumn(2,"Categoria") self.list_ctrl_1.InsertColumn(3,"Sub-Cat") self.list_ctrl_1.InsertColumn(4,"Descripcion") # end wxGlade def __do_layout(self): # begin wxGlade: frm_Articulos.__do_layout sizer_1 = wx.BoxSizer(wx.VERTICAL) sizer_2 = wx.BoxSizer(wx.VERTICAL) sizer_3 = wx.BoxSizer(wx.HORIZONTAL) sizer_5 = wx.BoxSizer(wx.HORIZONTAL) sizer_4 = wx.BoxSizer(wx.HORIZONTAL) sizer_4.Add(self.list_ctrl_1, 4, wx.EXPAND, 0) sizer_2.Add(sizer_4, 2, wx.EXPAND, 0) sizer_2.Add(self.toolbar, 1, wx.EXPAND, 0) self.notebook_1.AddPage(self.notebook_1_pane_1, "General") self.notebook_1.AddPage(self.notebook_1_pane_1, "Descripcion HTML") sizer_3.Add(self.notebook_1, 4, wx.EXPAND, 0) sizer_5.Add(self.bitmap_1, 0, 0, 0) self.panel_2.SetSizer(sizer_5) sizer_3.Add(self.panel_2, 1, wx.EXPAND, 0) sizer_2.Add(sizer_3, 2, wx.EXPAND, 0) sizer_1.Add(sizer_2, 2, wx.EXPAND, 0) self.SetSizer(sizer_1) sizer_1.Fit(self) self.Layout() self.Centre() # end wxGlade def CargaRS(self): sql = "Select * from Articulos" cn = md.mdDB.GestorBD() rs = cn.execute(sql) for registro in rs: i = 0 self.list_ctrl_1.InsertStringItem(i,registro[0]) self.list_ctrl_1.SetStringItem(i,3,registro[2]) i = i + 1
No entiendo porque da ese error bitmap no admitido, si no tiene ninguno...
saludos