This may help someone ...
I have at last solved the Thaw-failure problems I recently experienced after upgrading Python from 2.5 to 2.7.6 and wxPython from 2.8.10.1 to beta 3.0.1.0. What a relief! I did so by replacing all direct calls to *Freeze()* and *Thaw()* with calls to this code, placed in a separate module:
*winWarmth = {}**
**
**def winWarmthLookup(win):**
** # Check to see if we have already frozen or**
** # thawed this window or any of its parents**
** w = win**
** handle = win.GetHandle()**
** level = 0**
** found = False**
** while not found:**
** if w is not None: break**
** handle = w.GetHandle()**
** found = handle in winWarmth**
** if not found:**
** w = w.GetParent()**
** level += 1**
** return w, handle, level, found**
**
**def Freeze( win, source ):**
** w, handle, level, found = winWarmthLookup(win)**
**
** if found and winWarmth[handle][2] == 'frozen':**
** print 'Window with handle %s (source %s) is already frozen!' % (handle, source)**
** utils.Beep('Freeze')**
** else:**
** win.Freeze()**
** winWarmth[win.GetHandle()] = [level, 'frozen', source]**
** print 'Freeze successful:'**
** for item in winWarmth.items(): print ' '*4, item**
**
**def Thaw( win, source ):**
** w, handle, level, found = winWarmthLookup(win)**
**
** if found and winWarmth[handle][1] == 'frozen':**
** print 'About to thaw window with handle %d (source %s)' % (handle, source)**
** w.Thaw()**
** winWarmth[handle][1] = 'thawed'**
** print 'Thaw successful:'**
** for item in winWarmth.items(): print ' '*4, item**
** else:**
** print '%s (referenced at %s) is not frozen!' % (win.GetName(), source)**
** utils.Beep('Thaw')**
*
The *source* argument I've found most useful is simply a string containing the calling-module name (or abbreviated name) and line number.
Oh, my *utils.Beep* routine is there just to call attention to any Freeze/Thaw problems, i.e., to get me to look at the console:
*def Beep( source='???' ):**
** import winsound**
** print 'Beep from %s!' % source**
** winsound.Beep(2000,20)*
I do hope this helps someone. It's certainly helped me!
If there's a tighter way to code any of the above, please let me know.
I don't know if traveling up the window tree in my *winWarmthLookup* routine was necessary. I coded it that way because I thought my problems might be parent/child problems, e.g., freezing a parent, then thawing one or more of its children, then trying to thaw the parent. This URL made me wonder: http://wxpython-users.1045709.n5.nabble.com/Thaw-without-matching-Freeze-td2361682.html , even though the bug reported there was reported as fixed ( wxTrac has been migrated to GitHub Issues - wxWidgets ).
Bob
P.S. Got a better name than "Warmth"?
On 3/31/2014 8:11 AM, Bob Klahn wrote:
As you all may have seen in the wxPython demo failure thread of the past two days, I'm using the January 4th 3.0.1.0 beta version of wxPython (available here: http://wxpython.kosoftworks.com/preview/20140104/ ), because the December 25th 3.0.0.0 production version caused the wxPython 3.0.0.0 demo to fail. I'm using wxPython with Python 2.7.6 on my Windows XP SP3 machine.
But now I'm seeing supposedly-impossible Thaw failures. Here's an example, where I'm using a simple Notebook:
* if frame.nb1.IsFrozen(): frame.nb1.Thaw()**
*
This traceback results:
*File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_core.py", line 10746, in Thaw**
** return _core_.Window_Thaw(*args, **kwargs)**
**wx._core.PyAssertionError: C++ assertion "m_freezeCount" failed at ..\..\src\common\wincmn.cpp(1257) in wxWindowBase::Thaw(): Thaw() without matching Freeze()**
*
Might this "impossible" result be occurring simply because I'm using a beta version of wxPython? Since I can't use version 3.0.0.0, should I be using August 31st's 2.9.5.0 version instead? (I recently upgraded from version 2.8.10.1.)
Bob
P.S. Just in case anyone might ask: I cannot produce a small, runnable example of this behavior.
No virus found in this message.
Checked by AVG - www.avg.com <http://www.avg.com>
Version: 2014.0.4355 / Virus Database: 3882/7366 - Release Date: 04/19/14
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com <mailto:wxpython-users+unsubscribe@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.