-
Notifications
You must be signed in to change notification settings - Fork 0
/
thinkingInTkinter1.py
123 lines (95 loc) · 4.16 KB
/
thinkingInTkinter1.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
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
from tkinter import *
class MyApp:
def __init__(self, myParent):
button_width = 20
button_padx = "2m"
button_pady = "1m"
buttons_frame_padx = "3m"
buttons_frame_pady = '5m'
buttons_frame_ipadx = '30m'
buttons_frame_ipady = '1m'
self.commonVariable1 = 0
self.commonVariable2 = None
self.myParent = myParent
self.myContainer1 = Frame(myParent)
#self.myContainer1.pack()
self.myContainer1.pack(
ipadx = buttons_frame_ipadx,
ipady = buttons_frame_ipady,
padx = buttons_frame_padx,
pady = buttons_frame_pady)
self.button1 = Button(self.myContainer1, command = self.createFT)
self.button1['text'] = 'Create FT'
self.button1['background'] = 'white'
self.button1.configure (
width = button_width,
padx = button_padx,
pady = button_pady)
self.button1.pack(side = TOP)
self.button1.focus_force()
#self.button1.bind('<Button-1>', self.createFT)
self.button1.bind('<Return>', self.createFT_withEvent)
self.button2 = Button(self.myContainer1)
self.button2.configure(text = "Remove Artifacts ")
self.button2.configure(background = 'tan')
self.button2.configure( width = button_width, padx = button_padx, pady = button_pady)
self.button2.pack(side = TOP)
self.button2.bind("<Button-1>", self.removeArtifacts)
self.button2.bind("<Return>", self.removeArtifacts)
self.button3 = Button(self.myContainer1, text = "Remove Contaminants")
self.button3.configure(background = 'grey')
self.button3.configure( width = button_width, padx = button_padx, pady = button_pady)
self.button3.pack(side = TOP)
self.button3.bind("<Button-1>", self.removeContaminants)
self.button3.bind("<Return>", self.removeContaminants)
self.button4 = Button(self.myContainer1, text = "Remove Molecular Lines")
self.button4.configure(background = 'tan')
self.button4.configure( width = button_width, padx = button_padx, pady = button_pady)
self.button4.pack(side = TOP)
self.button4.bind("<Button-1>", self.removeMolecularLines)
self.button4.bind("<Return>", self.removeMolecularLines)
self.button5 = Button(self.myContainer1, text = 'Exit Button', command = self.exult)
self.button5.pack(side = TOP)
def createFT_withEvent(self, event):
print ('mouse = ', str(event.x), str(event.y))
report_event(event)
self.createFT()
self.commonVariable1 = 1
def createFT(self): #, event):
#report_event(event)
print(' Creating FT')
if(self.button1["background"] == "white"):
self.button1['background'] = "tan"
else:
self.button1['background'] = 'white'
if(self.commonVariable1 != 1):
self.commonVariable1 = 2
def removeArtifacts(self, event):
print( ' removing Artifacts - now you know it is real ')
self.commonVariable1 = 3
def removeContaminants(self, event):
print (" Removing contaminants ")
self.commonVariable1 = 4
def removeMolecularLines(self, event):
print ('removing molecular lines')
self.commonVariable1 = 5
def exult(self):
print ('Exulting and exiting')
print ('Common variable 1 and 2 are', str(self.commonVariable1), self.commonVariable2)
self.myParent.destroy()
def report_event(event):
event_name = {"2": "Keypress", "4": 'Button Press'}
print ("Reporting event \n mouse x and y: " + str(event.x), str(event.y))
print ("Time =", str(event.time))
print ('type =', str(event.type), event_name[str(event.type)])
print ('EventWidgetId' + str(event.widget), 'eventKey symbol' +str(event.keysym))
root = Tk()
#myContainer1 = Frame(root)
#myContainer1.pack()
#button1 = Button(myContainer1)
#button1["text"] = "thi sis text too \n and more \n text"
#button1["background"] = 'green'
#button1.pack()
#root.mainloop()
myapp = MyApp(root)
root.mainloop()