FindWindow question

Hello (again),

import wx
import wx.stc

class MyFrame(wx.Frame):
  def __init__(self, parent, id, title):
    wx.Frame.__init__(self, parent, id, title, wx.Point(0, 0), wx.Size(800, 600),
      wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX | wx.THICK_FRAME | wx.RESIZE_BORDER)

class DrApp(wx.App):
  def OnInit(self):
    frame = MyFrame(None, 101, "MyFrame")
    frame.Show(True)
    print frame.FindWindowById(101)
    print frame.FindWindowByName("MyFrame")
    self.SetTopWindow(frame)
    return True
  
if __name__ == '__main__':
  app = DrApp(0)
  app.MainLoop()

the output is:

<__main__.MyFrame; proxy of C++ wxFrame instance at _e8ed8c00_p_wxFrame>
None

My question:
Why do the second function FindWindowByName return None?

···

--
Franz Steinhäusler

DrPython (Project Developer)
http://drpython.sourceforge.net/
http://sourceforge.net/projects/drpython/

Because 'MyFrame' is the window's *title*, not its name. See the 'name'
argument to wx.Window. What you are looking for is FindWindowByLabel.

···

On Fri, 2004-09-17 at 21:21 +0200, Franz Steinhäusler wrote:

Hello (again),

import wx
import wx.stc

class MyFrame(wx.Frame):
  def __init__(self, parent, id, title):
    wx.Frame.__init__(self, parent, id, title, wx.Point(0, 0), wx.Size(800, 600),
      wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX | wx.THICK_FRAME | wx.RESIZE_BORDER)

class DrApp(wx.App):
  def OnInit(self):
    frame = MyFrame(None, 101, "MyFrame")
    frame.Show(True)
    print frame.FindWindowById(101)
    print frame.FindWindowByName("MyFrame")
    self.SetTopWindow(frame)
    return True
  
if __name__ == '__main__':
  app = DrApp(0)
  app.MainLoop()

the output is:

<__main__.MyFrame; proxy of C++ wxFrame instance at _e8ed8c00_p_wxFrame>
None

My question:
Why do the second function FindWindowByName return None?

--
Cliff Wells <clifford.wells@comcast.net>

Hello (again),

import wx
import wx.stc

class MyFrame(wx.Frame):
  def __init__(self, parent, id, title):
    wx.Frame.__init__(self, parent, id, title, wx.Point(0, 0),
wx.Size(800, 600),
      wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX | wx.THICK_FRAME |
wx.RESIZE_BORDER)

class DrApp(wx.App):
  def OnInit(self):
    frame = MyFrame(None, 101, "MyFrame")
    frame.Show(True)
    print frame.FindWindowById(101)
    print frame.FindWindowByName("MyFrame")
    self.SetTopWindow(frame)
    return True
  
if __name__ == '__main__':
  app = DrApp(0)
  app.MainLoop()

the output is:

<__main__.MyFrame; proxy of C++ wxFrame instance at
_e8ed8c00_p_wxFrame>
None

My question:
Why do the second function FindWindowByName return None?

"MyFrame" is the *title* of your frame, not its *name*. If you want
to use names you must include a 'name' keyword parameter.

    def OnInit(self):
        frame = MyFrame(None, 101, "MyFrame", name='MyFrame')

Donnal Walter
Arkansas Children's Hospital

···

--- Franz Steinh�usler <franz.steinhaeusler@utanet.at> wrote:

Hello (again),

import wx
import wx.stc

class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
  wx.Frame.__init__(self, parent, id, title, wx.Point(0, 0), wx.Size(800, 600),
    wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX | wx.THICK_FRAME | wx.RESIZE_BORDER)

class DrApp(wx.App):
def OnInit(self):
  frame = MyFrame(None, 101, "MyFrame")
  frame.Show(True)
  print frame.FindWindowById(101)
  print frame.FindWindowByName("MyFrame")
  self.SetTopWindow(frame)
  return True

if __name__ == '__main__':
app = DrApp(0)
app.MainLoop()

the output is:

<__main__.MyFrame; proxy of C++ wxFrame instance at _e8ed8c00_p_wxFrame>
None

My question:
Why do the second function FindWindowByName return None?

Hello Cliff and Donnal,

Because 'MyFrame' is the window's *title*, not its name. See the 'name'
argument to wx.Window. What you are looking for is FindWindowByLabel.

"MyFrame" is the *title* of your frame, not its *name*. If you want
to use names you must include a 'name' keyword parameter.

thanks for your answers, I was in a kind of hurry and overlooked this :slight_smile:

···

On Fri, 17 Sep 2004 21:21:00 +0200, Franz Steinhäusler <franz.steinhaeusler@utanet.at> wrote:
--
Franz Steinhäusler

DrPython (Project Developer)
http://drpython.sourceforge.net/