批量下载国家地理壁纸Python脚本(wxpython版)

[今天在CU的python版里看到一篇"批量下载国家地理壁纸Python脚本"。感觉不错,借此,用wxpython写了一个GUI的界面。]



部分代码
import wx
from getimg import getimg

class GetImgFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'GetImages',size=(500,150))
        panel = wx.Panel(self, -1)
        wx.StaticText(panel, -1, "Please enter a downloadable conditional",pos=(10,5))
        self.basicLabel = wx.StaticText(panel, -1, "Year:",pos=(30,40))
        self.yearText = wx.TextCtrl(panel, -1, "2009",pos=(60,40))
        self.yearText.SetInsertionPoint(0)
        self.basicLabel = wx.StaticText(panel, -1, "Month:",pos=(180,40))
        self.monthText = wx.TextCtrl(panel, -1, "7",pos=(220,40))
        self.monthText.SetInsertionPoint(0)
        self.basicLabel = wx.StaticText(panel, -1, "Day:",pos=(350,40))
        self.dayText = wx.TextCtrl(panel, -1, "1",pos=(380,40))
        self.dayText.SetInsertionPoint(0)
        self.button = wx.Button(panel, -1, "Download", pos=(380,80))             
        self.Bind(wx.EVT_BUTTON,self.OnDownload,self.button)
        self.Bind(wx.EVT_CLOSE,self.OnCloseWindow)
       
    def OnDownload(self,evt):
        year=int(self.yearText.GetValue())
        month=int(self.monthText.GetValue())
        day=int(self.dayText.GetValue())
        self.button.Enable(False)
        for day in range(1, day+1):
            getimg(year, "%(#)02d"%{"#":month}, "%(#)02d"%{"#":day}, "0", "http://192.168.1.114:666/",self.button)
       
    def OnCloseWindow(self,evt):
        self.Destroy()

if __name__ == '__main__':
    app = wx.PySimpleApp()
    GetImgFrame().Show()
    app.MainLoop()

详细内容看附件。

原文:http://bbs.chinaunix.net/thread-1535720-1-1.html,仅供学习。

你可能感兴趣的:(职场,wxPython,休闲)