zoukankan      html  css  js  c++  java
  • 实现抓图的工具2

    这里主要是给出界面,让用户可以选择保存的路径,还有网络地址可选,使用wxPython库编写

    #encoding:UTF-8
    import wx
    import os
    import crawlFirst

    class SelectPath(wx.Frame):
    def __init__(self,parent,id):
    wx.Frame.__init__(self,None,-1,u"选择保存路径(作者:董继超 版权所有)",size=(500,300),style=wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN)
    panel=wx.Panel(self,-1)
    button1=wx.Button(panel,label=u"开始",pos=(20,220),size=(60,30))
    button2=wx.Button(panel,label=u"关闭",pos=(100,220),size=(60,30))
    button3=wx.Button(panel,label=u"选择文件夹",pos=(380,77),size=(100,30))

    sList=["http://www.2cto.com/meinv/rhmeinv/","http://www.2cto.com/meinv/sexmv"]
    wx.StaticText(panel,-1,u"选择一个网址",(20,25))
    self.combo= wx.ComboBox(panel,-1,"http://www.2cto.com/meinv/rhmeinv/",(100,22),choices=sList,style=0)

    self.input_text = wx.TextCtrl(panel, -1, u"",pos=(20,80), size=(350, 25))
    self.Bind(wx.EVT_BUTTON,self.OnStart,button1)
    self.Bind(wx.EVT_BUTTON,self.OnCloseMe,button2)
    self.Bind(wx.EVT_BUTTON,self.OnSelPath,button3)
    self.Bind(wx.EVT_CLOSE,self.OnCloseWindow)

    def OnSelPath(self,event):
    dialog=wx.DirDialog(None,u"选择图片保存的目录",style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
    if dialog.ShowModal()==wx.ID_OK:
    self.input_text.SetValue(dialog.GetPath())

    def OnStart(self,event):
    sPath=self.input_text.Value.strip(" ")
    if sPath =="":
    wx.MessageBox(u'请选择保存路径',u'提示',wx.OK|wx.ICON_INFORMATION)
    return
    elif not os.path.exists(sPath):
    wx.MessageBox(u'所选路径不存在',u'提示',wx.OK|wx.ICON_INFORMATION)
    return
    else:
    print self.combo.Value
    crawlFirst.GetUrlContent(self.combo.Value,sPath)

    def OnCloseMe(self,event):
    self.Close(True)

    def OnCloseWindow(self,event):
    self.Destroy()

    if __name__=='__main__':
    app=wx.PySimpleApp()
    frame=SelectPath(parent=None,id=-1)
    frame.Show()
    app.MainLoop()
  • 相关阅读:
    Linux 性能监测:CPU
    Linux 性能监测:介绍
    数据库设计
    数据库设计
    如何将Virtualbox和VMware虚拟机相互转换
    如何将Virtualbox和VMware虚拟机相互转换
    stat()获得文件信息
    stat()获得文件信息
    网游创业为什么会失败?
    网游创业为什么会失败?
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/5374249.html
Copyright © 2011-2022 走看看