|
|
|
|
@ -5,7 +5,7 @@ from tkinter.ttk import * |
|
|
|
|
import os |
|
|
|
|
from PIL import Image |
|
|
|
|
|
|
|
|
|
VERSIONSTRING = "1.0.2" |
|
|
|
|
VERSIONSTRING = "1.0.3" |
|
|
|
|
|
|
|
|
|
class ProjectLiferFrame(Frame): |
|
|
|
|
files = list() |
|
|
|
|
@ -14,55 +14,69 @@ class ProjectLiferFrame(Frame): |
|
|
|
|
|
|
|
|
|
ttk.Frame.__init__(self, root) |
|
|
|
|
|
|
|
|
|
# define buttonframe |
|
|
|
|
self.buttonframe = Frame(self) |
|
|
|
|
self.butdirchooser = Button(self.buttonframe, text='Verzeichnis wählen', command=self.askdirectory) |
|
|
|
|
self.dirtext = Label(self.buttonframe, wraplength=150, width=10,anchor=W, justify=LEFT) |
|
|
|
|
self.butselall = Button(self.buttonframe, text='Alle wählen', command=self.select_all) |
|
|
|
|
self.butselnone = Button(self.buttonframe, text='Keine wählen', command=self.select_none) |
|
|
|
|
self.butcombine = Button(self.buttonframe, text='Kombiniere Bilder', command=self.combine_pictures) |
|
|
|
|
# define frame_actionbuttons |
|
|
|
|
self.frame_actionbuttons = Frame(self) |
|
|
|
|
|
|
|
|
|
photo_folder = PhotoImage(file="data/folder.png") |
|
|
|
|
photo_gears = PhotoImage(file="data/gears.png") |
|
|
|
|
|
|
|
|
|
self.button_choosedirectory = Button(self.frame_actionbuttons, compound=TOP, text='Verzeichnis wählen', image=photo_folder, command=self.askdirectory) |
|
|
|
|
self.button_choosedirectory.image = photo_folder |
|
|
|
|
self.button_docombine = Button(self.frame_actionbuttons, compound=TOP, text='Kombiniere Bilder', image=photo_gears, command=self.combine_pictures) |
|
|
|
|
self.button_docombine.image = photo_gears |
|
|
|
|
|
|
|
|
|
# define listbox and scrollbar |
|
|
|
|
self.label_currentdirectory = Label(self, text="Kein Ordner ausgewählt", wraplength=550, anchor=W, justify=LEFT, padding = (0, 5, 0, 0)) |
|
|
|
|
self.listbox = Listbox(self, selectmode=MULTIPLE) |
|
|
|
|
self.scrollbar = Scrollbar(self.listbox, orient=VERTICAL) |
|
|
|
|
|
|
|
|
|
# define selector_button_frame and buttons |
|
|
|
|
self.frame_selector_buttons = Frame(self) |
|
|
|
|
self.button_selectall = Button(self.frame_selector_buttons, text='Alle wählen', command=self.select_all) |
|
|
|
|
self.button_selectnone = Button(self.frame_selector_buttons, text='Keine wählen', command=self.select_none) |
|
|
|
|
|
|
|
|
|
# configure listbox and scrollbar |
|
|
|
|
self.listbox.config(yscrollcommand=self.scrollbar.set) |
|
|
|
|
self.scrollbar.config(command=self.listbox.yview) |
|
|
|
|
|
|
|
|
|
self.bottom_hbar = Separator(self,orient=HORIZONTAL) |
|
|
|
|
self.separator_bottom = Separator(self, orient=HORIZONTAL) |
|
|
|
|
|
|
|
|
|
# define progressframe |
|
|
|
|
self.pframe = Frame(self) |
|
|
|
|
self.frame_progressbar = Frame(self) |
|
|
|
|
|
|
|
|
|
# define Progresstext |
|
|
|
|
self.ptext = Label(self.pframe, text='', width=10, anchor=W) |
|
|
|
|
self.label_progressbar = Label(self.frame_progressbar, text='', width=10, anchor=W) |
|
|
|
|
|
|
|
|
|
# define ProgressBar |
|
|
|
|
self.pbar = Progressbar(self.pframe) |
|
|
|
|
self.progressbar = Progressbar(self.frame_progressbar) |
|
|
|
|
|
|
|
|
|
# layout buttonframe |
|
|
|
|
self.buttonframe.grid(row=0, column=0, sticky=N, padx=5, pady=5) |
|
|
|
|
self.butdirchooser.grid(row=0, column=0,columnspan=2, sticky=N + W + E, pady=5) |
|
|
|
|
self.dirtext.grid(row=1, column=0, columnspan=2, sticky=W +E, pady=5) |
|
|
|
|
self.butselall.grid(row=2, column=0, sticky=N, pady=5) |
|
|
|
|
self.butselnone.grid(row=2, column=1, sticky=N, pady=5) |
|
|
|
|
self.butcombine.grid(row=3, columnspan=2, sticky=N + W + E, pady=5) |
|
|
|
|
# layout frame_actionbuttons |
|
|
|
|
self.frame_actionbuttons.grid(row=0, column=0, rowspan=2, sticky=N, padx=5, pady=5) |
|
|
|
|
self.button_choosedirectory.grid(row=0, column=0, columnspan=2, sticky=N + W + E) |
|
|
|
|
self.button_docombine.grid(row=3, columnspan=2, sticky=N + W + E, pady=5) |
|
|
|
|
|
|
|
|
|
# layout listbox and scrollbar |
|
|
|
|
self.label_currentdirectory.grid(row=0, column=1, sticky=W + E, padx=5) |
|
|
|
|
self.listbox.columnconfigure(0, weight=1) |
|
|
|
|
self.listbox.rowconfigure(0, weight=1) |
|
|
|
|
self.listbox.grid(row=0, column=1, sticky=W + E + N + S, pady=5, padx=5) |
|
|
|
|
self.listbox.grid(row=1, column=1, sticky=W + E + N + S, pady=5, padx=5) |
|
|
|
|
self.scrollbar.grid(column=1, sticky=N + S) |
|
|
|
|
|
|
|
|
|
# layout frame_selector_buttons |
|
|
|
|
self.frame_selector_buttons.grid(row=2, column=1, sticky=W + E, padx=5) |
|
|
|
|
self.frame_selector_buttons.columnconfigure(0, weight=1) |
|
|
|
|
self.frame_selector_buttons.columnconfigure(1, weight=1) |
|
|
|
|
self.button_selectall.grid(row=0, column=0, sticky=N + E + W, pady=5) |
|
|
|
|
self.button_selectnone.grid(row=0, column=1, sticky=N + E + W, pady=5) |
|
|
|
|
|
|
|
|
|
# Horizontal Bar |
|
|
|
|
self.bottom_hbar.grid(row=1, columnspan=2, sticky=W + E) |
|
|
|
|
self.separator_bottom.grid(row=3, columnspan=2, sticky=W + E) |
|
|
|
|
|
|
|
|
|
# layout progressbar and text |
|
|
|
|
self.pframe.columnconfigure(1,weight=1) |
|
|
|
|
self.pframe.grid(row=2, column=0, columnspan=2, sticky=W+E+N+S, pady=5, padx=5) |
|
|
|
|
self.ptext.grid(row=0, column=0, sticky=W) |
|
|
|
|
self.pbar.grid(row=0, column=1, sticky=W + E + N + S) |
|
|
|
|
self.frame_progressbar.columnconfigure(1, weight=1) |
|
|
|
|
self.frame_progressbar.grid(row=4, column=0, columnspan=2, sticky=W + E + N + S, pady=5, padx=5) |
|
|
|
|
self.label_progressbar.grid(row=0, column=0, sticky=W) |
|
|
|
|
self.progressbar.grid(row=0, column=1, sticky=W + E + N + S) |
|
|
|
|
|
|
|
|
|
# defining options for opening a directory |
|
|
|
|
self.dir_opt = options = {} |
|
|
|
|
@ -70,10 +84,8 @@ class ProjectLiferFrame(Frame): |
|
|
|
|
options['mustexist'] = False |
|
|
|
|
options['parent'] = root |
|
|
|
|
options['title'] = 'Ordner auswählen' |
|
|
|
|
self.columnconfigure(0, weight=0) |
|
|
|
|
self.columnconfigure(1, weight=1) |
|
|
|
|
self.rowconfigure(0, weight=1) |
|
|
|
|
#self.rowconfigure(1, weight=0) |
|
|
|
|
self.rowconfigure(1, weight=1) |
|
|
|
|
|
|
|
|
|
def combine_pictures(self): |
|
|
|
|
|
|
|
|
|
@ -83,8 +95,8 @@ class ProjectLiferFrame(Frame): |
|
|
|
|
|
|
|
|
|
max = int(round(len(items) / 2)) |
|
|
|
|
current = 0 |
|
|
|
|
self.pbar["value"] = current |
|
|
|
|
self.pbar["maximum"] = max |
|
|
|
|
self.progressbar["value"] = current |
|
|
|
|
self.progressbar["maximum"] = max |
|
|
|
|
root.update_idletasks() |
|
|
|
|
items = iter(items) |
|
|
|
|
|
|
|
|
|
@ -109,11 +121,11 @@ class ProjectLiferFrame(Frame): |
|
|
|
|
new_im.save(self.folder + os.path.sep + '{}_and_{}.jpg'.format(imgname1, imgname2)) |
|
|
|
|
|
|
|
|
|
current += 1 |
|
|
|
|
self.pbar["value"] = current |
|
|
|
|
self.ptext["text"] = '{}/{}'.format(current, max) |
|
|
|
|
self.progressbar["value"] = current |
|
|
|
|
self.label_progressbar["text"] = '{}/{}'.format(current, max) |
|
|
|
|
root.update_idletasks() |
|
|
|
|
self.ptext["text"] = 'Done!' |
|
|
|
|
self.pbar["value"] = 0 |
|
|
|
|
self.label_progressbar["text"] = 'Done!' |
|
|
|
|
self.progressbar["value"] = 0 |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
@ -135,7 +147,7 @@ class ProjectLiferFrame(Frame): |
|
|
|
|
self.listbox.delete(0, END) |
|
|
|
|
self.files.clear() |
|
|
|
|
self.folder = filedialog.askdirectory(**self.dir_opt) |
|
|
|
|
self.dirtext['text'] = self.folder |
|
|
|
|
self.label_currentdirectory['text'] = self.folder |
|
|
|
|
for file in os.listdir(self.folder): |
|
|
|
|
pathfile = os.path.join(self.folder, file) |
|
|
|
|
if os.path.isfile(pathfile): |
|
|
|
|
|