Skip to content

Commit 769f2cd

Browse files
committed
Add Gallery functions
Added update and remove gallery funtions.
1 parent e753643 commit 769f2cd

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

uiplib/gui/gallery.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,31 @@ def show_image(self, image):
5555
def _blur_helper(self, event):
5656
"""Helper to schedule the blur_image task."""
5757
if self._job:
58-
self.appObj.after_cancel(self._job)
59-
self._job = self.appObj.after(250, self.blur_image)
58+
self.appObj.root.after_cancel(self._job)
59+
self._job = self.appObj.root.after(250, self.blur_image)
6060

6161
def blur_image(self):
6262
"""Apply blur to the chosen image."""
6363
show = self.image.blur(self.slider.get())
6464
self.show_image(show)
65+
66+
def update(self):
67+
"""Update the gallery."""
68+
appObj = self.appObj
69+
70+
gallery_remove(self.label)
71+
gallery_remove(self.cv)
72+
gallery_remove(self.slider)
73+
74+
if len(appObj.images) != 0:
75+
self.set_image(
76+
appObj.images[(appObj.index) % len(appObj.images)])
77+
else:
78+
self.show_error()
79+
80+
81+
def gallery_remove(object):
82+
"""Remove object from gallery if exists."""
83+
if object:
84+
object.pack_forget()
85+
object = None

uiplib/gui/generalTab.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ def create_general_tab(appObj):
4242
appObj.progress = 0
4343
appObj.progressBar = None
4444

45-
appObj.gallery = Gallery(mainFrame, appObj.root)
45+
appObj.gallery = Gallery(mainFrame, appObj)
4646
appObj.gallery.pack(fill=BOTH)
47-
if len(appObj.images) != 0:
48-
appObj.gallery.set_image(appObj.images[appObj.index])
49-
else:
50-
appObj.gallery.show_error()
47+
48+
appObj.gallery.update()
5149

5250
# Add Play Button to start.
5351
playBtn = Button(

0 commit comments

Comments
 (0)