Tooltips conflicting with win32ui module

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Tooltips conflicting with win32ui module

Michał Bałamut
Hi,
I have Python 2.7.2 (x86), wxPython 2.9.2, and Windows 7 x64.
When I run the attached module and then close the main window, the Python process hangs (i.e. console stays on screen).
There are 2 ways to fix it:
1. Remove the line:
import win32ui
In this example it's of course redundant, but I need it in my apps,
2. Remove the line:
combo.ToolTipString = 'tip'

So it seems that setting a tooltip on a control somehow conflicts with the win32ui module which prevents wxPython from unloading properly.
I'd be grateful for any ideas.
--
regards,
MB

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en

test.py (590 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Tooltips conflicting with win32ui module

Mike Driscoll
Have you tried calling the SetToolTipString() method of the ComboBox control instead? Not sure if that will make a difference, but worth a try.

-------------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Tooltips conflicting with win32ui module

Michał Bałamut
> Have you tried calling the SetToolTipString() method of the ComboBox control
> instead? Not sure if that will make a difference, but worth a try.

Unfortunately it didn't help.
--
regards,
MB

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Tooltips conflicting with win32ui module

Robin Dunn
In reply to this post by Mike Driscoll
On 10/7/11 1:34 PM, Mike Driscoll wrote:
> Have you tried calling theSetToolTipString() method of the ComboBox
> control instead? Not sure if that will make a difference, but worth a try.
>

ToolTipString is a property that calls SetToolTipString on assignment,
so there is no actual difference between them besides syntax.

--
Robin Dunn
Software Craftsman
http://wxPython.org

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Tooltips conflicting with win32ui module

Robin Dunn
In reply to this post by Michał Bałamut
On 10/7/11 1:07 PM, Michał Bałamut wrote:

> Hi,
> I have Python 2.7.2 (x86), wxPython 2.9.2, and Windows 7 x64.
> When I run the attached module and then close the main window, the Python process hangs (i.e. console stays on screen).
> There are 2 ways to fix it:
> 1. Remove the line:
> import win32ui
> In this example it's of course redundant, but I need it in my apps,
> 2. Remove the line:
> combo.ToolTipString = 'tip'
>
> So it seems that setting a tooltip on a control somehow conflicts with the win32ui module which prevents wxPython from unloading properly.
> I'd be grateful for any ideas.

This has been reported before, but at the time I was unable to make a
debug build of PyWin32 which is what will be needed to really dig into
this problem and figure it out.  The MainLoop is exiting as expected and
it hangs after that, so my theory is that win32ui is doing something
like installing an atexit function that is then waiting for some message
or some resource that wxMSW creates to service the tooltips to be freed.

You can force an exit by adding a call to wx.Exit() after MainLoop.

--
Robin Dunn
Software Craftsman
http://wxPython.org

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: Tooltips conflicting with win32ui module

Dietmar Schwertberger-2
Am 08.10.2011 06:35, schrieb Robin Dunn:
> This has been reported before, but at the time I was unable to make a
> debug build of PyWin32 which is what will be needed to really dig into
> this problem and figure it out. The MainLoop is exiting as expected and
> it hangs after that, so my theory is that win32ui is doing something
> like installing an atexit function that is then waiting for some message
> or some resource that wxMSW creates to service the tooltips to be freed.
>
> You can force an exit by adding a call to wx.Exit() after MainLoop.

For reference: in May I did also post this problem on the Python-win32
mailing list: http://code.activestate.com/lists/python-win32/11304/


Strange enough, for me the the original poster's script is exiting fine
without wx.Exit()...
(On Win 7, Python 2.7 and wxPython 2.8.12.0)


On my applications, the wx.Exit() workaround is working most of the
time, but not when there was an unhandled exception inside the mainloop
(e.g. in the built-in shell window).

When I tried to reproduce this by modifying the py shell example code,
I ended with the code below.
This code does not exit.
If I omit the following part, then everything is working as before
(i.e. hangs if I'm importing win32ui but don't call wx.Exit()):
         import sys
         sys.application = self
But then, when I have an exception in the shell window (e.g. by
entering 1/0), again it will hang at exit.

So I would assume that it's a problem with references.
The unhandled exception may also create a reference in a way similar to
sys.application = self .


Regards,

Dietmar


import wx
import wx.py

class App(wx.App):
     def OnInit(self):
         wx.InitAllImageHandlers()
         locals = {'__app__': 'PyShell Standalone Application'}
         self.shellFrame = wx.py.shell.ShellFrame(locals=locals)
         self.shellFrame.SetSize((750, 525))
         self.shellFrame.Show(True)
         self.SetTopWindow(self.shellFrame)
         self.shellFrame.shell.SetFocus()
         # Add the application object to the sys module's namespace.
         # This allows a shell user to do:
         # >>> import sys
         # >>> sys.application.whatever
         import sys
         sys.application = self
         return True


if __name__ == '__main__':
     import win32ui
     app = App(0)
     app.MainLoop()
     del app
     wx.Exit()

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en