<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>Glad 
you're enjoying it :)</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>What 
you're seeing is almost always due to an exception being raised in the 
</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>Python 
callback (which has nowhere good to go in a windows app - need to 
</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>think 
about what to do there).</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>The 
first thing to try is replacing the body of your callback with 
just</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>'pass' 
or 'return'. Now, if you can click the thing that calls it w/o getting 
</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>an 
error, you've verified that theres some prob with the Python 
code.</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>If so, 
'the debugger is your friend', as Jim always tells me :) Put a 
</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>&nbsp; 
import pdb</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>&nbsp; 
pdb.set_trace()</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>...at 
the top of the callback method code and go from there.</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>Given 
the one-liner in your example, the only thing I can think of is 
</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>if 
MessageBox hasn't been defined as a name (maybe you need to </FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>use 
the fully-qualified name or import that name explicitly?)</FONT></SPAN></DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=522152700-09012004><FONT face=Arial color=#0000ff size=2>Hope 
this helps,</FONT></SPAN></DIV>
<DIV>&nbsp;</DIV><BR>
<P><FONT size=2>Brian Lloyd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
brian@zope.com<BR>V.P. Engineering&nbsp;&nbsp; 
540.361.1716&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>Zope 
Corporation&nbsp;&nbsp; <A href="http://www.zope.com/" 
target=_blank>http://www.zope.com</A><BR></FONT></P>
<BLOCKQUOTE dir=ltr 
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> 
  pythondotnet-bounces@python.org [mailto:pythondotnet-bounces@python.org]<B>On 
  Behalf Of </B>Thane<BR><B>Sent:</B> Thursday, January 08, 2004 6:21 
  PM<BR><B>To:</B> pythondotnet@python.org<BR><B>Subject:</B> [Python.NET] 
  Problem with toolbar<BR><BR></FONT></DIV>
  <DIV><SPAN class=579221023-08012004><FONT face=Arial size=2>I think there's a 
  bug in the toolbar event handler.&nbsp; Here's the relevant 
  code:</FONT></SPAN></DIV>
  <DIV><SPAN class=579221023-08012004><FONT face=Arial 
  size=2></FONT></SPAN>&nbsp;</DIV>
  <DIV><SPAN class=579221023-08012004><FONT face=Arial 
  size=2>#-------------------------------------------------------</FONT></SPAN></DIV>
  <DIV><SPAN class=579221023-08012004><FONT face=Arial size=2>class 
  KtIde(WinForms.Form):<BR>&nbsp;&nbsp;&nbsp; """A simple Integrated Development 
  Environment for Python.NET<BR>&nbsp;&nbsp;&nbsp; from Kokopelli 
  Technology."""</FONT></SPAN></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><SPAN class=579221023-08012004><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; 
  def __init__(self):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # a bunch of 
  stuff...</FONT></SPAN></DIV><SPAN class=579221023-08012004>
  <DIV><FONT face=Arial 
  size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  # Add a toolbar<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.toolBar1 = 
  WinForms.ToolBar()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  self.imageList1 = 
  WinForms.ImageList(self.components)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  self.toolBarButton1 = 
  WinForms.ToolBarButton()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  self.toolBar1.Buttons.Add(self.toolBarButton1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  self.toolBar1.ImageList = 
  self.imageList1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  self.toolBar1.Location = Point(0, 
  30)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.toolBar1.Name = 
  "toolBar1"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  self.toolBar1.ShowToolTips = 
  True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.toolBar1.Size = 
  Size(632, 28)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  self.toolBar1.TabIndex = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  #<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Image 
  list<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  #<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.imageList1.ImageSize = 
  Size(16, 16)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  self.imageList1.TransparentColor = 
  Color.Transparent<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fname = 
  "ARW01RT.ICO"&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  self.imageList1.Images.Add(Image.FromFile(fname))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  # toolBarButtons<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  self.toolBarButton1.ImageIndex = 0</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT size=+0><SPAN class=579221023-08012004><FONT face=Arial 
  size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ######################&nbsp; 
  PROBLEM&nbsp; ########################</FONT></SPAN></DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  self.toolBar1.ButtonClick += self.toolBar1_ButtonClick </FONT></FONT></DIV>
  <DIV><FONT face=Arial><FONT size=2><SPAN 
  class=579221023-08012004>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  </SPAN>#<SPAN class=579221023-08012004> Or is 
it...?</SPAN></FONT></FONT></DIV>
  <DIV><FONT size=+0><SPAN class=579221023-08012004></SPAN><FONT 
  face=Arial><FONT size=2><SPAN 
  class=579221023-08012004>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  #self.toolBar1.ButtonClick += 
  </SPAN>WinForms.ToolBarButtonClickEventHandler(self.toolBar1_ButtonClick)</FONT></FONT></FONT></DIV>
  <DIV><SPAN class=579221023-08012004><FONT face=Arial 
  size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  ##########################################################</FONT></SPAN></DIV>
  <DIV><FONT size=+0><FONT face=Arial><FONT 
  size=2></FONT></FONT></FONT>&nbsp;</DIV>
  <DIV><FONT size=+0><FONT size=+0><SPAN class=579221023-08012004><FONT 
  face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # more 
  stuff....</FONT></SPAN></FONT></FONT></DIV>
  <DIV><FONT size=+0><FONT size=+0><SPAN class=579221023-08012004><FONT 
  face=Arial size=2></FONT></SPAN></FONT></FONT>&nbsp;</DIV>
  <DIV><FONT size=+0><FONT size=+0><SPAN class=579221023-08012004><FONT 
  face=Arial size=2>&nbsp;&nbsp;&nbsp; def toolBar1_ButtonClick(self, sender, 
  args):</FONT></SPAN></FONT></FONT></DIV>
  <DIV><FONT size=+0><FONT size=+0><SPAN class=579221023-08012004><FONT 
  face=Arial size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'''The 
  toolbar event handler'''<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  MessageBox.Show(args.ToString())<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  #~ if args.Button == 
  self.toolBarButton1:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  #~ MessageBox.Show("Hey, it works!")</FONT></SPAN></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2><SPAN class=579221023-08012004><FONT face=Arial 
  size=2>#-------------------------------------------------------</FONT></SPAN></FONT></DIV>
  <DIV><FONT face=Arial size=2><SPAN 
  class=579221023-08012004></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2><SPAN class=579221023-08012004>This bombs every 
  time I press the toolbar button -- unhandled exception.&nbsp; Message 
  is:</SPAN></FONT></DIV>
  <DIV><FONT face=Arial size=2><SPAN class=579221023-08012004>************** 
  Exception Text **************<BR>Python.Runtime.PythonException: Exception of 
  type Python.Runtime.PythonException was thrown.<BR>&nbsp;&nbsp; at 
  Python.Runtime.Dispatcher.Dispatch(ArrayList args)<BR>&nbsp;&nbsp; at 
  __System_Windows_Forms_ToolBarButtonClickEventHandlerDispatcher.Invoke(Object 
  , ToolBarButtonClickEventArgs )<BR>&nbsp;&nbsp; at 
  System.Windows.Forms.ToolBar.OnButtonClick(ToolBarButtonClickEventArgs 
  e)<BR>&nbsp;&nbsp; at 
  System.Windows.Forms.ToolBar.WmReflectCommand(Message&amp; m)<BR>&nbsp;&nbsp; 
  at System.Windows.Forms.ToolBar.WndProc(Message&amp; m)<BR>&nbsp;&nbsp; at 
  System.Windows.Forms.ControlNativeWindow.OnMessage(Message&amp; 
  m)<BR>&nbsp;&nbsp; at 
  System.Windows.Forms.ControlNativeWindow.WndProc(Message&amp; 
  m)<BR>&nbsp;&nbsp; at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, 
  Int32 msg, IntPtr wparam, IntPtr lparam)<BR></SPAN></FONT></DIV>
  <DIV><FONT face=Arial size=2><SPAN 
  class=579221023-08012004></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2><SPAN class=579221023-08012004>Any 
  clues?</SPAN></FONT></DIV>
  <DIV><FONT face=Arial size=2><SPAN 
  class=579221023-08012004></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2><SPAN class=579221023-08012004>Also, this is the 
  most fun I've had programming in a LONG time.&nbsp; MFC is out the 
  window.&nbsp; Brian -- my hat is off to you.&nbsp; Many thanks for your 
  efforts.</SPAN></FONT></DIV>
  <DIV><FONT face=Arial size=2><SPAN 
  class=579221023-08012004></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2><SPAN 
  class=579221023-08012004>Cheers,</SPAN></FONT></DIV>
  <DIV><FONT face=Arial size=2><SPAN 
  class=579221023-08012004></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2><SPAN 
  class=579221023-08012004>--Thane</SPAN></FONT></DIV>
  <DIV><FONT face=Arial size=2><SPAN 
  class=579221023-08012004></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2><SPAN class=579221023-08012004>Thane 
  Plummer</SPAN></FONT></DIV>
  <DIV><FONT face=Arial size=2><SPAN class=579221023-08012004>CEO Magna 
  Capital</DIV></SPAN></FONT>
  <DIV><FONT face=Arial size=2></FONT></FONT></FONT></SPAN>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV align=left><FONT face=Georgia>"La perfection est atteinte non quand il ne 
  reste rien à ajouter, mais quand il ne reste rien à enlever"</FONT></DIV>
  <DIV align=left><FONT face=Georgia>Antoine de St. Exupery from <I>The Little 
  Prince</I>&nbsp; (perfection is reached not when there's nothing left to add, 
  but when there's nothing left to remove)</FONT><BR></DIV>
  <DIV>&nbsp;</DIV></BLOCKQUOTE></BODY></HTML>