Compare commits

..

No commits in common. "b0f634f1e86862b3f66d4787005f9a4c423d2ecd" and "81a5497a32a9a4f21adf1c9b4c87f33b9821d2e7" have entirely different histories.

10 changed files with 87 additions and 187 deletions

View File

@ -139,13 +139,13 @@ A valid `vban.toml` might look like this:
```toml ```toml
[connection-1] [connection-1]
kind = 'banana' kind = 'banana'
host = '192.168.1.2' ip = '192.168.1.2'
streamname = 'worklaptop' streamname = 'worklaptop'
port = 6980 port = 6980
[connection-2] [connection-2]
kind = 'potato' kind = 'potato'
host = '192.168.1.3' ip = '192.168.1.3'
streamname = 'streampc' streamname = 'streampc'
port = 6990 port = 6990
``` ```

View File

@ -1,40 +0,0 @@
version: '3'
tasks:
build:
desc: Build Azure artifacts
deps: [rewrite]
cmds:
- defer: { task: restore }
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [azure-light, azure-dark]
cmd: poetry run pyinstaller --noconfirm --distpath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} spec/azure/{{.ITEM.THEME}}-{{.ITEM.KIND}}.spec
rewrite:
internal: true
desc: Run the source code rewriter
cmds:
- poetry run python tools/rewriter.py --rewrite --theme {{.THEME}}
restore:
internal: true
desc: Restore the backup files
cmds:
- poetry run python tools/rewriter.py --restore
compress:
desc: Compress Azure artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [azure-light, azure-dark]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} -DestinationPath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}}.zip -Force"'
clean:
desc: Clean build and dist directories
cmds:
- |
{{.SHELL}} -Command "Remove-Item -Path build/azure-*,dist/azure-* -Recurse -Force"

View File

@ -1,40 +0,0 @@
version: '3'
tasks:
build:
desc: Build Forest artifacts
deps: [rewrite]
cmds:
- defer: { task: restore }
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [forest-light, forest-dark]
cmd: poetry run pyinstaller --noconfirm --distpath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} spec/forest/{{.ITEM.THEME}}-{{.ITEM.KIND}}.spec
rewrite:
internal: true
desc: Run the source code rewriter
cmds:
- poetry run python tools/rewriter.py --rewrite --theme {{.THEME}}
restore:
internal: true
desc: Restore the backup files
cmds:
- poetry run python tools/rewriter.py --restore
compress:
desc: Compress Forest artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [forest-light, forest-dark]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/{{.ITEM.THEME}}-{{.ITEM.KIND}} -DestinationPath dist/{{.ITEM.THEME}}-{{.ITEM.KIND}}.zip -Force"'
clean:
desc: Clean build and dist directories
cmds:
- |
{{.SHELL}} -Command "Remove-Item -Path build/forest-*,dist/forest-* -Recurse -Force"

View File

@ -1,24 +0,0 @@
version: '3'
tasks:
build:
desc: Build Sunvalley artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
cmd: poetry run pyinstaller --noconfirm --distpath dist/sunvalley-{{.ITEM.KIND}} spec/sunvalley/sunvalley-{{.ITEM.KIND}}.spec
compress:
desc: Compress Sunvalley artifacts
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/sunvalley-{{.ITEM.KIND}} -DestinationPath dist/sunvalley-{{.ITEM.KIND}}.zip -Force"'
clean:
desc: Clean build and dist directories
cmds:
- |
{{.SHELL}} -Command "Remove-Item -Path build/sunvalley-*,dist/sunvalley-* -Recurse -Force"

View File

@ -1,19 +1,5 @@
version: '3' version: '3'
includes:
sunvalley:
taskfile: ./Taskfile.sunvalley.yml
vars:
THEME: sunvalley
forest:
taskfile: ./Taskfile.forest.yml
vars:
THEME: forest
azure:
taskfile: ./Taskfile.azure.yml
vars:
THEME: azure
vars: vars:
SHELL: pwsh SHELL: pwsh
@ -33,23 +19,63 @@ tasks:
build: build:
desc: Build all artifacts desc: Build all artifacts
cmds: cmds:
- for: - task: build-sunvalley
matrix: - echo "Sunvalley build complete"
THEME: [sunvalley, forest, azure] - task: build-forest
task: '{{.ITEM.THEME}}:build' - echo "Forest build complete"
compress: build-sunvalley:
desc: Compress all artifacts desc: Build Sunvalley artifacts
cmds: cmds:
- for: - for:
matrix: matrix:
THEME: [sunvalley, forest, azure] KIND: [basic, banana, potato]
task: '{{.ITEM.THEME}}:compress' cmd: poetry run pyinstaller --noconfirm --distpath dist/sunvalley-{{.ITEM.KIND}} spec/sunvalley-{{.ITEM.KIND}}.spec
build-forest:
desc: Build Forest artifacts
deps: [rewrite]
cmds:
- defer: { task: restore }
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [light, dark]
cmd: poetry run pyinstaller --noconfirm --distpath dist/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}} spec/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}}.spec
rewrite:
internal: true
desc: Run the source code rewriter
cmds:
- poetry run python tools/rewriter.py --rewrite
restore:
internal: true
desc: Restore the backup files
cmds:
- poetry run python tools/rewriter.py --restore
compress:
deps: [compress-sunvalley, compress-forest]
compress-sunvalley:
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/sunvalley-{{.ITEM.KIND}} -DestinationPath dist/sunvalley-{{.ITEM.KIND}}.zip -Force"'
compress-forest:
cmds:
- for:
matrix:
KIND: [basic, banana, potato]
THEME: [light, dark]
cmd: '{{.SHELL}} -Command "Compress-Archive -Path dist/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}} -DestinationPath dist/forest-{{.ITEM.KIND}}-{{.ITEM.THEME}}.zip -Force"'
clean: clean:
desc: Clean up build and dist directories desc: Clean up build and dist directories
cmds: cmds:
- for: - |
matrix: {{.SHELL}} -Command "
THEME: [sunvalley, forest, azure] Remove-Item -Path build/forest-*,build/sunvalley-*,dist/forest-*,dist/sunvalley-* -Recurse -Force"
task: '{{.ITEM.THEME}}:clean'

