CTkScrollableDropdownPP 2.0.2__tar.gz → 2.0.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.
@@ -4,11 +4,11 @@ import re
4
4
 
5
5
  class CTkScrollableDropdown(customtkinter.CTkToplevel):
6
6
 
7
- def __init__(self, attach, x=None, y=None, button_color=None, height: int = 55, width: int = None,
7
+ def __init__(self, attach, x=None, y=None, button_color=None, height: int = None, width: int = None,
8
8
  fg_color=None, button_height: int = 20, justify="center", scrollbar_button_color=None,
9
9
  scrollbar=True, scrollbar_button_hover_color=None, frame_border_width=0, values=[],
10
10
  command=None, image_values=[], alpha: float = 0.95, frame_corner_radius=20, double_click=False,
11
- resize=False, frame_border_color=None, text_color=None, autocomplete=False,
11
+ frame_border_color=None, text_color=None, autocomplete=False,
12
12
  hover_color=None, pagination: bool = True, items_per_page: int = 50,
13
13
  groups=None, **button_kwargs):
14
14
  super().__init__(master=attach.winfo_toplevel(), takefocus=1)
@@ -139,12 +139,14 @@ class CTkScrollableDropdown(customtkinter.CTkToplevel):
139
139
  else:
140
140
  self.button_container = self.frame
141
141
  self.dummy_entry = customtkinter.CTkEntry(self.frame, fg_color="transparent", border_width=0, height=1, width=1)
142
- self.height = height
143
- self.height_new = height
142
+ self.is_height = bool(height)
143
+ if height is None:
144
+ self.height_new = attach.winfo_toplevel().winfo_height()
145
+ else:
146
+ self.height_new = height
144
147
  self.width = width
145
148
  self.command = command
146
149
  self.fade = False
147
- self.resize = resize
148
150
  self.autocomplete = autocomplete
149
151
  self.var_update = customtkinter.StringVar()
150
152
  self.appear = True
@@ -342,13 +344,8 @@ class CTkScrollableDropdown(customtkinter.CTkToplevel):
342
344
  current_y_pos = self.winfo_y()
343
345
  self.x_pos = self.attach.winfo_rootx() if self.x is None else self.x + self.attach.winfo_rootx()
344
346
  self.width_new = self.attach.winfo_width() if self.width is None else self.width
345
- if self.resize:
346
- displayed_items = len(self.filtered_values) if self.filtered_values is not None else len(self.values)
347
- if self.pagination:
348
- displayed_items = min(displayed_items, self.items_per_page)
349
- base_height = 50 if self.pagination else 35
350
- items_height = displayed_items * self.button_height
351
- self.height_new = items_height + base_height
347
+ if not self.is_height:
348
+ self.height_new = self.attach.winfo_toplevel().winfo_height()
352
349
  screen_height = self.winfo_screenheight()
353
350
  dropdown_bottom = self.attach.winfo_rooty() + self.height_new
354
351
  if dropdown_bottom > screen_height:
@@ -472,8 +469,7 @@ class CTkScrollableDropdown(customtkinter.CTkToplevel):
472
469
  if self.old_kwargs == kwargs:
473
470
  return
474
471
  if "height" in kwargs:
475
- self.height = kwargs.pop("height")
476
- self.height_new = self.height
472
+ self.height_new = kwargs.pop("height")
477
473
  if "alpha" in kwargs:
478
474
  self.alpha = kwargs.pop("alpha")
479
475
  if "width" in kwargs:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: CTkScrollableDropdownPP
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: Enhanced CTkScrollableDropdown with pagination, search and groups support
5
5
  Author: PLauncher-Team, Akash Bora
6
6
  License: MIT
@@ -39,22 +39,30 @@ pip install ctkscrollabledropdownpp
39
39
 
40
40
  ```python
41
41
  import customtkinter as ctk
42
- from ctkscrollabledropdownpp import CTkScrollableDropdown
42
+ from CTkScrollableDropdownPP import CTkScrollableDropdown
43
43
 
44
44
  app = ctk.CTk()
45
- btn = ctk.CTkButton(app, text='Select')
46
- btn.pack(pady=20)
45
+ app.geometry("400x300")
46
+
47
+ combobox = ctk.CTkComboBox(
48
+ master=app,
49
+ values=[],
50
+ width=200,
51
+ height=30
52
+ )
53
+ combobox.pack(pady=50)
47
54
 
48
55
  values = [f"Item {i}" for i in range(1, 101)]
49
56
 
50
57
  dropdown = CTkScrollableDropdown(
51
- attach=btn,
58
+ attach=combobox,
52
59
  values=values,
53
60
  command=lambda v: print("Selected:", v),
54
- items_per_page=20,
55
- pagination=True,
56
61
  autocomplete=True,
57
- groups=[('1-50', r'^Item [1-4]'), ('Others', '__OTHERS__')]
62
+ groups=[
63
+ ('1-50', r'^Item ([1-9]|[1-4][0-9]|50)$'),
64
+ ('Others', '__OTHERS__')
65
+ ],
58
66
  )
59
67
 
60
68
  app.mainloop()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: CTkScrollableDropdownPP
3
- Version: 2.0.2
3
+ Version: 2.0.3
4
4
  Summary: Enhanced CTkScrollableDropdown with pagination, search and groups support
5
5
  Author: PLauncher-Team, Akash Bora
6
6
  License: MIT
@@ -39,22 +39,30 @@ pip install ctkscrollabledropdownpp
39
39
 
40
40
  ```python
41
41
  import customtkinter as ctk
42
- from ctkscrollabledropdownpp import CTkScrollableDropdown
42
+ from CTkScrollableDropdownPP import CTkScrollableDropdown
43
43
 
44
44
  app = ctk.CTk()
45
- btn = ctk.CTkButton(app, text='Select')
46
- btn.pack(pady=20)
45
+ app.geometry("400x300")
46
+
47
+ combobox = ctk.CTkComboBox(
48
+ master=app,
49
+ values=[],
50
+ width=200,
51
+ height=30
52
+ )
53
+ combobox.pack(pady=50)
47
54
 
48
55
  values = [f"Item {i}" for i in range(1, 101)]
49
56
 
50
57
  dropdown = CTkScrollableDropdown(
51
- attach=btn,
58
+ attach=combobox,
52
59
  values=values,
53
60
  command=lambda v: print("Selected:", v),
54
- items_per_page=20,
55
- pagination=True,
56
61
  autocomplete=True,
57
- groups=[('1-50', r'^Item [1-4]'), ('Others', '__OTHERS__')]
62
+ groups=[
63
+ ('1-50', r'^Item ([1-9]|[1-4][0-9]|50)$'),
64
+ ('Others', '__OTHERS__')
65
+ ],
58
66
  )
59
67
 
60
68
  app.mainloop()
@@ -22,22 +22,30 @@ pip install ctkscrollabledropdownpp
22
22
 
23
23
  ```python
24
24
  import customtkinter as ctk
25
- from ctkscrollabledropdownpp import CTkScrollableDropdown
25
+ from CTkScrollableDropdownPP import CTkScrollableDropdown
26
26
 
27
27
  app = ctk.CTk()
28
- btn = ctk.CTkButton(app, text='Select')
29
- btn.pack(pady=20)
28
+ app.geometry("400x300")
29
+
30
+ combobox = ctk.CTkComboBox(
31
+ master=app,
32
+ values=[],
33
+ width=200,
34
+ height=30
35
+ )
36
+ combobox.pack(pady=50)
30
37
 
31
38
  values = [f"Item {i}" for i in range(1, 101)]
32
39
 
33
40
  dropdown = CTkScrollableDropdown(
34
- attach=btn,
41
+ attach=combobox,
35
42
  values=values,
36
43
  command=lambda v: print("Selected:", v),
37
- items_per_page=20,
38
- pagination=True,
39
44
  autocomplete=True,
40
- groups=[('1-50', r'^Item [1-4]'), ('Others', '__OTHERS__')]
45
+ groups=[
46
+ ('1-50', r'^Item ([1-9]|[1-4][0-9]|50)$'),
47
+ ('Others', '__OTHERS__')
48
+ ],
41
49
  )
42
50
 
43
51
  app.mainloop()
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "CTkScrollableDropdownPP"
7
- version = "2.0.2"
7
+ version = "2.0.3"
8
8
  description = "Enhanced CTkScrollableDropdown with pagination, search and groups support"
9
9
  authors = [
10
10
  {name = "PLauncher-Team"},