-
Notifications
You must be signed in to change notification settings - Fork 27
/
frames.py
118 lines (87 loc) · 3.24 KB
/
frames.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
import tkinter
from PIL import ImageTk
from PIL import Image
class Frames:
xAxis = 0
yAxis = 0
MainWindow = 0
MainObj = 0
winFrame = object()
btnClose = object()
btnView = object()
image = object()
method = object()
callingObj = object()
labelImg = 0
def __init__(self, mainObj, MainWin, wWidth, wHeight, function, Object, xAxis=10, yAxis=10):
self.xAxis = xAxis
self.yAxis = yAxis
self.MainWindow = MainWin
self.MainObj = mainObj
self.MainWindow.title("Brain Tumor Detection")
if (self.callingObj != 0):
self.callingObj = Object
if (function != 0):
self.method = function
global winFrame
self.winFrame = tkinter.Frame(self.MainWindow, width=wWidth, height=wHeight)
self.winFrame['borderwidth'] = 5
self.winFrame['relief'] = 'ridge'
self.winFrame.place(x=xAxis, y=yAxis)
self.btnClose = tkinter.Button(self.winFrame, text="Close", width=8,
command=lambda: self.quitProgram(self.MainWindow))
self.btnClose.place(x=1020, y=600)
self.btnView = tkinter.Button(self.winFrame, text="View", width=8, command=lambda: self.NextWindow(self.method))
self.btnView.place(x=900, y=600)
def setCallObject(self, obj):
self.callingObj = obj
def setMethod(self, function):
self.method = function
def quitProgram(self, window):
global MainWindow
self.MainWindow.destroy()
def getFrames(self):
global winFrame
return self.winFrame
def unhide(self):
self.winFrame.place(x=self.xAxis, y=self.yAxis)
def hide(self):
self.winFrame.place_forget()
def NextWindow(self, methodToExecute):
listWF = list(self.MainObj.listOfWinFrame)
if (self.method == 0 or self.callingObj == 0):
print("Calling Method or the Object from which Method is called is 0")
return
if (self.method != 1):
methodToExecute()
if (self.callingObj == self.MainObj.DT):
img = self.MainObj.DT.getImage()
else:
print("Error: No specified object for getImage() function")
jpgImg = Image.fromarray(img)
current = 0
for i in range(len(listWF)):
listWF[i].hide()
if (listWF[i] == self):
current = i
if (current == len(listWF) - 1):
listWF[current].unhide()
listWF[current].readImage(jpgImg)
listWF[current].displayImage()
self.btnView['state'] = 'disable'
else:
listWF[current + 1].unhide()
listWF[current + 1].readImage(jpgImg)
listWF[current + 1].displayImage()
print("Step " + str(current) + " Extraction complete!")
def removeComponent(self):
self.btnClose.destroy()
self.btnView.destroy()
def readImage(self, img):
self.image = img
def displayImage(self):
imgTk = self.image.resize((250, 250), Image.ANTIALIAS)
imgTk = ImageTk.PhotoImage(image=imgTk)
self.image = imgTk
self.labelImg = tkinter.Label(self.winFrame, image=self.image)
self.labelImg.place(x=700, y=150)