Skip to content

Commit 4f5a83b

Browse files
V1.5.2
1. Add export settings to provide a variety of options. 2. Change the crawler template to case project. 3. Add PDF tools and train ticket cases. 4. Improve the function of operation and debugging. 5. Add Mac version. 6. Add donation function. If you want to support me, you can remit money to me. 7. Fix some feedback bugs
1 parent 9e4d9b6 commit 4f5a83b

File tree

88 files changed

+4348
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+4348
-0
lines changed

Examples/GirlImages/Fun.py

Lines changed: 862 additions & 0 deletions
Large diffs are not rendered by default.

Examples/GirlImages/GirlImages.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#coding=utf-8
2+
#import libs
3+
import sys
4+
import codecs
5+
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
6+
import GirlImages_cmd
7+
import GirlImages_sty
8+
import Fun
9+
import os
10+
import LeftTreeBar
11+
import RightTextBar
12+
import tkinter
13+
from tkinter import *
14+
import tkinter.ttk
15+
import tkinter.font
16+
#Add your Varial Here: (Keep This Line of comments)
17+
#Define UI Class
18+
class GirlImages:
19+
def __init__(self,root,isTKroot = True):
20+
uiName = self.__class__.__name__
21+
Fun.Register(uiName,'UIClass',self)
22+
self.root = root
23+
style = GirlImages_sty.SetupStyle()
24+
if isTKroot == True:
25+
root.title("Form1")
26+
Fun.CenterDlg(uiName,root,820,660)
27+
root['background'] = '#efefef'
28+
root.bind('<Configure>',self.Configure)
29+
Form_1= tkinter.Canvas(root,width = 10,height = 4)
30+
Form_1.place(x = 0,y = 0,width = 820,height = 660)
31+
Form_1.configure(bg = "#efefef")
32+
Form_1.configure(highlightthickness = 0)
33+
Fun.Register(uiName,'root',root)
34+
Fun.Register(uiName,'Form_1',Form_1)
35+
#Create the elements of root
36+
Label_2= tkinter.Label(root,text="网址",width = 10,height = 4)
37+
Fun.Register(uiName,'Label_2',Label_2)
38+
Label_2.place(x = 10,y = 2,width = 50,height = 24)
39+
Label_2.configure(relief = "flat")
40+
Entry_3_Variable = Fun.AddTKVariable(uiName,'Entry_3','')
41+
Entry_3= tkinter.Entry(root,textvariable=Entry_3_Variable)
42+
Fun.Register(uiName,'Entry_3',Entry_3)
43+
Entry_3.place(x = 60,y = 2,width = 500,height = 24)
44+
Entry_3.configure(relief = "sunken")
45+
Label_4= tkinter.Label(root,text="最大数量",width = 10,height = 4)
46+
Fun.Register(uiName,'Label_4',Label_4)
47+
Label_4.place(x = 560,y = 2,width = 60,height = 24)
48+
Label_4.configure(relief = "flat")
49+
Entry_5_Variable = Fun.AddTKVariable(uiName,'Entry_5','')
50+
Entry_5= tkinter.Entry(root,textvariable=Entry_5_Variable)
51+
Fun.Register(uiName,'Entry_5',Entry_5)
52+
Entry_5.place(x = 620,y = 2,width = 70,height = 24)
53+
Entry_5.configure(relief = "sunken")
54+
Button_6= tkinter.Button(root,text="开始",width = 10,height = 4)
55+
Fun.Register(uiName,'Button_6',Button_6)
56+
Button_6.place(x = 710,y = 2,width = 50,height = 24)
57+
Button_6.configure(command=lambda:GirlImages_cmd.Button_6_onCommand(uiName,"Button_6"))
58+
Button_7= tkinter.Button(root,text="停止",width = 10,height = 4)
59+
Fun.Register(uiName,'Button_7',Button_7)
60+
Button_7.place(x = 770,y = 2,width = 50,height = 24)
61+
Button_7.configure(command=lambda:GirlImages_cmd.Button_7_onCommand(uiName,"Button_7"))
62+
PanedWindow_8= tkinter.PanedWindow(root)
63+
Fun.Register(uiName,'PanedWindow_8',PanedWindow_8)
64+
PanedWindow_8.place(x = 0,y = 30,width = 871,height = 610)
65+
PanedWindow_8.configure(orient = tkinter.HORIZONTAL)
66+
PanedWindow_8.configure(showhandle = "0")
67+
PanedWindow_8.configure(sashrelief = "flat")
68+
PanedWindow_8.configure(sashwidth = "4")
69+
PanedWindow_8_child1= tkinter.Canvas(PanedWindow_8,bg="#FFDD94",name="child1")
70+
PanedWindow_8_child1.place(x = 1,y = 1,width = 261,height = 608)
71+
LeftTreeBar.LeftTreeBar(PanedWindow_8_child1,False)
72+
PanedWindow_8.add(PanedWindow_8_child1,width =261)
73+
PanedWindow_8_child2= tkinter.Canvas(PanedWindow_8,bg="#D0E6A5",name="child2")
74+
Fun.Register(uiName,'PanedWindow_8_child1',PanedWindow_8_child1)
75+
Fun.Register(uiName,'PanedWindow_8_child2',PanedWindow_8_child2)
76+
PanedWindow_8_child2.place(x = 266,y = 1,width = 604,height = 608)
77+
RightTextBar.RightTextBar(PanedWindow_8_child2,False)
78+
PanedWindow_8.add(PanedWindow_8_child2,width =604)
79+
Fun.Register(uiName,'PanedWindow_8_child1',PanedWindow_8_child1)
80+
Fun.Register(uiName,'PanedWindow_8_child2',PanedWindow_8_child2)
81+
Label_9= tkinter.Label(root,text="Label",width = 10,height = 4)
82+
Fun.Register(uiName,'Label_9',Label_9)
83+
Label_9.place(x = 0,y = 640,width = 820,height = 20)
84+
Label_9.configure(relief = "flat")
85+
#Inital all element's Data
86+
Fun.InitElementData(uiName)
87+
#Call Form_1's OnLoad Function
88+
GirlImages_cmd.Form_1_onLoad(uiName)
89+
#Add Some Logic Code Here: (Keep This Line of comments)
90+
91+
def Configure(self,event):
92+
if self.root == event.widget:
93+
PanedWindow_8 = Fun.GetElement(self.__class__.__name__,'PanedWindow_8')
94+
Label_9 = Fun.GetElement(self.__class__.__name__,'Label_9')
95+
PanedWindow_8.place(x = 0,y = 50,width = event.width,height = event.height - 51 - 20)
96+
Label_9.place(x = 0,y = event.height - 20,width = event.width,height = 20)
97+
98+
#Create the root of Kinter
99+
if __name__ == '__main__':
100+
root = tkinter.Tk()
101+
MyDlg = GirlImages(root)
102+
root.mainloop()
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#coding=utf-8
2+
import sys
3+
import os
4+
from os.path import abspath, dirname
5+
sys.path.append(abspath(dirname(__file__)))
6+
import tkinter
7+
import tkinter.filedialog
8+
from tkinter import *
9+
import Fun
10+
ElementBGArray={}
11+
ElementBGArray_Resize={}
12+
ElementBGArray_IM={}
13+
14+
import threading
15+
import urllib.request
16+
from bs4 import BeautifulSoup
17+
from PIL import Image,ImageTk,ImageFont,ImageDraw
18+
G_UITreeImageArray={}
19+
G_UITreeItemArray={}
20+
threadAction = True
21+
header = {
22+
"User-Agent": 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36',
23+
'Accept': '*/*',
24+
'Accept-Language': 'en-US,en;q=0.8',
25+
'Cache-Control': 'max-age=0',
26+
'Connection': 'keep-alive'
27+
}
28+
#代码参考博客:https://www.cnblogs.com/raorao1994/p/10301811.html
29+
def Download(url, picAlt, name):
30+
global G_UITreeImageArray
31+
global G_UITreeItemArray
32+
newPath = os.getcwd() + "\\images\\"+ picAlt + "\\"
33+
fullPath = '{0}{1}.jpg'.format(newPath, name)
34+
imageName = '{0}.jpg'.format(name)
35+
if url.find(".png") >= 0 :
36+
fullPath = '{0}{1}.png'.format(newPath, name)
37+
imageName = '{0}.png'.format(name)
38+
TreeView_2 = Fun.GetElement('LeftTreeBar','TreeView_2')
39+
parentItem = ''
40+
if not os.path.exists(newPath):
41+
os.makedirs(newPath)
42+
parentItem = TreeView_2.insert('','end',newPath,text=picAlt,values=('1'),tags = ('dirs',))
43+
G_UITreeItemArray[picAlt] = parentItem
44+
else:
45+
if picAlt in G_UITreeItemArray:
46+
parentItem = G_UITreeItemArray[picAlt]
47+
else:
48+
parentItem = TreeView_2.insert('','end',newPath,text=picAlt,values=('1'),tags = ('dirs',))
49+
G_UITreeItemArray[picAlt] = parentItem
50+
newTreeItem = TreeView_2.insert(parentItem,'end',fullPath,text=imageName,values=('2'))
51+
urllib.request.urlretrieve(url, fullPath)
52+
#代码参考博客:https://www.cnblogs.com/raorao1994/p/10301811.html
53+
def run(targetUrl, uiName,beginNUM, endNUM):
54+
global threadAction
55+
urlPath, webName = os.path.split(targetUrl)
56+
Text_2 = Fun.GetElement('RightTextBar','Text_2')
57+
if threadAction == False:
58+
output = 'Stop'
59+
Text_2.insert(tkinter.END,output)
60+
return
61+
req = urllib.request.Request(url=targetUrl, headers=header)
62+
response = urllib.request.urlopen(req)
63+
html = response.read().decode('gb2312', 'ignore')
64+
soup = BeautifulSoup(html, 'html.parser')
65+
Divs = soup.find_all('div', attrs={'id': 'big-pic'})
66+
nowpage = soup.find('span', attrs={'class': 'nowpage'}).get_text()
67+
totalpage = soup.find('span', attrs={'class': 'totalpage'}).get_text()
68+
if beginNUM == endNUM:
69+
return
70+
for div in Divs:
71+
beginNUM = beginNUM + 1
72+
if div.find('a') is None:
73+
print('No Images')
74+
return
75+
elif div.find('a')['href'] is None or div.find('a')['href'] == "":
76+
print('No Images')
77+
return
78+
labelText = '>>>:Progress :' + str(beginNUM) + '/' + str(endNUM) + ' ,DownLoading Images:('+ str(nowpage) + '/' + str(totalpage) + ')'
79+
Fun.SetText(uiName,'Label_9',labelText)
80+
if int(nowpage) < int(totalpage):
81+
nextPageLink = urlPath + '//' + (div.find('a')['href'])
82+
elif int(nowpage) == int(totalpage):
83+
nextPageLink = (div.find('a')['href'])
84+
picLink = (div.find('a').find('img')['src'])
85+
picAlt = (div.find('a').find('img'))['alt']
86+
output = 'Image Link:'+ picLink + '\n'
87+
Text_2.insert(tkinter.END,output)
88+
output = 'DirName:[ '+ picAlt + ' ] ' + '\n'
89+
Text_2.insert(tkinter.END,output)
90+
output = 'Start...........\n'
91+
Text_2.insert(tkinter.END,output)
92+
Download(picLink, picAlt, nowpage)
93+
output = 'Finish!\n'
94+
Text_2.insert(tkinter.END,output)
95+
output = 'Mext link:'+nextPageLink + '\n'
96+
Text_2.insert(tkinter.END,output)
97+
Text_2.see(tkinter.END)
98+
run(nextPageLink, uiName , beginNUM, endNUM)
99+
return
100+
def Form_1_onLoad(uiName):
101+
Fun.SetText(uiName,'Entry_3','http://www.mmonly.cc/mmtp/qcmn/237273_10.html')
102+
Fun.SetText(uiName,'Entry_5','200')
103+
def Button_6_onCommand(uiName,widgetName):
104+
global threadAction
105+
targetUrl = Fun.GetText(uiName,"Entry_3")
106+
total = Fun.GetText(uiName,"Entry_5")
107+
Text_2 = Fun.GetElement("RightTextBar","Text_2")
108+
Text_2.delete('0.0',tkinter.END)
109+
threadAction = True
110+
run_thread = threading.Thread(target=run, args=[targetUrl,uiName,0,int(total)])
111+
run_thread.start()
112+
def Button_7_onCommand(uiName,widgetName):
113+
global threadAction
114+
threadAction = False
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import tkinter
2+
import tkinter.ttk
3+
def SetupStyle():
4+
style = tkinter.ttk.Style()
5+
return style

