Hi, I try create a toolbar with ArtProvider.GetBitmap with own images for example:
bmp = wx.Bitmap(wx.Image(“images/text.png”, wx.BITMAP_TYPE_PNG))
self.img_text = wx.ArtProvider.GetBitmap(bmp, wx.ART_TOOLBAR, (16, 16))
self.AddLabelTool(ID_TEXT, “Text”, self.img_text, wx.NullBitmap, wx.ITEM_NORMAL, “”, “”)
and sent
gdi.Bitmap_swiginit(self,gdi.new_Bitmap(*args, **kwargs))
TypeError: String or Unicode type required
You can use external images or just the system with artprovider?
···
–
SIN ETIQUETAS.[ PUNTO ]
http://hi.im/jyr
http://www.opentumblr.com
Hi,
You can use external images or just the system with artprovider?
Try this:
class MyArtProvider(wx.ArtProvider):
def CreateBitmap(self, artId, artClient, size):
# The first time the ArtProvider is asked for a certain bitmap
it creates it,
# The next time it will reuse it.
# NB: size and artClient are ignored, you may want to fix that.
return wx.Bitmap("images/%s.png"%artId, wx.BITMAP_TYPE_PNG)
wx.ArtProvider.Push(MyArtProvider())
...
bitmap = wx.ArtProvider.GetBitmap('text', wx.ART_TOOLBAR, (16, 16))
self.AddLabelTool(ID_TEXT, "Text", bitmap, wx.NullBitmap,
wx.ITEM_NORMAL, "", "")
Cheers, Frank
···
2009/10/15 Jair Gaxiola <jyr.gaxiola@gmail.com>:
So I had it, but when I test on Linux and Windows with a different resolution, the toolbar is not equal. Works me with ArtProvider.
···
On Thu, Oct 15, 2009 at 7:52 PM, Mike Driscoll mike@pythonlibrary.org wrote:
Hi Jair,
On Thu, Oct 15, 2009 at 3:16 PM, Frank Niessink frank@niessink.com wrote:
Hi,
2009/10/15 Jair Gaxiola jyr.gaxiola@gmail.com:
You can use external images or just the system with artprovider?
Try this:
class MyArtProvider(wx.ArtProvider):
def CreateBitmap(self, artId, artClient, size):
# The first time the ArtProvider is asked for a certain bitmap
it creates it,
# The next time it will reuse it.
# NB: size and artClient are ignored, you may want to fix that.
return wx.Bitmap("images/%s.png"%artId, wx.BITMAP_TYPE_PNG)
wx.ArtProvider.Push(MyArtProvider())
…
bitmap = wx.ArtProvider.GetBitmap(‘text’, wx.ART_TOOLBAR, (16, 16))
self.AddLabelTool(ID_TEXT, “Text”, bitmap, wx.NullBitmap,
wx.ITEM_NORMAL, “”, “”)
Cheers, Frank
You don’t even need the ArtProvider. You can just do something like this:
newIcon = wx.BitmapFromImage(wx.Image(“myToolbarPicture.png”))
newTool = self.toolbar.AddLabelTool(wx.ID_ANY, “New”, newIcon)
–
SIN ETIQUETAS.[ PUNTO ]
http://hi.im/jyr
http://www.opentumblr.com