PythonWin dynamic toolbar

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ilariu Raducan

    PythonWin dynamic toolbar

    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.SteBitma pSize(32,32)

    What is wrong with it?

    Thank you,
    Lale


    def OnCreateClient( self,context,ob j):
    window.MDIChild Wnd.OnCreateCli ent(self,contex t,obj)
    parent = self
    style = win32con.WS_CHI LD | win32con.WS_VIS IBLE |
    afxres.CBRS_SIZ E_DYNAMIC | afxres.CBRS_TOP | \
    afxres.CBRS_TOO LTIPS | afxres.CBRS_FLY BY
    self.toolbar = tb = win32ui.CreateT oolBar (parent, style)
    tbctrl = tb.GetToolBarCt rl()
    tbctrl.SetBitma pSize(32,32)
    bmp = win32ui.CreateB itmap()
    bmp.LoadBitmapF ile(open('impor timages.bmp','r '))
    bmpIndex = tbctrl.AddBitma p(1,bmp)
    tbctrl.AddStrin gs('rect\0point \0poligon\0')
    tbutton = tbctrl.TBUTTON
    tbutton[0]=(bmpIndex,868, win32con.TBSTAT E_ENABLED,
    win32con.TBSTYL E_BUTTON,None,0 )
    tbctrl.AddButto ns(1,tbutton)
    tb.EnableDockin g(afxres.CBRS_A LIGN_ANY)
    tb.SetWindowTex t("Test")
    parent.EnableDo cking(afxres.CB RS_ALIGN_ANY)
    parent.DockCont rolBar(tb)
    print tbctrl.GetButto nCount()
    return 1

Working...