Счетчик Строк

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!usr/bin/env python
# -*- coding:utf-8 -*-
# files length counter
# (c) login999
from Tkinter import *
from tkMessageBox import showerror
from tkFileDialog import askopenfilename
LastCounter = 0
NowCounter = 0
AllCounter = 0
def Count():
global LastCount
global NowCount
global AllCount
global AllCounter
global NowCounter
global LastCounter
LastCounter = NowCounter
NowCounter = 0
try:
with open(askopenfilename()) as accs:
for _ in accs:
NowCounter += 1
AllCounter += 1
LastCount["text"] = LastCounter
NowCount["text"] = NowCounter
AllCount["text"] = AllCounter
except Exception, e:
showerror(u"Ошибка", e)
def NODUP():
global LastCount
global NowCount
global AllCount
global AllCounter
global NowCounter
global LastCounter
LastCounter = NowCounter
NowCounter = 0
try:
with open(askopenfilename()) as accs:
for _ in set(accs):
NowCounter += 1
AllCounter += 1
LastCount["text"] = LastCounter
NowCount["text"] = NowCounter
AllCount["text"] = AllCounter
except Exception, e:
showerror(u"Ошибка", e)
def Clear():
global LastCount
global NowCount
global AllCount
global AllCounter
global NowCounter
global LastCounter
NowCounter = 0
LastCounter = 0
AllCounter = 0
LastCount["text"] = LastCounter
NowCount["text"] = NowCounter
AllCount["text"] = AllCounter
MainWindow = Tk()
MainWindow["bd"] = 5
MainWindow.title(u"Счетчик Строк")
MainWindow.resizable(width=False, height=False)
ButtonsFrame = Frame(MainWindow)
CountButton = Button(ButtonsFrame, text=u"Посчитать", width=11, command=Count)
NODUPButton = Button(ButtonsFrame, text=u"Без дублей", width=11, command=NODUP)
ClearButton = Button(ButtonsFrame, text=u"Очистить", width=11, command=Clear)
CountButton.grid(row=0, column=0)
NODUPButton.grid(row=1, column=0)
ClearButton.grid(row=2, column=0)
ButtonsFrame.grid(row=0, column=0, sticky="w")
LinesLabel = LabelFrame(MainWindow, text=u"Количество строк")
LastLabel = Label(LinesLabel, text=u"Последний :", anchor="w", width=12)
LastCount = Label(LinesLabel, text=LastCounter, width=8)
NowLabel = Label(LinesLabel, text=u"Нынешний :", anchor="w", width=12)
NowCount = Label(LinesLabel, text=NowCounter, width=8)
AllLabel = Label(LinesLabel, text=u"Всего :", anchor="w", width=12)
AllCount = Label(LinesLabel, text=AllCounter, width=8)
LastLabel.grid(row=0, column=0)
LastCount.grid(row=0, column=1)
NowLabel.grid(row=1, column=0)
NowCount.grid(row=1, column=1)
AllLabel.grid(row=2, column=0)
AllCount.grid(row=2, column=1)
LinesLabel.grid(row=0, column=1, sticky="w")
MainWindow.mainloop()