added createWindow
This commit is contained in:
2
main.py
2
main.py
@@ -89,7 +89,7 @@ class Berry(App):
|
|||||||
console.clear()
|
console.clear()
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
result = subprocess.check_output(command, shell=True, text=True)
|
result = subprocess.check_output(command, shell=True, text=True, stderr=subprocess.STDOUT)
|
||||||
console.write(result)
|
console.write(result)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
console.write(e.stdout)
|
console.write(e.stdout)
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ class PluginLoader(Window):
|
|||||||
allow_maximize=True
|
allow_maximize=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# region Lua functions
|
||||||
|
|
||||||
def fake_notify(self, message: str, title: str = None, severity: str = "information"):
|
def fake_notify(self, message: str, title: str = None, severity: str = "information"):
|
||||||
self.app.notify(message=message, title=title, severity=severity)
|
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):
|
def add_bind(self, action_name: str, key: str, description: str, show: bool = True):
|
||||||
# a bit of a sneaky way of doing things
|
# 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()
|
self.app.refresh_bindings()
|
||||||
|
|
||||||
def fake_run_action(self, action_name: str):
|
def fake_run_action(self, action_name: str):
|
||||||
@@ -43,6 +46,23 @@ class PluginLoader(Window):
|
|||||||
|
|
||||||
setattr(self.app, f"action_{action_name}", wrapper)
|
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
|
@work
|
||||||
async def find_plugins(self):
|
async def find_plugins(self):
|
||||||
log = self.query_one(RichLog)
|
log = self.query_one(RichLog)
|
||||||
@@ -59,7 +79,8 @@ class PluginLoader(Window):
|
|||||||
"setTheme": self.set_theme,
|
"setTheme": self.set_theme,
|
||||||
"runAction": self.fake_run_action,
|
"runAction": self.fake_run_action,
|
||||||
"addBind": self.add_bind,
|
"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![/]")
|
log.write("\n[b]Done loading plugins![/]")
|
||||||
if no_errors:
|
if no_errors:
|
||||||
log.write("[d]Window will automatically close in 5 seconds.[/]")
|
log.write("[d]Window will automatically close in 10 seconds.[/]")
|
||||||
await asyncio.sleep(5.0)
|
await asyncio.sleep(10)
|
||||||
self.close_window()
|
self.close_window()
|
||||||
|
|
||||||
async def on_mount(self):
|
async def on_mount(self):
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local plugin = {}
|
local plugin = {}
|
||||||
|
|
||||||
function testAction()
|
function testAction()
|
||||||
berry.ui.notify("I just ran the test action!")
|
local window = berry.ui.createWindow("test window")
|
||||||
end
|
end
|
||||||
|
|
||||||
function plugin.init()
|
function plugin.init()
|
||||||
|
|||||||
Reference in New Issue
Block a user