From 31a49e7ba6f6b9e31164bc0a0111e175b551dc75 Mon Sep 17 00:00:00 2001 From: mastercoms Date: Sat, 21 Aug 2021 12:47:50 -0400 Subject: [PATCH] some more work on settings --- .vscode/launch.json | 23 +++++++++++++++++++++++ gui/css/app.css | 20 ++++++++++++++++++++ gui/templates/index.html | 8 -------- gui/templates/settings.html | 2 +- pbgui/__init__.py | 5 +++++ pbgui/core.py | 1 + pbgui/gateway.py | 17 +++++++++++------ pbgui/widgets/__init__.py | 3 ++- pbgui/widgets/commitlog.py | 3 +-- pbsync/pbsync.py | 15 ++++++++------- 10 files changed, 72 insertions(+), 25 deletions(-) delete mode 100644 gui/templates/index.html diff --git a/.vscode/launch.json b/.vscode/launch.json index 8ad4b48..b66b254 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -33,6 +33,16 @@ "options": ["hotfix", "update", "release"], "type": "pickString" }, + { + "id": "guiSelection", + "description": "Please choose GUI page", + "default": "sync", + "options": [ + "sync", + "settings" + ], + "type": "pickString" + }, { "id": "publishSelection", "description": "Please choose build type to publish", @@ -77,6 +87,19 @@ "program": "pbsync/pbsync.py", "console": "integratedTerminal" }, + { + "name": "GUI", + "args": [ + "--gui", + "${input:guiSelection}", + "--debugpath", + "${input:debugPath}" + ], + "type": "python", + "request": "launch", + "program": "pbsync/pbsync.py", + "console": "integratedTerminal" + }, { "name": "Pull Binaries", "args": ["--sync", "binaries", "--debugpath", "${input:debugPath}"], diff --git a/gui/css/app.css b/gui/css/app.css index 1ff7252..18b0c6e 100644 --- a/gui/css/app.css +++ b/gui/css/app.css @@ -5,6 +5,10 @@ color: var(--bs-light); } +#app-inner { + margin-top: 1rem; +} + .flx-LineEdit { width: 100%; border-radius: 0.25rem; @@ -13,3 +17,19 @@ .nav-pills .flx-Button { text-align: start; } + +.flx-BaseButton { + color: inherit; +} + +.flx-Widget:not(.flx-Layout) > .flx-Layout { + position: initial; +} + +.flx-box { + justify-content: initial; +} + +.flx-Label { + align-self: center; +} diff --git a/gui/templates/index.html b/gui/templates/index.html deleted file mode 100644 index cef6ee2..0000000 --- a/gui/templates/index.html +++ /dev/null @@ -1,8 +0,0 @@ -{% include 'navbar.html' %} -
-
-
- -
-
-
diff --git a/gui/templates/settings.html b/gui/templates/settings.html index a2239b1..94b8300 100644 --- a/gui/templates/settings.html +++ b/gui/templates/settings.html @@ -2,7 +2,7 @@
- +
\ No newline at end of file diff --git a/pbgui/__init__.py b/pbgui/__init__.py index fe67de0..f3214e0 100644 --- a/pbgui/__init__.py +++ b/pbgui/__init__.py @@ -20,6 +20,7 @@ asset_pkgs = [("webfonts/", gui.webfonts), ("img/", gui.img)] m = None +default_page = "sync" sync_fn = None def load_flexx_static(data): @@ -39,6 +40,10 @@ def load_static(pkg, filename): return load_flexx_static(data) +def set_default_page(page): + global default_page + default_page = page + for asset_dir, asset_pkg in asset_pkgs: for asset_name in pkg_resources.contents(asset_pkg): diff --git a/pbgui/core.py b/pbgui/core.py index f8a630e..2e614a0 100644 --- a/pbgui/core.py +++ b/pbgui/core.py @@ -16,6 +16,7 @@ def init(self): self.g = Gateway() self.fs = FileBrowserWidget() self.g.set_jfs(self.fs._jswidget) + self.g.init_page(pbgui.default_page) @flx.action def open_file(self, filename): diff --git a/pbgui/gateway.py b/pbgui/gateway.py index 3eee72d..fddf83c 100644 --- a/pbgui/gateway.py +++ b/pbgui/gateway.py @@ -9,7 +9,6 @@ from pbgui import load_static, load_template, widgets -DEFAULT_PAGE = "index" pages = {} @@ -24,10 +23,12 @@ def load_templated_page(file, name, kwargs): # Jinja2 static properties to define per page page_props = { "d": {}, - "index": { - "name": "Home", - "type": "home" + "sync": { + "name": "Sync" }, + "settings": { + "name": "Settings" + } } for resource in pkg_resources.contents(gui.templates): @@ -74,9 +75,9 @@ def init(self): self.elements = { "Button": flx.Button, "FileWidget": None, - "CommitLogTable": widgets.CommitLogTable, + "CommitLogTable": widgets.CommitLogTableWidget, + "Settings": widgets.SettingsWidget, } - self.set_html(pages[DEFAULT_PAGE]) def _create_dom(self): return flx.create_element("div", {"id": "app", "onreact": self.react}) @@ -135,3 +136,7 @@ def set_jfs(self, filebrowser): @flx.action def update_commits(self, commits): self.get_widget("commit-log").update_commits(commits) + + @flx.action + def init_page(self, page): + self.set_html(pages[page]) diff --git a/pbgui/widgets/__init__.py b/pbgui/widgets/__init__.py index c6efdf3..b24495b 100644 --- a/pbgui/widgets/__init__.py +++ b/pbgui/widgets/__init__.py @@ -1 +1,2 @@ -from .commitlog import CommitLogTable \ No newline at end of file +from .commitlog import CommitLogTableWidget +from .settings import SettingsWidget \ No newline at end of file diff --git a/pbgui/widgets/commitlog.py b/pbgui/widgets/commitlog.py index 9ae3617..1eb3ff9 100644 --- a/pbgui/widgets/commitlog.py +++ b/pbgui/widgets/commitlog.py @@ -1,7 +1,6 @@ from flexx import flx - -class CommitLogTable(flx.Widget): +class CommitLogTableWidget(flx.Widget): commits = flx.ListProp() commit_nodes = flx.ListProp() diff --git a/pbsync/pbsync.py b/pbsync/pbsync.py index 2cfdfe8..a1f4d3e 100644 --- a/pbsync/pbsync.py +++ b/pbsync/pbsync.py @@ -19,6 +19,7 @@ from pbpy import pbuac import pbgui.main +import pbgui.gateway import pbsync_version @@ -440,7 +441,7 @@ def main(argv): parser.add_argument("--sync", help="Main command for the PBSync, synchronizes the project with latest changes from the repo, and does some housekeeping", choices=["all", "partial", "binaries", "engineversion", "engine", "force", "ddc"]) - parser.add_argument("--nogui", help="Command line switch to skip GUI for sync handler", default=False) + parser.add_argument("--gui", help="Open a GUI page", choices=["sync", "settings"]) parser.add_argument("--printversion", help="Prints requested version information into console.", choices=["current-engine", "latest-engine", "project"]) parser.add_argument( @@ -540,13 +541,13 @@ def pbsync_config_parser_func(root): run UpdateProject again.""", True) # Parse args - if not (args.sync is None): + if not (args.gui is None): def sync(): - sync_handler(args.sync, args.repository, args.bundle) - if args.nogui: - sync() - else: - pbgui.main.run(sync) + return sync_handler(args.sync, args.repository, args.bundle) + pbgui.set_default_page(args.gui) + pbgui.main.run(sync) + if not (args.sync is None): + sync_handler(args.sync, args.repository, args.bundle) elif not (args.printversion is None): printversion_handler(args.printversion, args.repository) elif not (args.autoversion is None):