MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / add_item

Method add_item

gui/utils.py:203–223  ·  view source on GitHub ↗

Add an item to the list.

(self, text: str, icon: str = "")

Source from the content-addressed store, hash-verified

201 self._bind_scroll_events()
202
203 def add_item(self, text: str, icon: str = "") -> None:
204 """Add an item to the list."""
205 display_text = f"{icon} {text}" if icon else text
206
207 item = ctk.CTkButton(
208 self,
209 text=display_text,
210 anchor="w",
211 height=36,
212 corner_radius=DIMENSIONS["corner_radius_small"],
213 fg_color="transparent",
214 hover_color=COLORS["bg_medium"],
215 text_color=COLORS["text_primary"],
216 font=ctk.CTkFont(family=FONTS["family"], size=FONTS["size_normal"]),
217 command=lambda idx=len(self.items): self._select(idx),
218 )
219 item.pack(fill="x", padx=4, pady=2)
220 item.bind("<Double-1>", lambda e, idx=len(self.items): self._double_click(idx))
221 # Bind scroll events to new item
222 self._bind_scroll_to_widget(item)
223 self.items.append(item)
224
225 def _bind_scroll_events(self) -> None:
226 """Bind mouse wheel scroll events to this scrollable frame."""

Callers 1

_load_accountsMethod · 0.80

Calls 3

_selectMethod · 0.95
_double_clickMethod · 0.95

Tested by

no test coverage detected