added createWindow
This commit is contained in:
@@ -19,6 +19,8 @@ class PluginLoader(Window):
|
||||
allow_maximize=True
|
||||
)
|
||||
|
||||
# region Lua functions
|
||||
|
||||
def fake_notify(self, message: str, title: str = None, severity: str = "information"):
|
||||
self.app.notify(message=message, title=title, severity=severity)
|
||||
|
||||
@@ -31,7 +33,8 @@ class PluginLoader(Window):
|
||||
|
||||
def add_bind(self, action_name: str, key: str, description: str, show: bool = True):
|
||||
# a bit of a sneaky way of doing things
|
||||
self.app.bind(key, action_name, description=description, show=show)
|
||||
#self.app.bind(key, action_name, description=description, show=show)
|
||||
self.app._bindings.bind(key, action_name, description, show, priority=True)
|
||||
self.app.refresh_bindings()
|
||||
|
||||
def fake_run_action(self, action_name: str):
|
||||
@@ -43,6 +46,23 @@ class PluginLoader(Window):
|
||||
|
||||
setattr(self.app, f"action_{action_name}", wrapper)
|
||||
|
||||
def create_window(self, title: str, icon: str = "", show_title: bool = True, can_close: bool = True, can_maximize: bool = True, can_resize: bool = True, start_horizontal: str = "center", start_vertical: str = "middle"):
|
||||
new_window = Window(
|
||||
id=title,
|
||||
mode="temporary" if can_close else 'permanent',
|
||||
allow_maximize=can_maximize,
|
||||
allow_resize=can_resize,
|
||||
start_open=True,
|
||||
icon=icon,
|
||||
show_title=show_title,
|
||||
starting_horizontal=start_horizontal,
|
||||
starting_vertical=start_vertical
|
||||
)
|
||||
self.app.mount(new_window)
|
||||
return new_window
|
||||
|
||||
# endregion
|
||||
|
||||
@work
|
||||
async def find_plugins(self):
|
||||
log = self.query_one(RichLog)
|
||||
@@ -59,7 +79,8 @@ class PluginLoader(Window):
|
||||
"setTheme": self.set_theme,
|
||||
"runAction": self.fake_run_action,
|
||||
"addBind": self.add_bind,
|
||||
"createAction": self.create_action
|
||||
"createAction": self.create_action,
|
||||
"createWindow": self.create_window
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,8 +174,8 @@ class PluginLoader(Window):
|
||||
|
||||
log.write("\n[b]Done loading plugins![/]")
|
||||
if no_errors:
|
||||
log.write("[d]Window will automatically close in 5 seconds.[/]")
|
||||
await asyncio.sleep(5.0)
|
||||
log.write("[d]Window will automatically close in 10 seconds.[/]")
|
||||
await asyncio.sleep(10)
|
||||
self.close_window()
|
||||
|
||||
async def on_mount(self):
|
||||
|
||||
Reference in New Issue
Block a user