Commit 717bfffc authored by Kieran Hymas's avatar Kieran Hymas

Fixed several bugs with saving snapshot and now snapshot save dialog opens in...

Fixed several bugs with saving snapshot and now snapshot save dialog opens in directory where previous save occured
parent bec3dfbf
......@@ -6,10 +6,12 @@ from tkinter import filedialog
from PIL import Image, ImageTk
import numpy as np
import cv2
import os
#Classes
class Application:
def __init__(self, window):
self.wd = os.path.expanduser('~')
self.window = window
self.window.title("Pycroscope")
self.width = self.window.winfo_screenwidth()
......@@ -228,7 +230,10 @@ class Application:
ret, frame = self.vid.get_frame(self.options)
if ret:
newframe = cv2.cvtColor(frame,cv2.COLOR_RGB2BGR)
path = tk.filedialog.asksaveasfilename()
path = tk.filedialog.asksaveasfilename(title="Pycroscope: save screenshot", defaultextension=".png", initialdir=self.wd)
if path == () or path == '' or path == False:
return
self.wd = '/'.join(path.split('/')[:-1]) + '/'
cv2.imwrite(path, newframe)
else:
print("[-] Error: something went wrong.")
......
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