CTkScrollableDropdownPP 2.1.2__tar.gz → 2.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ class CTkScrollableDropdown(customtkinter.CTkToplevel):
10
10
  command=None, image_values=[], alpha: float = 0.95, frame_corner_radius=20, double_click=False,
11
11
  frame_border_color=None, text_color=None, autocomplete=False,
12
12
  hover_color=None, pagination: bool = True, items_per_page: int = 50,
13
- groups=None, font=("Segoe UI", 12), **button_kwargs):
13
+ groups=None, font=("Segoe UI", 12), fade_in_duration: bool = True, fps: int = 60, **button_kwargs):
14
14
  super().__init__(master=attach.winfo_toplevel(), takefocus=1)
15
15
 
16
16
  self.group_patterns = None
@@ -39,6 +39,10 @@ class CTkScrollableDropdown(customtkinter.CTkToplevel):
39
39
  self.current_group = 0
40
40
  self.font = font
41
41
  self.groups = []
42
+ self.fade_enabled = fade_in_duration
43
+ self.fps = max(1, int(fps))
44
+ self.fade_animation_duration = 0.25
45
+ self.animating = False
42
46
 
43
47
  if groups is not None:
44
48
  for g in groups:
@@ -188,7 +192,7 @@ class CTkScrollableDropdown(customtkinter.CTkToplevel):
188
192
  if self.autocomplete:
189
193
  self.bind_autocomplete()
190
194
  self.withdraw()
191
- self.attributes("-alpha", self.alpha)
195
+ self.attributes("-alpha", 0)
192
196
  if self.groups:
193
197
  self.switch_group(0)
194
198
  self._init_buttons()
@@ -275,10 +279,13 @@ class CTkScrollableDropdown(customtkinter.CTkToplevel):
275
279
  self.after(500, self.destroy_popup)
276
280
 
277
281
  def _withdraw(self):
282
+ if self.animating:
283
+ return
278
284
  if not self.winfo_exists():
279
285
  return
280
286
  if self.winfo_viewable() and self.hide_flag:
281
- self.withdraw()
287
+ self._animated_withdraw()
288
+ return
282
289
  self.event_generate("<<Closed>>")
283
290
  self.hide_flag = True
284
291
 
@@ -382,12 +389,17 @@ class CTkScrollableDropdown(customtkinter.CTkToplevel):
382
389
  or current_x_pos != self.x_pos
383
390
  or current_y_pos != self.y_pos):
384
391
  self.geometry(f"{self.width_new}x{self.height_new}+{self.x_pos}+{self.y_pos}")
385
- self.attributes('-alpha', self.alpha)
392
+ if self.fade_enabled:
393
+ self.attributes('-alpha', 0)
394
+ else:
395
+ self.attributes('-alpha', self.alpha)
386
396
  self.update_idletasks()
387
397
  if self.pagination:
388
398
  self._update_pagination_buttons(filtered=bool(self.filtered_values))
389
399
 
390
400
  def _iconify(self):
401
+ if self.animating:
402
+ return
391
403
  if self.attach.cget("state") == "disabled":
392
404
  return
393
405
  if self.disable:
@@ -401,10 +413,12 @@ class CTkScrollableDropdown(customtkinter.CTkToplevel):
401
413
  self.place_dropdown()
402
414
  self._deiconify()
403
415
  else:
404
- self.withdraw()
416
+ self._animated_withdraw()
405
417
  self.hide_flag = True
406
418
 
407
419
  def _attach_key_press(self, k):
420
+ if self.animating:
421
+ return
408
422
  if hasattr(self, "search_var"):
409
423
  self.search_var.set("")
410
424
  self.event_generate("<<Selected>>")
@@ -418,11 +432,11 @@ class CTkScrollableDropdown(customtkinter.CTkToplevel):
418
432
  if self.pagination:
419
433
  self.pagination_frame.pack(fill="x", side="bottom")
420
434
  self.fade = False
421
- self.withdraw()
435
+ self._animated_withdraw()
422
436
  self.hide_flag = True
423
437
 
424
438
  def live_update(self, string=None):
425
- if self.disable or self.fade:
439
+ if self.disable or self.fade or self.animating:
426
440
  return
