Remove prints, change key mapping
This commit is contained in:
parent
b795713018
commit
cd30da3426
40
main_c.py
40
main_c.py
@ -60,8 +60,9 @@ from send2trash import send2trash
|
|||||||
# X Allow opening and exporting without a camera connected
|
# X Allow opening and exporting without a camera connected
|
||||||
# o Better settings names
|
# o Better settings names
|
||||||
# o webcam support (pygame, win and linux only)
|
# o webcam support (pygame, win and linux only)
|
||||||
# o picam support (picamera2)
|
# X picam support (picamera2)
|
||||||
# o notify export ending
|
# o notify export ending
|
||||||
|
# o Use try/except for picam and pygame lib import
|
||||||
|
|
||||||
running_from_folder = os.path.realpath(__file__)
|
running_from_folder = os.path.realpath(__file__)
|
||||||
alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
|
alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
|
||||||
@ -128,8 +129,6 @@ class KISStopmo(tk.Tk):
|
|||||||
self.screen_w, self.screen_h = project_settings['screen_w'], project_settings['screen_h']
|
self.screen_w, self.screen_h = project_settings['screen_w'], project_settings['screen_h']
|
||||||
self.framerate = project_settings['framerate']
|
self.framerate = project_settings['framerate']
|
||||||
|
|
||||||
# ~ for setting in camera_settings:
|
|
||||||
# ~ print(setting)
|
|
||||||
# ~ self.photo = None
|
# ~ self.photo = None
|
||||||
self.end_thread = False
|
self.end_thread = False
|
||||||
# Window setup
|
# Window setup
|
||||||
@ -214,16 +213,16 @@ class KISStopmo(tk.Tk):
|
|||||||
# Key binding
|
# Key binding
|
||||||
root.bind("<Escape>", lambda event: root.attributes("-fullscreen", False))
|
root.bind("<Escape>", lambda event: root.attributes("-fullscreen", False))
|
||||||
root.bind("<f>", lambda event: root.attributes("-fullscreen", True))
|
root.bind("<f>", lambda event: root.attributes("-fullscreen", True))
|
||||||
root.bind("<n>", self.next_frame)
|
root.bind("<e>", self.next_frame)
|
||||||
root.bind("<b>", self.previous_frame)
|
root.bind("<j>", self.previous_frame)
|
||||||
root.bind("<B>", self.toggle_onionskin)
|
root.bind("<J>", self.toggle_onionskin)
|
||||||
root.bind("<N>", self.preview_animation)
|
root.bind("<N>", self.preview_animation)
|
||||||
root.bind("<e>", self.trigger_export_animation)
|
root.bind("<E>", self.trigger_export_animation)
|
||||||
root.bind("<d>", self.remove_frame)
|
root.bind("<d>", self.remove_frame)
|
||||||
# ~ root.bind("<a>", self.print_imglist)
|
# ~ root.bind("<a>", self.print_imglist)
|
||||||
|
|
||||||
if project_settings['trigger_mode'] != 'event':
|
if project_settings['trigger_mode'] != 'event':
|
||||||
root.bind("<j>", self.capture_image)
|
root.bind("<n>", self.capture_image)
|
||||||
|
|
||||||
|
|
||||||
def check_config(self):
|
def check_config(self):
|
||||||
@ -343,7 +342,6 @@ class KISStopmo(tk.Tk):
|
|||||||
existing_animation_files = self.img_list
|
existing_animation_files = self.img_list
|
||||||
# ~ existing_animation_files =
|
# ~ existing_animation_files =
|
||||||
file_list = os.listdir(folder)
|
file_list = os.listdir(folder)
|
||||||
# ~ print(file_list)
|
|
||||||
for file in file_list:
|
for file in file_list:
|
||||||
if (file.startswith(self.project_letter) and file.endswith(project_settings['file_extension'])):
|
if (file.startswith(self.project_letter) and file.endswith(project_settings['file_extension'])):
|
||||||
if file not in existing_animation_files:
|
if file not in existing_animation_files:
|
||||||
@ -377,7 +375,6 @@ class KISStopmo(tk.Tk):
|
|||||||
frame_list = self.get_frames_list(folder)
|
frame_list = self.get_frames_list(folder)
|
||||||
counter = (".%04i." % x for x in count(0))
|
counter = (".%04i." % x for x in count(0))
|
||||||
# ~ for i in range(len(frame_list)):
|
# ~ for i in range(len(frame_list)):
|
||||||
# ~ print(frame_list)
|
|
||||||
for i in frame_list.keys():
|
for i in frame_list.keys():
|
||||||
# ~ if os.path.exists(os.path.realpath(frame_list[i])):
|
# ~ if os.path.exists(os.path.realpath(frame_list[i])):
|
||||||
if os.path.exists(os.path.join(folder, i)):
|
if os.path.exists(os.path.join(folder, i)):
|
||||||
@ -409,7 +406,6 @@ class KISStopmo(tk.Tk):
|
|||||||
if not os.path.exists(frame_path):
|
if not os.path.exists(frame_path):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# ~ print(self.img_list)
|
|
||||||
print(_("Removing {}").format(frame_path))
|
print(_("Removing {}").format(frame_path))
|
||||||
# trash file
|
# trash file
|
||||||
send2trash(frame_path)
|
send2trash(frame_path)
|
||||||
@ -419,15 +415,10 @@ class KISStopmo(tk.Tk):
|
|||||||
self.offset_dictvalues(self.img_index)
|
self.offset_dictvalues(self.img_index)
|
||||||
# rename files and get new list
|
# rename files and get new list
|
||||||
self.img_list = self.batch_rename(folder_path)
|
self.img_list = self.batch_rename(folder_path)
|
||||||
print(self.img_list)
|
|
||||||
self.clean_img_list(folder_path)
|
self.clean_img_list(folder_path)
|
||||||
# ~ print(self.img_list)
|
|
||||||
# update index if possible
|
# update index if possible
|
||||||
# ~ print(self.img_index)
|
|
||||||
self.img_index = self.check_range(self.img_index, False)
|
self.img_index = self.check_range(self.img_index, False)
|
||||||
# ~ print(self.img_index)
|
|
||||||
# update display
|
# update display
|
||||||
# ~ print(self.img_index)
|
|
||||||
self.update_image(None, self.img_index)
|
self.update_image(None, self.img_index)
|
||||||
|
|
||||||
# ~ def open_jpg(self, filepath:str, w:int, h:int):
|
# ~ def open_jpg(self, filepath:str, w:int, h:int):
|
||||||
@ -435,10 +426,7 @@ class KISStopmo(tk.Tk):
|
|||||||
# If pic not cached
|
# If pic not cached
|
||||||
if filetuple[-1] is None:
|
if filetuple[-1] is None:
|
||||||
try:
|
try:
|
||||||
# ~ image = Image.open(filepath)
|
|
||||||
# ~ print( filetuple[0] + "is not in cache")
|
|
||||||
image = Image.open(os.path.join(self.savepath, filetuple[0]))
|
image = Image.open(os.path.join(self.savepath, filetuple[0]))
|
||||||
# ~ image = image.resize((w, h),reducing_gap=1.5)
|
|
||||||
image = ImageOps.fit(image, (w, h))
|
image = ImageOps.fit(image, (w, h))
|
||||||
if vflip:
|
if vflip:
|
||||||
image = image.transpose(Image.Transpose.FLIP_TOP_BOTTOM)
|
image = image.transpose(Image.Transpose.FLIP_TOP_BOTTOM)
|
||||||
@ -448,16 +436,9 @@ class KISStopmo(tk.Tk):
|
|||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
# ~ print( filetuple[0] + "is in cache")
|
|
||||||
image = filetuple[-1]
|
image = filetuple[-1]
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
|
||||||
# ~ def inc(self, x):
|
|
||||||
# ~ if x >= len(self.img_list)-1:
|
|
||||||
# ~ return 0
|
|
||||||
# ~ else:
|
|
||||||
# ~ return x + 1
|
|
||||||
|
|
||||||
def check_range(self, x, loop=True):
|
def check_range(self, x, loop=True):
|
||||||
if x < 0:
|
if x < 0:
|
||||||
@ -510,7 +491,6 @@ class KISStopmo(tk.Tk):
|
|||||||
if self.onion_skin:
|
if self.onion_skin:
|
||||||
if index:
|
if index:
|
||||||
photo = self.apply_onionskin(new_image, project_settings['onionskin_alpha_default'], project_settings['onionskin_fx'])
|
photo = self.apply_onionskin(new_image, project_settings['onionskin_alpha_default'], project_settings['onionskin_fx'])
|
||||||
# ~ print(photo)
|
|
||||||
self.label.configure(image=photo)
|
self.label.configure(image=photo)
|
||||||
self.label.image = photo
|
self.label.image = photo
|
||||||
return new_image
|
return new_image
|
||||||
@ -658,7 +638,6 @@ class KISStopmo(tk.Tk):
|
|||||||
print(speed)
|
print(speed)
|
||||||
print(str(current_lightmeter_value) + " - " + str(current_shutterspeed_value))
|
print(str(current_lightmeter_value) + " - " + str(current_shutterspeed_value))
|
||||||
return True
|
return True
|
||||||
# ~ print(str(current_lightmeter_value) + " - " + str(current_shutterspeed_value))
|
|
||||||
|
|
||||||
def capture_image(self, event=None, event_data=None):
|
def capture_image(self, event=None, event_data=None):
|
||||||
# get net file name based on prefix, file count and extension
|
# get net file name based on prefix, file count and extension
|
||||||
@ -673,7 +652,6 @@ class KISStopmo(tk.Tk):
|
|||||||
else:
|
else:
|
||||||
# Get file from DSLR camera
|
# Get file from DSLR camera
|
||||||
if event_data is None:
|
if event_data is None:
|
||||||
# ~ print("j pressed")
|
|
||||||
new_frame_path = self.camera.capture(gp.GP_CAPTURE_IMAGE)
|
new_frame_path = self.camera.capture(gp.GP_CAPTURE_IMAGE)
|
||||||
# ~ self.camera.trigger_capture()
|
# ~ self.camera.trigger_capture()
|
||||||
new_frame = self.camera.file_get(
|
new_frame = self.camera.file_get(
|
||||||
@ -685,9 +663,7 @@ class KISStopmo(tk.Tk):
|
|||||||
event_data.folder, event_data.name, gp.GP_FILE_TYPE_NORMAL)
|
event_data.folder, event_data.name, gp.GP_FILE_TYPE_NORMAL)
|
||||||
new_frame.save(target_path)
|
new_frame.save(target_path)
|
||||||
# ~ next_filename = prefix+next(filename)+ext
|
# ~ next_filename = prefix+next(filename)+ext
|
||||||
# ~ print(self.img_list)
|
|
||||||
if '{letter}.-001.JPG'.format(letter=self.project_letter) in self.img_list:
|
if '{letter}.-001.JPG'.format(letter=self.project_letter) in self.img_list:
|
||||||
# ~ self.img_list.pop('A.-001.JPG')
|
|
||||||
self.img_list.pop('{letter}.-001.JPG'.format(letter=self.project_letter))
|
self.img_list.pop('{letter}.-001.JPG'.format(letter=self.project_letter))
|
||||||
# Display new frame
|
# Display new frame
|
||||||
self.display_last_frame()
|
self.display_last_frame()
|
||||||
@ -699,7 +675,6 @@ class KISStopmo(tk.Tk):
|
|||||||
return
|
return
|
||||||
event_type, event_data = self.camera.wait_for_event(self.timeout)
|
event_type, event_data = self.camera.wait_for_event(self.timeout)
|
||||||
if event_type == gp.GP_EVENT_FILE_ADDED:
|
if event_type == gp.GP_EVENT_FILE_ADDED:
|
||||||
# ~ print("file added")
|
|
||||||
self.capture_image(None, event_data)
|
self.capture_image(None, event_data)
|
||||||
# ~ root.after(self.timeout, self.wait_for_capture)
|
# ~ root.after(self.timeout, self.wait_for_capture)
|
||||||
self.wait_for_capture()
|
self.wait_for_capture()
|
||||||
@ -724,7 +699,6 @@ class KISStopmo(tk.Tk):
|
|||||||
|
|
||||||
def trigger_export_animation(self, event):
|
def trigger_export_animation(self, event):
|
||||||
# ~ output_folder = filedialog.askdirectory()
|
# ~ output_folder = filedialog.askdirectory()
|
||||||
# TODO : Check what happens when closing the window without entering a name
|
|
||||||
self.export_filename = ()
|
self.export_filename = ()
|
||||||
self.export_filename = filedialog.asksaveasfilename(defaultextension='.mp4', filetypes=((_("Mp4 files"), '*.mp4'),))
|
self.export_filename = filedialog.asksaveasfilename(defaultextension='.mp4', filetypes=((_("Mp4 files"), '*.mp4'),))
|
||||||
if not self.export_filename:
|
if not self.export_filename:
|
||||||
|
Loading…
Reference in New Issue
Block a user