|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Exchanging value,data etc. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|