By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,657 Members | 1,346 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,657 IT Pros & Developers. It's quick & easy.

GUI Download Manager

P: 5
I have here a script from Kika http://zetcode.com/wxpython/gripts/ which is a gript that connect to an ftp site (when you run the Kika program it will show a log in window and when you click connect it will state that you're successfully log in and nothing follows.)What should I add in this script so that every time I run the script and successfully connect to the ftp site using your username or password or an anonymous connection another window will appear(log in window will automatically disappear) which contains your ftp site and all the files. Then you will be given an option if you want to download everything or just download the newest files. Thanks!

Expand|Select|Wrap|Line Numbers
  1. class NewDl(wx.Frame):
  2.  
  3.     def __init__(self, *args, **kw):
  4.         super(NewDl, self).__init__(*args, **kw) 
  5.  
  6.         self.InitUI()
  7.  
  8.         loc = wx.IconLocation(r'C:\Python27\favicon.ico', 0)
  9.         self.SetIcon(wx.IconFromLocation(loc))
  10.  
  11.     def InitUI(self):    
  12.  
  13.         wx.StaticText(self, label='FTP site:', pos=(60, 40))
  14.         wx.StaticText(self, label='Username:', pos=(60, 85))
  15.         wx.StaticText(self, label='Password:', pos=(60, 130))
  16.  
  17.         self.ftpsite = wx.TextCtrl(self, pos=(160, 30), 
  18.             size=(160, -1))
  19.         self.username = wx.TextCtrl(self,  pos=(160, 75), 
  20.             size=(160, -1))
  21.         self.password = wx.TextCtrl(self, pos=(160, 125), 
  22.             size=(160, -1), style=wx.TE_PASSWORD)
  23.  
  24.         self.ftp = None
  25.  
  26.         con = wx.Button(self, label='Connect', pos=(160, 220))
  27.  
  28.         self.Bind(wx.EVT_BUTTON, self.OnConnect, con)
  29.         self.Bind(wx.EVT_MAXIMIZE, self.OnMaximize) 
  30.         self.Bind(wx.EVT_SHOW, self.OnShown)
  31.  
  32.         self.sb = NewDownload(self)
  33.         self.SetStatusBar(self.sb)
  34.  
  35.         self.SetSize((400, 350))
  36.         self.SetTitle('SeA - HABS')
  37.         self.Centre()
  38.         self.Show()
  39.  
  40.  
  41.     def OnShown(self, e):
  42.  
  43.         if self.sb:
  44.             self.sb.PlaceIcon() 
  45.  
  46.     def OnMaximize(self, e):
  47.  
  48.         self.sb.PlaceIcon()             
  49.  
  50.     def OnConnect(self, e):
  51.  
  52.         if not self.ftp:
  53.  
  54.             ftpsite = self.ftpsite.GetValue()
  55.             username = self.username.GetValue()
  56.             password = self.password.GetValue()
  57.  
  58.             try:
  59.  
  60.                 self.ftp = FTP(ftpsite)
  61.                 var = self.ftp.login(username, password)
  62.  
  63.                 self.sb.SetStatusText('Successfully Login!')
  64.                 self.sb.icon.SetBitmap(wx.Bitmap('connected.png'))
  65.  
  66.             except AttributeError:
  67.  
  68.                 self.sb.SetStatusText('Error!')
  69.                 self.ftp = None
  70.  
  71.             except all_errors, err:
  72.  
  73.                 self.sb.SetStatusText(str(err))
  74.                 self.ftp = None
  75.  
Jan 6 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.