I don't know where to put quit.png. This result in errors. Is it put on SPE folder or somewhere in python? or Just in same directory as saved file?
I appreciate your help!
Steve

Code
import wx
class MyFrame(wx.Frame):
def __init__(self,parent,id,title):
wx.Frame.__init__(self,parent,id,title,size=(700,600))

toolbar=self.CreateToolBar()
toolbar.AddLabelTool(wx.ID_EXIT,'',wx.Bitmap('..\icons\quit.png'))

app=wx.App()
MyFrame(None, -1, 'Simple Toolbar')
app.MainLoop()

This might just help you ...

import wx

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

        toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER)
        # image file is in the same folder as the source code
        # otherwise give a full path name
        toolbar.AddSimpleTool(1, wx.Image('quit.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'quit', '')
        # add more toolbar images here ...
        toolbar.Realize()

app = wx.PySimpleApp()
frame = MyFrame(None, -1, 'Simple Toolbar')
frame.Show(True)
app.MainLoop()

This might just help you ...

import wx

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

        toolbar = wx.ToolBar(self, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER)
        # image file is in the same folder as the source code
        # otherwise give a full path name
        toolbar.AddSimpleTool(1, wx.Image('quit.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap(), 'quit', '')
        # add more toolbar images here ...
        toolbar.Realize()

app = wx.PySimpleApp()
frame = MyFrame(None, -1, 'Simple Toolbar')
frame.Show(True)
app.MainLoop()

Script terminates!
When I remove line 10 then it works but then No icon. Cant it be done in another way??
Help please
Steve

Read line 8 and 9, you got to have the properly named icon image file for this to work.

Read line 8 and 9, you got to have the properly named icon image file for this to work.

OOooops
I get error

File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 3336, in ConvertToBitmap
return _core_.Image_ConvertToBitmap(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "image.Ok()" failed at ..\..\src\msw\bitmap.cpp(799) in wxBitmap::CreateFromImage(): invalid image
Script terminated.

Any help
Steve

Any help please. I want to make toolbar with Icon. I have tried above methods nothing seemed to work. I also ponder on How to Connect events in python and Its modules(like wx python) and then Compile them to exe file.

I also have to put question: Is there way to write DLL in python as is in VB?

Can I compile python DLLs and EXEs to work as VB is?

Thanks a lot and God Bless you for your help!!

Steve

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.