PythonWin dynamic toolbar

Ilariu Raducan lale at fotonation.com
Mon Jul 7 08:40:07 EDT 2003


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





More information about the Python-list mailing list