Commit f8e15a5d authored by Kieran Hymas's avatar Kieran Hymas

Fixed possible refresh devices bug

parent 7b0e3e57
......@@ -21,6 +21,7 @@ class Application:
#Videostream options
self.videostreamplaying = False
self.videostreampaused = False
self.videostream = 0 #Initialise an empty video VideoStream
self.availableStreams = self.getPossibleVideoStreams()
self.delay = 10
......@@ -38,7 +39,7 @@ class Application:
'BrushSize' : DoubleVar(), \
'BrushColour' : [0, 0, 0], \
'EdgeDetection' : BooleanVar(), \
'EdgeDetectionColour' : [0, 0, 0], \
'EdgeDetectionColour' : [0, 255, 0], \
'EdgeDetectionThickness' : IntVar(), \
'EdgeDetectionThresh1' : DoubleVar(), \
'EdgeDetectionThresh2' : DoubleVar(), \
......@@ -100,21 +101,18 @@ class Application:
self.filemenu.add_command(label="Refresh stream list", command=self.refreshStreams)
self.streamoptionsmenu = Menu(self.filemenu, tearoff=0)
self.filemenu.add_cascade(label="Stream actions", state=DISABLED, menu=self.streamoptionsmenu)
self.streamoptionsmenu.add_command(label="Pause")
self.streamoptionsmenu.add_command(label="Resume", state=DISABLED)
self.streamoptionsmenu.add_command(label="Blackout")
self.streamoptionsmenu.add_command(label="Pause", command=self.onPause)
self.streamoptionsmenu.add_command(label="Resume", command=self.onResume, state=DISABLED)
self.streamoptionsmenu.add_command(label="Kill", command=self.cleanUpVideo)
self.filemenu.add_command(label="Exit", command=self.onExit)
self.editmenu = Menu(self.menubar, tearoff=0)
self.editmenu.add_command(label="Preferences", command=self.onPreferences)
self.menubar.add_cascade(label="Edit", menu=self.editmenu)
self.toolmenu = Menu(self.menubar, tearoff=0)
self.toolmenu.add_command(label="Show toolbar", command=self.initToolbar)
self.toolmenu.add_separator()
self.toolmenu.add_command(label="Blur", command=self.onBlur)
self.toolmenu.add_command(label="Record", command=self.onRecord)
self.toolmenu.add_command(label="Colour", command=self.onColour)
self.toolmenu.add_command(label="Brush", command=self.onBrush)
self.toolmenu.add_command(label="Edge detection", command=self.onEdge)
self.toolmenu.add_separator()
self.toolmenu.add_command(label="Show toolbar", command=self.initToolbar)
self.menubar.add_cascade(label="Tools", menu=self.toolmenu)
self.helpmenu = Menu(self.menubar, tearoff=0)
......@@ -334,10 +332,6 @@ class Application:
def onExit(self):
self.window.quit()
#Edit
def onPreferences(self):
print("Preferences!")
#Help
def onAbout(self):
about = Toplevel(self.window)
......@@ -366,7 +360,6 @@ class Application:
def onRotate(self):
self.options['Rotate'] = np.mod(self.options['Rotate'] + 1, 4)
print("Rotate")
def onSkew(self):
self.options['Skew'] = not self.options['Skew']
......@@ -374,11 +367,9 @@ class Application:
def onvMirror(self):
self.options['vMirror'] = not self.options['vMirror']
print("vMirror")
def onhMirror(self):
self.options['hMirror'] = not self.options['hMirror']
print("hMirror")
def onBlur(self):
self.initBlurOptionsWindow()
......@@ -410,6 +401,8 @@ class Application:
return arr
def refreshStreams(self):
if self.videostreamplaying:
return #Put a pop up window here asking user if they want to close current stream to refresh devices
self.sessionmenu.delete(0, len(self.availableStreams))
self.availableStreams = self.getPossibleVideoStreams()
for ind in self.availableStreams:
......@@ -432,7 +425,7 @@ class Application:
self.newwin.protocol("WM_DELETE_WINDOW", self.cleanUpVideo)
def updateVideo(self):
if self.videostreamplaying:
if self.videostreamplaying and not self.videostreampaused:
if self.vid.vidcap.isOpened():
if self.paintbrushOptionsExists:
self.canvas.config(cursor="cross black black")
......@@ -444,6 +437,17 @@ class Application:
self.canvas.create_image(0, 0, image=self.photo, anchor=NW)
self.window.after(self.delay, self.updateVideo)
def onPause(self):
self.videostreampaused = True
self.streamoptionsmenu.entryconfig("Resume", state=NORMAL)
self.streamoptionsmenu.entryconfig("Pause", state=DISABLED)
def onResume(self):
self.videostreampaused = False
self.updateVideo()
self.streamoptionsmenu.entryconfig("Resume", state=DISABLED)
self.streamoptionsmenu.entryconfig("Pause", state=NORMAL)
def cleanUpVideo(self):
self.vid.__del__()
self.newwin.destroy()
......
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