Add 'starts_at' display for campaigns on mouse over
This commit is contained in:
1 parent
0bbbce0d5d
commit
ec0781acae
1 file changed
+23
-5
@@ -233,6 +233,20 @@ class PaddedListbox(tk.Listbox):
|
|||||||
self.configure(*args, **kwargs)
|
self.configure(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class MouseOverLabel(ttk.Label):
|
||||||
|
def __init__(self, *args, alt_text: str = '', **kwargs) -> None:
|
||||||
|
options = {}
|
||||||
|
if args and args[0] is not None:
|
||||||
|
options.update(args[0])
|
||||||
|
if kwargs:
|
||||||
|
options.update(kwargs)
|
||||||
|
self._org_text: str = options.get("text", '')
|
||||||
|
self._alt_text: str = alt_text
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.bind("<Enter>", lambda e: self.config(text=self._alt_text))
|
||||||
|
self.bind("<Leave>", lambda e: self.config(text=self._org_text))
|
||||||
|
|
||||||
|
|
||||||
class _WSEntry(TypedDict):
|
class _WSEntry(TypedDict):
|
||||||
status: str
|
status: str
|
||||||
topics: int
|
topics: int
|
||||||
@@ -287,8 +301,7 @@ class WebsocketStatus:
|
|||||||
status_lines: list[str] = []
|
status_lines: list[str] = []
|
||||||
topic_lines: list[str] = []
|
topic_lines: list[str] = []
|
||||||
for idx in range(MAX_WEBSOCKETS):
|
for idx in range(MAX_WEBSOCKETS):
|
||||||
item = self._items.get(idx)
|
if (item := self._items.get(idx)) is None:
|
||||||
if item is None:
|
|
||||||
status_lines.append('')
|
status_lines.append('')
|
||||||
topic_lines.append('')
|
topic_lines.append('')
|
||||||
else:
|
else:
|
||||||
@@ -930,10 +943,13 @@ class InventoryOverview:
|
|||||||
ttk.Label(
|
ttk.Label(
|
||||||
campaign_frame, text=status_text, takefocus=False, foreground=status_color
|
campaign_frame, text=status_text, takefocus=False, foreground=status_color
|
||||||
).grid(column=1, row=1, sticky="w", padx=4)
|
).grid(column=1, row=1, sticky="w", padx=4)
|
||||||
ttk.Label(
|
MouseOverLabel(
|
||||||
campaign_frame,
|
campaign_frame,
|
||||||
text=f"Ends: {campaign.ends_at.astimezone().replace(microsecond=0, tzinfo=None)}",
|
text=f"Ends: {campaign.ends_at.astimezone().replace(microsecond=0, tzinfo=None)}",
|
||||||
takefocus=False
|
alt_text=(
|
||||||
|
f"Starts: {campaign.starts_at.astimezone().replace(microsecond=0, tzinfo=None)}"
|
||||||
|
),
|
||||||
|
takefocus=False,
|
||||||
).grid(column=1, row=2, sticky="w", padx=4)
|
).grid(column=1, row=2, sticky="w", padx=4)
|
||||||
acl = campaign.allowed_channels
|
acl = campaign.allowed_channels
|
||||||
if acl:
|
if acl:
|
||||||
@@ -1511,6 +1527,7 @@ if __name__ == "__main__":
|
|||||||
td = total_drops
|
td = total_drops
|
||||||
cm = current_minutes
|
cm = current_minutes
|
||||||
tm = total_minutes
|
tm = total_minutes
|
||||||
|
ref_stamp = datetime.now(timezone.utc).replace(minute=0, second=0)
|
||||||
mock = SimpleNamespace(
|
mock = SimpleNamespace(
|
||||||
id="0",
|
id="0",
|
||||||
campaign=SimpleNamespace(
|
campaign=SimpleNamespace(
|
||||||
@@ -1520,7 +1537,8 @@ if __name__ == "__main__":
|
|||||||
upcoming=True,
|
upcoming=True,
|
||||||
image_url="https://static-cdn.jtvnw.net/ttv-boxart/460630-285x380.jpg",
|
image_url="https://static-cdn.jtvnw.net/ttv-boxart/460630-285x380.jpg",
|
||||||
allowed_channels=[],
|
allowed_channels=[],
|
||||||
ends_at=datetime.now(timezone.utc) + timedelta(days=5, hours=6, minutes=23),
|
starts_at=ref_stamp,
|
||||||
|
ends_at=ref_stamp + timedelta(days=7),
|
||||||
timed_drops={},
|
timed_drops={},
|
||||||
claimed_drops=cd,
|
claimed_drops=cd,
|
||||||
total_drops=td,
|
total_drops=td,
|
||||||
|
|||||||
Reference in new issue
Block a user