#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    Python - Toolbar with enable/disable icons - wxGlade first and second bitmap


    Hello, where can I find a sample of simple toolbar with enable/disable icons?

    I can make a nice toolbar with wxGlade and also I have the image for each icon on enable and disable situation but I cant figure how to enable / disable the icons by code once the program is running.

    wxGlade have the option for "First bitmap" and "Second bitmap"

    I think is something like "If bmpDisabled is wx.NullBitmap, a shadowed version of the normal bitmap is created and used as the disabled image."


    where in theory Python it self make the shadowed version of the icon, but I dont have a sample to learn.

    Example of my code:
    #!/usr/bin/env python
    # -*- coding: iso-8859-15 -*-
    # generated by wxGlade 0.6.5 (standalone edition) on Tue Dec 11 21:54:42 2012

    import wx

    # begin wxGlade: extracode
    # end wxGlade


    class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
    # begin wxGlade: MyFrame.__init__
    kwds["style"] = wx.DEFAULT_FRAME_STYLE
    wx.Frame.__init__(self, *args, **kwds)

    # Tool Bar
    self.frame_1_toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.TB_TEXT)
    self.SetToolBar(self.frame_1_toolbar)
    self.frame_1_toolbar.AddLabelTool(1, "CUT", wx.Bitmap("editcut.png", wx.BITMAP_TYPE_ANY), wx.Bitmap("editcutapagado.png", wx.BITMAP_TYPE_ANY), wx.ITEM_NORMAL, "CUT", "")
    self.frame_1_toolbar.AddLabelTool(2, "EXIT", wx.Bitmap("exit.png", wx.BITMAP_TYPE_ANY), wx.Bitmap("exitaapagado.png", wx.BITMAP_TYPE_ANY), wx.ITEM_NORMAL, "EXIT", "")
    # Tool Bar end

    self.__set_properties()
    self.__do_layout()
    # end wxGlade

    def __set_properties(self):
    # begin wxGlade: MyFrame.__set_properties
    self.SetTitle("frame_1")
    self.frame_1_toolbar.Realize()
    # end wxGlade

    def __do_layout(self):
    # begin wxGlade: MyFrame.__do_layout
    sizer_1 = wx.BoxSizer(wx.VERTICAL)
    self.SetSizer(sizer_1)
    sizer_1.Fit(self)
    self.Layout()
    # end wxGlade

    # end of class MyFrame
    if __name__ == "__main__":
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    app.SetTopWindow(frame_1)
    frame_1.Maximize()
    frame_1.Show()
    app.MainLoop()

    So, how can I disable/enable this button?

    self.frame_1_toolbar.AddLabelTool(1, "CUT", wx.Bitmap("editcut.png", wx.BITMAP_TYPE_ANY), wx.Bitmap("editcutapagado.png", wx.BITMAP_TYPE_ANY), wx.ITEM_NORMAL, "CUT", "")

    thanks
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0
    No one?

IMN logo majestic logo threadwatch logo seochat tools logo