[Q] wxPython from newbie

Young-Jin Lee ylee12 at uiuc.edu
Mon Nov 12 23:41:59 EST 2001


Hi, all.
I have a question on AddSimpleTool() method of tool bar. I was trying to
create a simple application with a tool bar.
I was reading wxToolBar.py and trying to copy and paste the code.
While I was reading the code, I had problem understanding the following
code.
toolBar = self.CreateToolBar( wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT )

I checked the online help of wxPython (wxWindows) and I got the following
information.
virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL,
wxWindowID id = -1, const wxString& name = "toolBar")
My problem is that I couldn't know the exact return type of CreateToolBar()
method because it is a virtual function.
But I decided to go further on wxToolBar.py.

Then I got another problem in the following code.
toolBar.AddSimpleTool( 10, images.getNewBitmap(), "New", "Long help for
'New'" )
I looked up the online help, but I couldn't find any method named
AddSimpleTool in wxToolBar and I found nothing when I tried to search
"AddSimpleTool" in the online help.
In addition to this problem, I couldn't understand getNewBitmap() method in
images.py (it is also in the demo directory of wxPython distribution.)

def getNewBitmap():
    return wxBitmapFromXPMData(getNewData())

def getNewData():
    return cPickle.loads(zlib.decompress(
'x\332\323\310)0\344\012V74S04U0V0T\347J\014V\327SHVp\312IL\316\006\363"\200
\
<e70\000\363\025\200|\277\374\274T(\007\025\300\004\365\240\000U0\002\014 \
\242\350\202\021z\330T\202\324\242\011\202\304\007\267 \002 \004\321CI\017\
\000\303\177S\022' ))

getNewBitmap() method of images.py calls getNewData() method. I guess this
method tried to read a image file for tool bar icon. But I don't understand
why we should use this kind of method. I expected there is a method whose
input parameter is a image file name and it would return the pointer (or
reference or whatever) of it. Is this the only way to use an image for a
tool bar icon? Is there more easy example of using tool bar in the
application?

Thanks for reading long question.
I hope to get an answer. Thanks in advance.

YJ






More information about the Python-list mailing list