View File

@ -1,9 +1,10 @@
# load a specific profile on start (file name without .toml ext) # load a specific profile on start (file name without .toml ext)
# [configs] # [configs]
# config="example" # config="example"
# load with themes enabled? # load with themes enabled? set the default mode
[theme] [theme]
enabled = true enabled = true
mode = "light"
# load in extended mode? if so which orientation # load in extended mode? if so which orientation
[extends] [extends]
extended = true extended = true
@ -21,4 +22,4 @@ size = 3
default = 0 default = 0
# show the navigation frame? # show the navigation frame?
[navigation] [navigation]
show = false show = true

View File

@ -2,12 +2,12 @@
### set the ip then uncomment ### set the ip then uncomment
# [connection-1] # [connection-1]
# kind = 'banana' # kind = 'banana'
# ip = 'localhost' # ip = '<ip address 1>'
# streamname = 'Command1' # streamname = 'Command1'
# port = 6980 # port = 6980
# [connection-2] # [connection-2]
# kind = 'potato' # kind = 'potato'
# ip = 'gamepc.local' # ip = '<ip address 2>'
# streamname = 'Command1' # streamname = 'Command1'
# port = 6980 # port = 6980

View File

@ -16,7 +16,7 @@ def write_outs(output, outs: tuple):
output.write(out) output.write(out)
def rewrite_app(theme): def rewrite_app():
app_logger = logger.getChild('app') app_logger = logger.getChild('app')
app_logger.info('rewriting app.py') app_logger.info('rewriting app.py')
infile = Path(SRC_DIR) / 'app.bk' infile = Path(SRC_DIR) / 'app.bk'
@ -34,28 +34,24 @@ def rewrite_app(theme):
( (
' self._vmr = vmr\n', ' self._vmr = vmr\n',
' self._theme = theme\n', ' self._theme = theme\n',
' self._theme_name = theme.split("-")[0]\n',
' self._theme_type = theme.split("-")[-1]\n',
' tcldir = Path.cwd() / "theme"\n', ' tcldir = Path.cwd() / "theme"\n',
' if not tcldir.is_dir():\n', ' if not tcldir.is_dir():\n',
' tcldir = Path.cwd() / "_internal" / "theme"\n', ' tcldir = Path.cwd() / "_internal" / "theme"\n',
' match self._theme_name:\n', ' self.tk.call("source", tcldir.resolve() / f"forest-{self._theme}.tcl")\n',
' case "forest":\n',
' self.tk.call("source", tcldir.resolve() / f"{self._theme}.tcl")\n',
' case "azure":\n',
' self.tk.call("source", tcldir.resolve() / f"{self._theme_name}.tcl")\n',
), ),
) )
# def connect() # def connect()
case 'def connect(kind_id: str, vmr) -> App:\n': case 'def connect(kind_id: str, vmr) -> App:\n':
output.write('def connect(kind_id: str, vmr, theme) -> App:\n') output.write(
'def connect(kind_id: str, vmr, theme="light") -> App:\n'
)
case ' return VMMIN_cls(vmr)\n': case ' return VMMIN_cls(vmr)\n':
output.write(' return VMMIN_cls(vmr, theme)\n') output.write(' return VMMIN_cls(vmr, theme)\n')
case _: case _:
output.write(line) output.write(line)
def rewrite_builders(theme): def rewrite_builders():
builders_logger = logger.getChild('builders') builders_logger = logger.getChild('builders')
builders_logger.info('rewriting builders.py') builders_logger.info('rewriting builders.py')
infile = Path(SRC_DIR) / 'builders.bk' infile = Path(SRC_DIR) / 'builders.bk'
@ -75,26 +71,15 @@ def rewrite_builders(theme):
case 'import sv_ttk\n': case 'import sv_ttk\n':
output.write('#import sv_ttk\n') output.write('#import sv_ttk\n')
case ' self.app.resizable(False, False)\n': case ' self.app.resizable(False, False)\n':
if theme.startswith('forest'): write_outs(
write_outs( output,
output, (
( ' self.app.resizable(False, False)\n'
' self.app.resizable(False, False)\n' ' if _configuration.themes_enabled:\n',
' if _configuration.themes_enabled:\n', ' ttk.Style().theme_use(f"forest-{self.app._theme}")\n',
' ttk.Style().theme_use(self.app._theme)\n', ' self.logger.info(f"Forest Theme applied")\n',
' self.logger.info(f"{self.app._theme} Theme applied")\n', ),
), )
)
elif theme.startswith('azure'):
write_outs(
output,
(
' self.app.resizable(False, False)\n'
' if _configuration.themes_enabled:\n',
' self.app.tk.call("set_theme", self.app._theme_type)\n',
' self.logger.info(f"Azure {self.app._theme_type} Theme applied")\n',
),
)
ignore_next_lines = 6 ignore_next_lines = 6
# setting navframe button widths # setting navframe button widths
case ' variable=self.navframe.submix,\n': case ' variable=self.navframe.submix,\n':
@ -186,21 +171,12 @@ def rewrite_builders(theme):
) )
case _: case _:
if 'Toggle.TButton' in line: if 'Toggle.TButton' in line:
if theme.startswith('forest'): output.write(line.replace('Toggle.TButton', 'ToggleButton'))
output.write(
line.replace('Toggle.TButton', 'ToggleButton')
)
elif theme.startswith('azure'):
output.write(
line.replace(
'Toggle.TButton', 'Switch.TCheckbutton'
)
)
else: else:
output.write(line) output.write(line)
def rewrite_menu(theme): def rewrite_menu():
menu_logger = logger.getChild('menu') menu_logger = logger.getChild('menu')
menu_logger.info('rewriting menu.py') menu_logger.info('rewriting menu.py')
infile = Path(SRC_DIR) / 'menu.bk' infile = Path(SRC_DIR) / 'menu.bk'
@ -223,7 +199,7 @@ def rewrite_menu(theme):
output.write(line) output.write(line)
def prepare_for_build(theme): def prepare_for_build():
################# MOVE FILES FROM PACKAGE DIR INTO SRC DIR ######################### ################# MOVE FILES FROM PACKAGE DIR INTO SRC DIR #########################
for file in ( for file in (
PACKAGE_DIR / 'app.py', PACKAGE_DIR / 'app.py',
@ -235,8 +211,12 @@ def prepare_for_build(theme):
file.rename(SRC_DIR / f'{file.stem}.bk') file.rename(SRC_DIR / f'{file.stem}.bk')
###################### RUN THE FILE REWRITER FOR EACH *.BK ######################### ###################### RUN THE FILE REWRITER FOR EACH *.BK #########################
for step in (rewrite_app, rewrite_builders, rewrite_menu): steps = (
step(theme) rewrite_app,
rewrite_builders,
rewrite_menu,
)
[step() for step in steps]
def cleanup(): def cleanup():
@ -259,13 +239,12 @@ def cleanup():
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--rewrite', action='store_true') parser.add_argument('--rewrite', action='store_true')
parser.add_argument('--theme', type=str, default='forest')
parser.add_argument('--restore', action='store_true') parser.add_argument('--restore', action='store_true')
args = parser.parse_args() args = parser.parse_args()
if args.rewrite: if args.rewrite:
logger.info('preparing files for build') logger.info('preparing files for build')
prepare_for_build(args.theme) prepare_for_build()
elif args.restore: elif args.restore:
logger.info('cleaning up files') logger.info('cleaning up files')
cleanup() cleanup()

View File

@ -60,7 +60,7 @@ _defaults = {
'submixes': { 'submixes': {
'default': 0, 'default': 0,
}, },
'navigation': {'show': False}, 'navigation': {'show': True},
} }

View File

@ -357,17 +357,15 @@ class Menus(tk.Menu):
opts = {} opts = {}
opts |= self.vban_config[f'connection-{i + 1}'] opts |= self.vban_config[f'connection-{i + 1}']
kind_id = opts.pop('kind') kind_id = opts.pop('kind')
if 'ip' in opts:
opts['host'] = opts.pop('ip')
self.vban = vban_cmd.api(kind_id, **opts) self.vban = vban_cmd.api(kind_id, **opts)
# login to vban interface # login to vban interface
try: try:
self.logger.info(f'Attempting vban connection to {opts.get("host")}') self.logger.info(f'Attempting vban connection to {opts.get("ip")}')
self.vban.login() self.vban.login()
except VBANCMDConnectionError as e: except VBANCMDConnectionError as e:
self.vban.logout() self.vban.logout()
msg = ( msg = (
f'Timeout attempting to establish connection to {opts.get("host")}', f'Timeout attempting to establish connection to {opts.get("ip")}',
'Please check your connection settings', 'Please check your connection settings',
) )
messagebox.showerror('Connection Error', '\n'.join(msg)) messagebox.showerror('Connection Error', '\n'.join(msg))