Close a frame from another frame

Hi,

How can I do it?

Or to be more precise how can I know in every time which frames of my project

are open?

Which method you use?

Regards

Beppe

Giuseppe Costanzi wrote:

Hi,
How can I do it?

  otherFrame.Close()

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Giuseppe Costanzi wrote:

Hi,
How can I do it?

otherFrame.Close()

Lol....if it had been so easy I have not write my post.
I try to expalin better.
I have a frame frA ,and from this I open another frame frB.
to do this i make

#form the first frame
import AnotherFrame

def fctEdit(self,event):

        NewFrame = AnotherFrame.MyFrame()
        NewFrame.Show()

now the AnotherFrame is open.
If I do again the function (fctEdit) I will control if any or previous istance
of the AnotherFrame is running such as

def fctEdit(self,event):
        try:
            NewFrame.Close()
       except:
            print 'the Anotherframe it's just open'

        NewFrame = AnotherFrame.MyFrame()
        NewFrame.Show()

The problem is, when I declare NewFrame=AnotherFrame.MyFrame() there is a property of this
new istance that I could use to reffer to itself ?

Beppe

Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

···

----- Original Message ----- From: Robin Dunn
To: wxPython-users@lists.wxwidgets.org
Sent: Monday, May 28, 2007 10:59 PM
Subject: Re: [wxPython-users] Close a frame from another frame

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Monday, May 28, 2007, 2:50:35 PM, Giuseppe Costanzi wrote:

Hi, How can I do it? Or to be more precise how can I know in every
time which frames of my project are open?
Which method you use?

A dictionary of {strings:wx.Frames} pairs, where the strings are the
frame names.

First I make sure I assign every frame a name, via SetName. Then on
the top level frame's __init__ I use a:
    self.wins = {}

and I open the frames via a call to an OpenWindow method also defined
on the top level frame:
    def OpenWindow(self, name):
        win = self.wins.get(name)
        if not win:
            win = SecondaryFrame(self, name)
            self.wins[name] = win
        win.Show()

and I make sure to bind every frame's EVT_CLOSE event to a method on
the frame so that it eventually calls a CloseWindow method also
defined on the top level frame:

On the secondary frame's __init__:
   self.Bind(wx.EVT_CLOSE, self.OnClose)

and somewhere on the secondary frame:
    def OnClose(self, event):
        self.parent.CloseWindow(self.GetName())
        event.Skip()

and on the top level frame:
    def CloseWindow(self, name):
        del self.wins[name]

-- tacao

No bits were harmed during the making of this e-mail.