add label to progressbar

empty progressbar after done
master
Herr L 9 years ago
parent da61df86be
commit ca1ff65881
  1. 2
      .idea/markdown-navigator/profiles_settings.xml
  2. 49
      ProjectLifer.py

@ -1,3 +1,3 @@
<component name="MarkdownNavigator.ProfileManager"> <component name="MarkdownNavigator.ProfileManager">
<settings default="" /> <settings default="" pdf-export="" />
</component> </component>

@ -18,25 +18,41 @@ class ProjectLiferFrame(Frame):
self.butselall = Button(self, text='Alle wählen', command=self.select_all) self.butselall = Button(self, text='Alle wählen', command=self.select_all)
self.butselnone = Button(self, text='Keine wählen', command=self.select_none) self.butselnone = Button(self, text='Keine wählen', command=self.select_none)
# define ProgressBar # define listbox and scrollbar
self.pbar = Progressbar(self)
self.listbox = Listbox(self, selectmode=MULTIPLE) self.listbox = Listbox(self, selectmode=MULTIPLE)
self.scrollbar = Scrollbar(self.listbox, orient=VERTICAL) self.scrollbar = Scrollbar(self.listbox, orient=VERTICAL)
# configure listbox and scrollbar
self.listbox.config(yscrollcommand=self.scrollbar.set) self.listbox.config(yscrollcommand=self.scrollbar.set)
self.scrollbar.config(command=self.listbox.yview) self.scrollbar.config(command=self.listbox.yview)
self.butcombine.grid(row=0, rowspan=2, columnspan=2, sticky=W + E + N + S, padx=5, pady=5) # define progressframe
self.butdirchooser.grid(row=2, columnspan=2, padx=5, pady=5) self.pframe = Frame(self)
self.butselall.grid(row=3, column=0)
self.butselnone.grid(row=3, column=1) # define Progresstext
self.pbar.grid(row=4, columnspan=3, sticky=W + E + N + S, pady=5, padx=5) self.ptext = Label(self.pframe, text='', width=10, anchor=W)
self.listbox.grid(column=2, row=0, rowspan=4, columnspan=2, sticky=W + E + N + S, pady=5, padx=5)
# define ProgressBar
self.pbar = Progressbar(self.pframe)
# layout buttons
self.butcombine.grid(row=0, columnspan=2, sticky=W + E + N + S, padx=5, pady=5)
self.butdirchooser.grid(row=1, columnspan=2, padx=5, pady=5)
self.butselall.grid(row=2, column=0)
self.butselnone.grid(row=2, column=1)
# layout listbox and scrollbar
self.listbox.columnconfigure(0, weight=1) self.listbox.columnconfigure(0, weight=1)
self.listbox.rowconfigure(0, weight=1) self.listbox.rowconfigure(0, weight=1)
self.listbox.grid(row=0, column=2, rowspan=3, columnspan=2, sticky=W + E + N + S, pady=5, padx=5)
self.scrollbar.grid(column=1, sticky=N + S) self.scrollbar.grid(column=1, sticky=N + S)
# layout progressbar and text
self.pframe.columnconfigure(1,weight=1)
self.pframe.grid(row=3, column=0, columnspan=5, 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)
# defining options for opening a directory # defining options for opening a directory
self.dir_opt = options = {} self.dir_opt = options = {}
options['initialdir'] = 'C:\\' options['initialdir'] = 'C:\\'
@ -49,7 +65,6 @@ class ProjectLiferFrame(Frame):
self.rowconfigure(0, weight=5) self.rowconfigure(0, weight=5)
self.rowconfigure(1, weight=1) self.rowconfigure(1, weight=1)
self.rowconfigure(2, weight=1) self.rowconfigure(2, weight=1)
self.rowconfigure(3, weight=1)
def combine_pictures(self): def combine_pictures(self):
@ -57,8 +72,10 @@ class ProjectLiferFrame(Frame):
items = self.listbox.curselection() items = self.listbox.curselection()
items = [self.files[int(item)] for item in items] items = [self.files[int(item)] for item in items]
self.pbar["value"] = 0 max = int(round(len(items) / 2))
self.pbar["maximum"] = int(round(len(items) / 2)) current = 0
self.pbar["value"] = current
self.pbar["maximum"] = max
root.update_idletasks() root.update_idletasks()
items = iter(items) items = iter(items)
@ -82,8 +99,12 @@ class ProjectLiferFrame(Frame):
imgname2 = os.path.splitext(os.path.basename(i2))[0] imgname2 = os.path.splitext(os.path.basename(i2))[0]
new_im.save(self.folder + os.path.sep + '{}_and_{}.jpg'.format(imgname1, imgname2)) new_im.save(self.folder + os.path.sep + '{}_and_{}.jpg'.format(imgname1, imgname2))
self.pbar["value"] += 1 current += 1
self.pbar["value"] = current
self.ptext["text"] = '{}/{}'.format(current, max)
root.update_idletasks() root.update_idletasks()
self.ptext["text"] = 'Done!'
self.pbar["value"] = 0
return return
@ -127,6 +148,6 @@ if __name__ == '__main__':
root.columnconfigure(0, weight=1) root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1) root.rowconfigure(0, weight=1)
root.minsize(700, 500) root.minsize(700, 500)
root.title("ProjectLifer 1.0.1") root.title("ProjectLifer 1.0.2")
ProjectLiferFrame(root).grid(row=0, column=0, sticky=(N, S, E, W)) ProjectLiferFrame(root).grid(row=0, column=0, sticky=(N, S, E, W))
root.mainloop() root.mainloop()

Loading…
Cancel
Save