Examples/GirlImages/LeftTreeBar.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#coding=utf-8
2+
#import libs
3+
import LeftTreeBar_cmd
4+
import LeftTreeBar_sty
5+
import Fun
6+
import tkinter
7+
from tkinter import *
8+
import tkinter.ttk
9+
import tkinter.font
10+
#Add your Varial Here: (Keep This Line of comments)
11+
#Define UI Class
12+
class LeftTreeBar:
13+
def __init__(self,root,isTKroot = True):
14+
uiName = self.__class__.__name__
15+
Fun.G_UIElementArray[uiName]={}
16+
Fun.G_UIElementUserDataArray[uiName]={}
17+
Fun.Register(uiName,'UIClass',self)
18+
self.root = root
19+
style = LeftTreeBar_sty.SetupStyle()
20+
if isTKroot == True:
21+
root.title("Form1")
22+
root.wm_attributes("-topmost",1)
23+
root.geometry("205x549")
24+
root.bind('<Configure>',self.Configure)
25+
Form_1= tkinter.Canvas(root,width = 10,height = 4)
26+
Form_1.place(x = 0,y = 0,width = 205,height = 549)
27+
Form_1.configure(bg = "#333333")
28+
Form_1.configure(highlightthickness = 0)
29+
Fun.Register(uiName,'root',root)
30+
Fun.Register(uiName,'Form_1',Form_1)
31+
#Create the elements of root
32+
TreeView_2= tkinter.ttk.Treeview(root,show="tree")
33+
TreeView_2.place(x = 0,y = 0,width = 205,height = 549)
34+
TreeView_2.configure(selectmode = "extended")
35+
TreeView_2.bind("<Button-1>",Fun.EventFunction_Adaptor(LeftTreeBar_cmd.TreeView_2_onButton1,uiName=uiName,widgetName="TreeView_2"))
36+
Fun.Register(uiName,'TreeView_2',TreeView_2)
37+
#Inital all element's Data
38+
Fun.InitElementData(uiName)
39+
#Add Some Logic Code Here: (Keep This Line of comments)
40+
root.bind('<Configure>',self.Configure)
41+
def Configure(self,event):
42+
if self.root == event.widget:
43+
TreeView_2 = Fun.GetElement(self.__class__.__name__,'TreeView_2')
44+
TreeView_2.place(x = 0,y = 0,width = event.width,height = event.height)
45+
46+
#Create the root of Kinter
47+
if __name__ == '__main__':
48+
root = tkinter.Tk()
49+
MyDlg = LeftTreeBar(root)
50+
root.mainloop()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#coding=utf-8
2+
import sys
3+
import os
4+
from os.path import abspath, dirname
5+
sys.path.append(abspath(dirname(__file__)))
6+
import tkinter
7+
import tkinter.filedialog
8+
from tkinter import *
9+
from PIL import Image
10+
import Fun
11+
def TreeView_2_onButton1(event,uiName,widgetName):
12+
TreeCtrl = Fun.GetElement(uiName,widgetName)
13+
item = TreeCtrl.identify("item",event.x,event.y)
14+
if item is not None and item is not "":
15+
filename_lower = str(item).lower()
16+
if filename_lower.find(".png") >= 0 or filename_lower.find(".jpg") >= 0 :
17+
img= Image.open(filename_lower)
18+
img.show()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import tkinter
2+
import tkinter.ttk
3+
def SetupStyle():
4+
style = tkinter.ttk.Style()
5+
return style
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#coding=utf-8
2+
#import libs
3+
import RightTextBar_cmd
4+
import RightTextBar_sty
5+
import Fun
6+
import tkinter
7+
from tkinter import *
8+
import tkinter.ttk
9+
import tkinter.font
10+
#Add your Varial Here: (Keep This Line of comments)
11+
#Define UI Class
12+
class RightTextBar:
13+
def __init__(self,root,isTKroot = True):
14+
uiName = self.__class__.__name__
15+
Fun.G_UIElementArray[uiName]={}
16+
Fun.G_UIElementUserDataArray[uiName]={}
17+
Fun.Register(uiName,'UIClass',self)
18+
self.root = root
19+
style = RightTextBar_sty.SetupStyle()
20+
if isTKroot == True:
21+
root.title("Form1")
22+
root.wm_attributes("-topmost",1)
23+
root.geometry("607x585")
24+
Form_1= tkinter.Canvas(root,width = 10,height = 4)
25+
Form_1.place(x = 0,y = 0,width = 607,height = 549)
26+
Form_1.configure(bg = "#333333")
27+
Form_1.configure(highlightthickness = 0)
28+
Fun.Register(uiName,'root',root)
29+
Fun.Register(uiName,'Form_1',Form_1)
30+
#Create the elements of root
31+
Text_2= tkinter.Text(root)
32+
Text_2.place(x = 0,y = 0,width = 607,height = 549)
33+
Text_2.configure(bg = "#333333")
34+
Text_2.configure(fg = "#ffffff")
35+
Text_2.configure(relief = "sunken")
36+
Text_2_Scrollbar = tkinter.Scrollbar(Text_2,orient=tkinter.VERTICAL)
37+
Text_2_Scrollbar.place(x = 587,y = 0,width = 20,height = 549)
38+
Text_2_Scrollbar.config(command = Text_2.yview)
39+
Text_2.config(yscrollcommand = Text_2_Scrollbar.set)
40+
Fun.Register(uiName,'Text_2',Text_2)
41+
Fun.Register(uiName,'Text_2_Scrollbar',Text_2_Scrollbar)
42+
#Inital all element's Data
43+
Fun.InitElementData(uiName)
44+
#Add Some Logic Code Here: (Keep This Line of comments)
45+
root.bind('<Configure>',self.Configure)
46+
def Configure(self,event):
47+
if self.root == event.widget:
48+
Text_2 = Fun.GetElement(self.__class__.__name__,'Text_2')
49+
Text_2_Scrollbar = Fun.GetElement(self.__class__.__name__,'Text_2_Scrollbar')
50+
Text_2.place(x = 0,y = 0,width = event.width,height = event.height)
51+
Text_2_Scrollbar.place(x = event.width-20,y = 0,width = 20,height = event.height)
52+
53+
#Create the root of Kinter
54+
if __name__ == '__main__':
55+
root = tkinter.Tk()
56+
MyDlg = RightTextBar(root)
57+
root.mainloop()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#coding=utf-8
2+
import sys
3+
import os
4+
from os.path import abspath, dirname
5+
sys.path.append(abspath(dirname(__file__)))
6+
import tkinter
7+
import tkinter.filedialog
8+
from tkinter import *
9+
import Fun
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import tkinter
2+
import tkinter.ttk
3+
def SetupStyle():
4+
style = tkinter.ttk.Style()
5+
return style

0 commit comments

Comments
 (0)