Skip to content

Commit

Permalink
Fix re-enabling not working
Browse files Browse the repository at this point in the history
Fix tray icon menu not updating
  • Loading branch information
aliencaocao committed Jan 21, 2024
1 parent d7a4f04 commit a86f193
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
10 changes: 5 additions & 5 deletions scanning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@
"outputs": [
{
"data": {
"text/plain": "'2115507066'"
"text/plain": "'1992141906'"
},
"execution_count": 129,
"execution_count": 130,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -231,11 +231,11 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
"end_time": "2024-01-21T08:59:27.857633500Z",
"start_time": "2024-01-21T08:59:27.836633400Z"
"end_time": "2024-01-21T09:42:09.654427500Z",
"start_time": "2024-01-21T09:42:09.644608500Z"
}
},
"execution_count": 129
"execution_count": 130
},
{
"cell_type": "code",
Expand Down
15 changes: 10 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,15 @@ def toggle():
global timer
if not toggle_var.get():
if connect_discord(RPC):
stop_variable.clear()
timer = RepeatedTimer(interval, update, stop_variable=stop_variable)
toggle_var.set(True)
menu.insert(0, item('Disable' if not is_CN else '禁用', toggle))
else:
stop_update()
toggle_var.set(False)
menu.insert(0, item('Enable' if not is_CN else '启用', toggle))
icon.menu = menu


def about():
Expand All @@ -170,10 +174,9 @@ def show_window(icon, item):


def hide_window():
global icon
root.withdraw()
image = Image.open(get_res_path("app_logo.png"))
menu = [item('Show' if not is_CN else '显示主窗口', show_window),
item('Quit' if not is_CN else '退出', quit_app)]
if toggle_var.get():
menu.insert(0, item('Disable' if not is_CN else '禁用', toggle))
else:
Expand Down Expand Up @@ -369,6 +372,9 @@ def stop_update():
RPC.clear(pid=pid)


menu = [item('Show' if not is_CN else '显示主窗口', show_window, default=True),
item('Quit' if not is_CN else '退出', quit_app)]

root = Tk()
root.title('Netease Cloud Music Discord RPC')
root.resizable(False, False)
Expand Down Expand Up @@ -400,6 +406,5 @@ def stop_update():
root.after_idle(startup)
root.mainloop()

# TODO: delay before first update
# TODO: disable then enable dont work, just disable work
# TODO: tray icon menu dont update after enable/disable
# TODO: delay before first update - unable to reproduce reliably
# TODO: RuntimeError: Event loop is closed error when re-enabling, doesnt affect functionality though

0 comments on commit a86f193

Please sign in to comment.