[Python.NET] Problem with toolbar

Thane thane at magna-capital.com
Thu Jan 8 18:21:23 EST 2004


I think there's a bug in the toolbar event handler.  Here's the relevant
code:
 
#-------------------------------------------------------
class KtIde(WinForms.Form):
    """A simple Integrated Development Environment for Python.NET
    from Kokopelli Technology."""
 
    def __init__(self):
        # a bunch of stuff...
        
        # Add a toolbar
        self.toolBar1 = WinForms.ToolBar()
        self.imageList1 = WinForms.ImageList(self.components)
        self.toolBarButton1 = WinForms.ToolBarButton()
        self.toolBar1.Buttons.Add(self.toolBarButton1)
        self.toolBar1.ImageList = self.imageList1
        self.toolBar1.Location = Point(0, 30)
        self.toolBar1.Name = "toolBar1"
        self.toolBar1.ShowToolTips = True
        self.toolBar1.Size = Size(632, 28)
        self.toolBar1.TabIndex = 0
        #
        # Image list
        #
        self.imageList1.ImageSize = Size(16, 16)
        self.imageList1.TransparentColor = Color.Transparent
        fname = "ARW01RT.ICO" 
        self.imageList1.Images.Add(Image.FromFile(fname))
        
        # toolBarButtons
        self.toolBarButton1.ImageIndex = 0
 
        ######################  PROBLEM  ########################
        self.toolBar1.ButtonClick += self.toolBar1_ButtonClick 
        # Or is it...?
        #self.toolBar1.ButtonClick +=
WinForms.ToolBarButtonClickEventHandler(self.toolBar1_ButtonClick)
        ##########################################################
 
        # more stuff....
 
    def toolBar1_ButtonClick(self, sender, args):
        '''The toolbar event handler'''
        MessageBox.Show(args.ToString())
        #~ if args.Button == self.toolBarButton1:
            #~ MessageBox.Show("Hey, it works!")
 
#-------------------------------------------------------
 
This bombs every time I press the toolbar button -- unhandled exception.
Message is:
************** Exception Text **************
Python.Runtime.PythonException: Exception of type
Python.Runtime.PythonException was thrown.
   at Python.Runtime.Dispatcher.Dispatch(ArrayList args)
   at
__System_Windows_Forms_ToolBarButtonClickEventHandlerDispatcher.Invoke(Objec
t , ToolBarButtonClickEventArgs )
   at System.Windows.Forms.ToolBar.OnButtonClick(ToolBarButtonClickEventArgs
e)
   at System.Windows.Forms.ToolBar.WmReflectCommand(Message& m)
   at System.Windows.Forms.ToolBar.WndProc(Message& m)
   at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)

 
Any clues?
 
Also, this is the most fun I've had programming in a LONG time.  MFC is out
the window.  Brian -- my hat is off to you.  Many thanks for your efforts.
 
Cheers,
 
--Thane
 
Thane Plummer
CEO Magna Capital
 
 
"La perfection est atteinte non quand il ne reste rien à ajouter, mais quand
il ne reste rien à enlever"
Antoine de St. Exupery from The Little Prince  (perfection is reached not
when there's nothing left to add, but when there's nothing left to remove)

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythondotnet/attachments/20040108/4f0a0fe2/attachment.html


More information about the PythonDotNet mailing list