#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    44
    Rep Power
    11

    Exchanging value,data etc.


    This one is kind of complicated to me, the main point is to exchange value between frames and windows (wxPython)

    I make a connection from a Frame1, then I will have another Dialog window that will do some FTP processing, like showing a list of files on the server, but how could I make a connection make on Frame1 to work with the Dialog?

    Here an example:

    Code:
    Frame one:
     from ftplib import FTP
    
     self.ftp = FTP()# make a connection
    Code:
    Dialog:
     list = self.ftp.nlst() #it should use the connection make on Frame1.
     self.txt.WriteText(list)
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    London, England
    Posts
    1,585
    Rep Power
    1373
    One of the parameters to the dialog __init__ method is the parent object, which in your case I presume will be Frame one. You can get the ftp object from that:

    Code:
    class MyDialog(wxDialog):
      def __init__(self, parent, id, *args, **kwargs):
         wxDialog.__init__(self, parent, -1, 'myDialogTitle', *args, **kwargs)
         self.ftp = parent.ftp

    Alternatively you could pass the ftp or list object as an extra parameter to the __init__ method:

    Code:
    class MyDialog(wxDialog):
      def __init__(self, parent, *args, **kwargs):
         self.list = kwargs.pop('list', [])    #Python 2.3 onwards
         wxDialog.__init__(self, parent, -1, 'myDialogTitle', *args, **kwargs)
         self.ftp = parent.ftp
    in this example the 'list' object must be passed as a keyword parameter.

    Dave - The Developers' Coach

IMN logo majestic logo threadwatch logo seochat tools logo