Passing information between .py's

This is a really basic question, but I’m having trouble finding the

answer to it online.

How do I transfer the file name which is input in one .py (an MDI
parent frame) to another .py (an MDI child frame)? The
parent gets the file name from the user via a file select dialog, but
the child frame is the one that needs to know what file it is working
with.

The child frame is just an object, like any other.
Derive your child frame class from wxMDIChildFrame and
add a member such as "SetFilename(self, Filename)".
Then have the application call the SetFilename member
to pass the information along. You could also just
set Child.Filename too, but this way you get to take
action when it is set (if you need to).

Gre7g

···

--- Mark Martinez <mark.martinez2@gmail.com> wrote:

How do I transfer the file name which is input in
one .py (an MDI
parent frame) to another .py (an MDI child frame)?
The
parent gets the file name from the user via a file
select dialog, but
the child frame is the one that needs to know what
file it is working
with.

____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhosting

Gre7g Luterman wrote:

  You could also just
set Child.Filename too, but this way you get to take
action when it is set (if you need to).

I'd just set the attribute. If you need to take action later, you can make it a property. See:

-CHB

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

The child frame is just an object, like any other.
Derive your child frame class from wxMDIChildFrame and

add a member such as “SetFilename(self, Filename)”.
Then have the application call the SetFilename member
to pass the information along. You could also just
set Child.Filename too, but this way you get to take

action when it is set (if you need to).

Gre7g

I’m sure this is wrong, so please correct me where I’m messing up. I created the SetFileName:

def SetFileName(self, File):

    File = self.File

and have this in my file selection:

 if dlg.ShowModal() == wx.ID_OK:
       filepaths = dlg.GetPaths()
       filename = dlg.GetFilenames()
        self.FileName

= filename
SetFileName(self, filename)
self.ReadFile()

and then in MDIChildFrame I have:

    filename = MDIParentFrame1.SetFileName.File

I know this doesn’t make too much sense, and I sure know it doesn’t work.

I'm sure this is wrong, so please correct me where
I'm messing up. I created
the SetFileName:

    def SetFileName(self, File):
        File = self.File

Well, this is backwards, for starters.

and have this in my file selection:

     if dlg.ShowModal() == wx.ID_OK:
           filepaths = dlg.GetPaths()
           filename = dlg.GetFilenames()
           self.FileName = filename
           SetFileName(self, filename)
           self.ReadFile()

and then in MDIChildFrame I have:

        filename = MDIParentFrame1.SetFileName.File

I know this doesn't make too much sense, and I sure
know it doesn't work.

Try something simple, like:

if Dialog.ShowModal() == wx.ID_OK:
    ChildWindow.Filename = Dialog.GetPath()

And then in your child window, when you need to know
the filename, simply refer to self.Filename.

Gre7g

···

--- Mark Martinez <mark.martinez2@gmail.com> wrote:

____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/