427
441
  self.frame._parent_canvas.yview_moveto(0)
428
442
  if string and string.strip() != "":
@@ -480,7 +494,14 @@ class CTkScrollableDropdown(customtkinter.CTkToplevel):
480
494
 
481
495
  def _deiconify(self):
482
496
  if self.all_values:
483
- self.deiconify()
497
+ if self.fade_enabled:
498
+ if self.animating:
499
+ return
500
+ self.deiconify()
501
+ self._animate_fade_in()
502
+ else:
503
+ self.deiconify()
504
+ self.attributes('-alpha', self.alpha)
484
505
 
485
506
  def popup(self, x=None, y=None):
486
507
  self.x = x
@@ -582,3 +603,74 @@ class CTkScrollableDropdown(customtkinter.CTkToplevel):
582
603
  self.widgets[key][0].configure(**kwargs)
583
604
  self.old_kwargs = kwargs
584
605
  self.master.update()
606
+
607
+ def _animate_fade_in(self):
608
+ if not self.fade_enabled:
609
+ self.attributes('-alpha', self.alpha)
610
+ return
611
+ if self.animating:
612
+ return
613
+ self.animating = True
614
+ total_frames = max(1, int(self.fps * self.fade_animation_duration))
615
+ step = float(self.alpha) / total_frames
616
+ current = 0.0
617
+ interval = max(1, int(1000 / self.fps))
618
+ def step_fn(frame, value):
619
+ new_value = value + step
620
+ if new_value >= self.alpha or frame >= total_frames - 1:
621
+ try:
622
+ self.attributes('-alpha', self.alpha)
623
+ finally:
624
+ self.animating = False
625
+ return
626
+ try:
627
+ self.attributes('-alpha', new_value)
628
+ except Exception:
629
+ pass
630
+ self.after(interval, lambda: step_fn(frame + 1, new_value))
631
+ try:
632
+ self.attributes('-alpha', 0.0)
633
+ except Exception:
634
+ pass
635
+ step_fn(0, current)
636
+
637
+ def _animated_withdraw(self):
638
+ if not self.winfo_exists():
639
+ return
640
+ if not self.fade_enabled:
641
+ if self.winfo_viewable():
642
+ self.withdraw()
643
+ self.event_generate("<<Closed>>")
644
+ self.hide_flag = True
645
+ return
646
+ if self.animating:
647
+ return
648
+ self.animating = True
649
+ total_frames = max(1, int(self.fps * self.fade_animation_duration))
650
+ step = float(self.alpha) / total_frames
651
+ interval = max(1, int(1000 / self.fps))
652
+ current_alpha = None
653
+ try:
654
+ current_alpha = float(self.attributes('-alpha'))
655
+ except Exception:
656
+ current_alpha = self.alpha
657
+ def step_fn(frame, value):
658
+ new_value = value - step
659
+ if new_value <= 0 or frame >= total_frames - 1:
660
+ try:
661
+ self.attributes('-alpha', 0.0)
662
+ finally:
663
+ try:
664
+ if self.winfo_viewable():
665
+ self.withdraw()
666
+ finally:
667
+ self.event_generate("<<Closed>>")
668
+ self.hide_flag = True
669
+ self.animating = False
670
+ return
671
+ try:
672
+ self.attributes('-alpha', new_value)
673
+ except Exception:
674
+ pass
675
+ self.after(interval, lambda: step_fn(frame + 1, new_value))
676
+ step_fn(0, current_alpha)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: CTkScrollableDropdownPP
3
- Version: 2.1.2
3
+ Version: 2.1.3
4
4
  Summary: Enhanced CTkScrollableDropdown with pagination, search and groups support
5
5
  Author: PLauncher-Team, Akash Bora
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: CTkScrollableDropdownPP
3
- Version: 2.1.2
3
+ Version: 2.1.3
4
4
  Summary: Enhanced CTkScrollableDropdown with pagination, search and groups support
5
5
  Author: PLauncher-Team, Akash Bora
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "CTkScrollableDropdownPP"
7
- version = "2.1.2"
7
+ version = "2.1.3"
8
8
  description = "Enhanced CTkScrollableDropdown with pagination, search and groups support"
9
9
  authors = [
10
10
  {name = "PLauncher-Team"},