PythonWin dynamic toolbar

I

Ilariu Raducan

Hi All,
I'm trying to create a dynamic toolbar.
This function tries to create the toolbar and add a button to it.
It craches at tbctrl.SteBitmapSize(32,32)

What is wrong with it?

Thank you,
Lale


def OnCreateClient(self,context,obj):
window.MDIChildWnd.OnCreateClient(self,context,obj)
parent = self
style = win32con.WS_CHILD | win32con.WS_VISIBLE |
afxres.CBRS_SIZE_DYNAMIC | afxres.CBRS_TOP | \
afxres.CBRS_TOOLTIPS | afxres.CBRS_FLYBY
self.toolbar = tb = win32ui.CreateToolBar (parent, style)
tbctrl = tb.GetToolBarCtrl()
tbctrl.SetBitmapSize(32,32)
bmp = win32ui.CreateBitmap()
bmp.LoadBitmapFile(open('importimages.bmp','r'))
bmpIndex = tbctrl.AddBitmap(1,bmp)
tbctrl.AddStrings('rect\0point\0poligon\0')
tbutton = tbctrl.TBUTTON
tbutton[0]=(bmpIndex,868,win32con.TBSTATE_ENABLED,
win32con.TBSTYLE_BUTTON,None,0)
tbctrl.AddButtons(1,tbutton)
tb.EnableDocking(afxres.CBRS_ALIGN_ANY)
tb.SetWindowText("Test")
parent.EnableDocking(afxres.CBRS_ALIGN_ANY)
parent.DockControlBar(tb)
print tbctrl.GetButtonCount()
return 1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top