-
Notifications
You must be signed in to change notification settings - Fork 0
/
main-Copy1.sh
233 lines (183 loc) · 5.51 KB
/
main-Copy1.sh
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/usr/bin/wish
set fp [open config]
set itemList [exec cat config]
set i 0
# 设置主窗口的位置
set left 15
set top 230
wm attribute . -topmost 1
wm resizable . 0 0
wm geometry . -$left+$top
labelframe .software -text "Software" -width 130 -height 300 -padx 1m -pady 1m
labelframe .service -text "Copy" -width 130 -height 300 -padx 1m -pady 1m
labelframe .other -text "Other" -width 130 -height 300 -padx 1m -pady 1m
toplevel .font -width [expr 20*6+7] -height [expr 20*12+11] -padx 1m -pady 1m -background #ff85dd
wm geometry .font -$left+$top
wm overrideredirect .font true
wm withdraw .font
pack .software .service .other
button .other.getPath -text "new path" -width 13
pack .other.getPath
# 定义顶层窗口
toplevel .tl -padx 1m -pady 1m
wm overrideredirect .tl true
wm withdraw .tl
wm geometry .tl -$left+400
# 定义笔窗口
toplevel .pen -background "#ff0000"
wm overrideredirect .pen true
wm geometry .pen 15x15
wm withdraw .pen
# 定义输入框
set path_ "/home/yfs/jupyter-dir/notebook/deep_learning/images"
set paths [exec cat path]
listbox .tl.lb -listvariable paths -width 50
grid .tl.lb
bind .tl.lb <Double-Button-1> {
set path_ [%W get [%W curselection]]
puts $path_
wm withdraw .tl
}
set startx -1
set starty -1
set endx -1
set endy -1
bind . <Control-s> {
set loc [exec xdotool getmouselocation --shell]
set x [exec echo $loc | head -n 2 | head -n 1 | cut -d "=" -f 2]
set y [exec echo $loc | head -n 2 | tail -n 1 | cut -d "=" -f 2]
if {$startx == -1 && $starty == -1} {
set startx $x
set starty $y
} else {
set endx $x
set endy $y
}
puts "$startx, $starty, $endx, $endy"
}
bind . <Control-e> {
set startx -1
set starty -1
set endx -1
set endy -1
}
bind .other.getPath <1> {
puts "OK1"
#pack .tl.path
wm deiconify .tl
}
bind . <Control-z> {
if {$startx == -1 || $starty == -1 || $endx == -1 || $endy == -1} {
exec zenity --error --text "未选择截屏区域" 2>/dev/null
} else {
exec bash getMaxFile.sh $path_ $startx $starty $endx $endy &
after 100
exec xdotool mousemove $startx $starty mousedown 1 mousemove $endx $endy mouseup 1
}
}
bind . <Alt-z> {
exec bash delete_png.sh $path_
}
proc getString {color} {
set result $color
set result [format %x $result]
while {[string length $result] < 6} {
set result 0$result
}
return "#$result"
}
set color 0
for {set i 0} {$i < [expr 30*15]} {incr i} {
if {$i == 179} {
set result #ffffff
} else {
set result [getString $color]
}
label .font.color$i -background $result -width 2 -height 1
bind .font.color$i <1> {
set c [%W cget -background]
clipboard clear
clipboard append "<font color='$c' size=3></font>"
wm withdraw .font
}
set color [expr $color + 37282]
}
# 预处理配置文件内容e c
foreach item $itemList {
puts $item
set name [exec echo $item | cut -d "+" -f 2]
set kind [exec echo $item | cut -d "+" -f 3]
switch $kind {
1 {
set pathName .software.b$i
}
2 {
set pathName .service.b$i
}
3 {
set pathName .other.b$i
}
4 {
set pathName .other.b$i
}
}
button $pathName -text $name -textvariable $item -width 13
# 排列布局 可以修改某个kind内的布局,默认所有kind都是pack布局
switch $kind {
default {
pack $pathName
}
}
bind $pathName <1> {
set item [%W cget -textvariable]
set cmd [exec echo $item | cut -d "+" -f 1]
set name [exec echo $item | cut -d "+" -f 2]
set kind [exec echo $item | cut -d "+" -f 3]
switch $kind {
1 {
exec {*}$cmd &
puts "finished!!!\n\n"
}
2 {
if {$name == "font"} {
# 长为12个,宽为6个
set width [expr 20 * 6 + 7]
set height [expr 20 * 12 + 11]
wm deiconify .font
for {set i 0} {$i < [expr 30*15]} {incr i} {
set col [expr {$i %% 30}]
set row [expr {$i / 30}]
grid .font.color$i -column $col -row $row -padx 0.5m -pady 0.5m
}
} else {
set cmd [string trimleft $cmd]
clipboard clear
clipboard append $cmd
}
}
3 {
puts [exec expect upload_github.sh]
puts "finished!!!\n\n"
}
4 {
wm deiconify .pen
set done 0
bind .pen <Button-1> {
# 唤醒笔窗口
wm withdraw .pen
set done 1
}
while {!$done} {
set loc [exec xdotool getmouselocation]
set locX [exec echo $loc | cut -d " " -f 1 | cut -d ":" -f 2]
set locY [exec echo $loc | cut -d " " -f 2 | cut -d ":" -f 2]
wm geometry .pen +$locX+$locY
after 10
update
}
puts "finish!"
}
}
}
incr i
}