wxpython 3 FindWindowById( some predifined id ).Destroy() problem

Hi,

I have written an app which uses many frames which were being destroyed by FindWindowById( id ).Destroy().
The app is about opening and closing relays for billiard tables.
So when a specific pool frame was open and the user opened another pool frame the second frame tried (try:) to self.FindWindowById( specific id ).Destroy()
the previous frame so that only one pool frame was open at the time.

This worked perfectly in 2.8.12.1 but now with wxpython 3.0.0 it does not. No error output is generated though

Also in a new app I am writing now I am getting :
wx._core.PyAssertionError: C++ assertion “ff_family != (0<<4)” failed at …\src\msw\font.cpp(650) in wxNativeFontInfo::SetFamily(): unknown wxFontFamily
error.

Was there any changes as far as wx.Font is concerned?

It also worked flawlessly in 2.8.12.1.

P.S. Does wxpython 3.0.0 support agw library?

Thanks in advance,
JohnD

Nothing is noted in the 3.x changes doc
“site-packages/wx-3.0-msw/docs”, but I think 3.x is a bit more
strict in checking things.
Can you show the your code.
Yes
Werner

···

Hi John,

  It is better to cover one problem per thread, much better for

future use of the list archive.

  On 09/03/2014 22:36, John D wrote:

Hi,

    I have written an app which uses many frames which were being

destroyed by FindWindowById( id ).Destroy().

    The app is about opening and closing relays for billiard tables.

    So when a specific pool frame was open and the user opened

another pool frame the second frame tried (try:) to
self.FindWindowById( specific id ).Destroy()

    the previous frame so that only one pool frame was open at the

time.

    This worked perfectly in 2.8.12.1 but now with wxpython 3.0.0 it

does not. No error output is generated though

    Also in a new app I am writing now I am getting :

     wx._core.PyAssertionError: C++ assertion "ff_family !=

(0<<4)" failed at …..\src\msw\font.cpp(650) in
wxNativeFontInfo::SetFamily(): unknown wxFontFamily

    error.



    Was there any changes as far as wx.Font is concerned?
    It also worked flawlessly in 2.8.12.1.



    P.S. Does wxpython 3.0.0 support agw library?
    Thanks in advance,

    JohnD

  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.

  For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).


Best regards**
Werner
**
The Wine Cellar Book
www.thewinecellarbook.com\en

Mit freundlichen Grüssen**
Werner
**
Das Weinkellerbuch
www.thewinecellarbook.com\de

Cordialement,
**Werner
**
Le Livre de Cave
www.thewinecellarbook.com\fr


-- Niderenweg 6
CH-9043 Trogen
Tel: +41 71 340 06 30
Mob: +41 76 374 81 07

Hi and thank you for the quick response

For example the piece of code below works perfect on wxpython 2.8.12.1 (python 2.7.6) and it produces an error on python 3.0.0:

import wx

class DemoFrame(wx.Frame):
def init(self):
wx.Frame.init(self, None, wx.ID_ANY, u"DION Entertainment Club",size=(160,200),pos=(0,0)) # ,style=wx.CLIP_CHILDREN
self.b = wx.Button(self, id=-1, label=u’Open’, pos=(10,10), size=(140, 40))
self.b.Bind(wx.EVT_BUTTON,self.show_other)

self.b2 =  wx.Button(self, id=-1, label=u'Close', pos=(10,70), size=(140, 40))
self.b2.Bind(wx.EVT_BUTTON,self.close_other)              
self.Show()

def show_other(self,evt):
f2 = wx.Frame(self,id=6666)
c = wx.Choice(f2,-1,choices=[‘red’,‘blue’,‘green’])
f2.Show()

def close_other(self,evt):
self.FindWindowById(6666).Destroy()

app = wx.PySimpleApp()
frame = DemoFrame()
app.MainLoop()

The error it produces is:
AttributeError: ‘NoneType’ object has no attribute ‘Destroy’

I am running it on windows 7 with wing-ide 101 as an IDE.

Am I doing something wrong here?

By the way I test it by installing and uninstalling each version of wxpython from the Control Panel (Programs and Features) of Windows.

Thanks again

Hi,

This works for me:

   def close_other(self,evt):
     #w = self.FindWindowById(6666)
     w = wx.FindWindowById(6666)
     if w:
       w.Destroy()

Note sure why the first one doesn't work.

Instead of PySimpleApp you should use just wx.App, the first one is going away in Phoenix.

Werner

John D wrote:

def close_other(self,evt):
self.FindWindowById(6666).Destroy()

The error it produces is:
AttributeError: 'NoneType' object has no attribute 'Destroy'

I am running it on windows 7 with wing-ide 101 as an IDE.

Am I doing something wrong here?

wx.Window.FindWindowById no longer includes top-level windows in the search, just those that are directly contained in the window. To search all windows in the application you can use wx.FindWindowById instead.

···

--
Robin Dunn
Software Craftsman

Hi Robin,

···

On 3/15/2014 5:53 AM, Robin Dunn wrote:

John D wrote:

def close_other(self,evt):
self.FindWindowById(6666).Destroy()

The error it produces is:
AttributeError: 'NoneType' object has no attribute 'Destroy'

I am running it on windows 7 with wing-ide 101 as an IDE.

Am I doing something wrong here?

wx.Window.FindWindowById no longer includes top-level windows in the search, just those that are directly contained in the window. To search all windows in the application you can use wx.FindWindowById instead.

But that isn't reflected in the doc, I think:
http://wxpython.org/Phoenix/docs/html/Window.html?highlight=findwindowbyid#Window.FindWindowById

Should I do a ticket for wxWidgets for that?

Werner