Commit 6426debb authored by Kieran Hymas's avatar Kieran Hymas

Added colour palette menu

parent 0a793d2b
......@@ -21,7 +21,7 @@ class Application:
self.availableStreams = self.getPossibleVideoStreams()
self.delay = 10
#Image options
self.options = {'BnW' : False, \
self.options = {'bnw' : BooleanVar(), \
'vMirror' : False, \
'hMirror' : False, \
'Rotate' : 0, \
......@@ -50,6 +50,9 @@ class Application:
#Blur options
self.blurOptionsExists = False
#Colour options
self.colourOptionsExists = False
#INIT
self.initApp()
self.window.mainloop()
......@@ -69,10 +72,10 @@ class Application:
filemenu = Menu(menubar, tearoff=0)
menubar.add_cascade(label="File", menu=filemenu)
sessionmenu = Menu(filemenu, tearoff=0)
filemenu.add_cascade(label="New session", menu=sessionmenu)
filemenu.add_cascade(label="New stream", menu=sessionmenu)
for ind in self.availableStreams:
sessionmenu.add_command(label=str(ind), command=lambda stream=ind : self.launchVideo(stream))
filemenu.add_command(label="Exit Pycroscope", command=self.onExit)
filemenu.add_command(label="Exit", command=self.onExit)
editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="Preferences", command=self.onPreferences)
......@@ -150,6 +153,7 @@ class Application:
self.blurOptionsExists = True
blurOptions = Toplevel(self.window, bd=1)
blurOptions.title("Pycroscope: blur options")
blurcheck = Checkbutton(blurOptions, text="Apply Guassian blur", variable=self.options['Blur'])
blurcheck.pack(side=TOP)
......@@ -172,6 +176,23 @@ class Application:
self.blurOptionsExists = False
widget.destroy()
def initColourOptionsWindow(self):
if self.colourOptionsExists:
return
self.colourOptionsExists = True
colourOptions = Toplevel(self.window, bd=1)
colourOptions.title("Pycroscope: colour options")
bnwcheck = Checkbutton(colourOptions, text="Apply black and white filter", variable=self.options['bnw'])
bnwcheck.pack(side=TOP)
colourOptions.protocol("WM_DELETE_WINDOW", lambda arg=colourOptions : self.onClosingColourOptions(arg))
def onClosingColourOptions(self, widget):
self.colourOptionsExists = False
widget.destroy()
#Menubar options
#File
def onExit(self):
......@@ -210,12 +231,10 @@ class Application:
print("hMirror")
def onBlur(self):
#self.options['Blur'] = not self.options['Blur']
self.initBlurOptionsWindow()
def onColour(self):
self.options['BnW'] = not self.options['BnW']
print("Colour")
self.initColourOptionsWindow()
def onBrush(self):
print("Brush")
......
......@@ -19,7 +19,7 @@ class VideoStream:
ret, frame = self.vidcap.read()
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
#Apply options
if options['BnW']:
if options['bnw'].get():
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
if options['vMirror']:
frame = cv2.flip(frame, 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment