-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtilities.py
63 lines (45 loc) · 1.68 KB
/
Utilities.py
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 11 17:43:59 2022
@author: mariamjabara
"""
def sprintf(format, *args): # so that the same s=sprintf("%3.2f",x) as in C can be used, for old programmers
s = format % args
return s
def popUpMessage(msg):
popup = tk.Tk()
def leavemini():
popup.destroy()
popup.wm_title("!")
label = ttk.Label(popup, text=msg,font=NORMAL_FONT)
label.pack(side="top",fill="x", pady=10)
B1 = ttk.Button(popup,text = "Okay", command = leavemini)
B1.pack()
popup.mainloop()
def line_select_callback(eclick, erelease):
'eclick and erelease are the press and release events'
global c_x1, c_x2, c_y1, c_y2
x1, y1 = eclick.xdata, eclick.ydata
x2, y2 = erelease.xdata, erelease.ydata
c_x1 = x1
c_x2 = x2
c_y1 = y1
c_y2 = y2
print("(%3.2f, %3.2f) --> (%3.2f, %3.2f)" % (x1, y1, x2, y2))
print(" The button you used were: %s %s" % (eclick.button, erelease.button))
def toggle_selector(event):
print(' Key pressed.')
if event.key in ['Q', 'q'] and toggle_selector.RS.active:
print(' RectangleSelector deactivated.')
toggle_selector.RS.set_active(False)
toggle_selector.RS.set_visible(False)
toggle_selector.RS.update()
if event.key in ['A', 'a'] and not toggle_selector.RS.active:
print(' RectangleSelector activated.')
toggle_selector.RS.set_active(True)
toggle_selector.RS.set_visible(True)
toggle_selector.RS.update()
def mycallback(event):
if toggle_selector.RS.active:
toggle_selector.RS.update()