Skip to content

Commit

Permalink
gui: bump Toga
Browse files Browse the repository at this point in the history
  • Loading branch information
layday committed Jun 11, 2024
1 parent 38e938b commit a491abc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
23 changes: 7 additions & 16 deletions instawow-gui/src/instawow_gui/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# pyright: reportUnknownArgumentType = false
# pyright: reportUnknownMemberType = false

from __future__ import annotations

import asyncio
Expand Down Expand Up @@ -63,8 +60,6 @@ def on_app_exit(app: toga.App, **kwargs: object):
self.on_exit = on_app_exit

def startup(self) -> None:
self.main_window = toga.MainWindow(title=self.formal_name, size=(800, 600))

if sys.platform == 'win32':
import ctypes

Expand All @@ -89,45 +84,39 @@ def dispatch_js_keyboard_event(command: toga.Command, **kwargs: object):
),
text='Toggle Search Filter',
shortcut=toga.Key.MOD_1 + toga.Key.G,
group=toga.Group.EDIT, # pyright: ignore[reportArgumentType]
group=toga.Group.EDIT,
section=20,
order=10,
),
)
self.commands.add(
toga.Command(
partial(
dispatch_js_keyboard_event,
action=_TogaSimulateKeypressAction.ActivateViewInstalled,
),
text='Installed',
shortcut=toga.Key.MOD_1 + toga.Key.L,
group=toga.Group.WINDOW, # pyright: ignore[reportArgumentType]
group=toga.Group.WINDOW,
section=20,
order=10,
),
)
self.commands.add(
toga.Command(
partial(
dispatch_js_keyboard_event,
action=_TogaSimulateKeypressAction.ActivateViewReconcile,
),
text='Unreconciled',
group=toga.Group.WINDOW, # pyright: ignore[reportArgumentType]
group=toga.Group.WINDOW,
section=20,
order=20,
),
)
self.commands.add(
toga.Command(
partial(
dispatch_js_keyboard_event,
action=_TogaSimulateKeypressAction.ActivateViewSearch,
),
text='Search',
shortcut=toga.Key.MOD_1 + toga.Key.F,
group=toga.Group.WINDOW, # pyright: ignore[reportArgumentType]
group=toga.Group.WINDOW,
section=20,
order=30,
),
Expand All @@ -137,7 +126,9 @@ def dispatch_js_keyboard_event(command: toga.Command, **kwargs: object):

self.__start_json_rpc_server(partial(setattr, web_view, 'url'))

self.main_window.content = web_view
self.main_window = toga.MainWindow(
title=self.formal_name, size=(800, 600), content=web_view
)
self.main_window.show()


Expand Down
4 changes: 3 additions & 1 deletion instawow-gui/src/instawow_gui/json_rpc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ async def respond(self, config_ctxs: _ConfigBoundCtxCollection) -> SelectFolderR
def select_folder():
async def inner() -> Path | None:
try:
return await app.main_window.select_folder_dialog( # pyright: ignore[reportUnknownMemberType]
assert app.main_window
return await app.main_window.select_folder_dialog(
'Select folder', self.initial_folder
)
except ValueError:
Expand Down Expand Up @@ -621,6 +622,7 @@ async def respond(self, config_ctxs: _ConfigBoundCtxCollection) -> ConfirmDialog

def confirm():
async def inner():
assert app.main_window
return await app.main_window.confirm_dialog(self.title, self.message)

task = asyncio.create_task(inner())
Expand Down
2 changes: 1 addition & 1 deletion instawow-gui/src/instawow_gui_wrapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def _patch_std_streams() -> None:
import sys

# These are ``None`` when pythonw is used.
if sys.stdout is None or sys.stderr is None: # pyright: ignore[reportUnnecessaryComparison]
if sys.stdout is None or sys.stderr is None:
sys.stdout = sys.stderr = io.StringIO()


Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ dependencies = [
]
optional-dependencies."skeletal-gui" = [
"aiohttp-rpc >= 1.0.0",
"toga-core >= 0.4.2",
"toga-core >= 0.4.5",
]
optional-dependencies."gui" = [
"instawow[skeletal-gui]",
"toga >= 0.4.2",
"toga >= 0.4.5",
]
optional-dependencies."test" = [
"anyio >= 4.3.0",
Expand Down

0 comments on commit a491abc

Please sign in to comment.