updates to gui to match changes to interfaces

updates to gui to match changes to interfaces

now packaged with poetry and on pypi
This commit is contained in:
onyx-and-iris
2022-06-16 23:53:28 +01:00
parent 0688a36a76
commit 2c39b9d215
15 changed files with 273 additions and 78 deletions

View File

@@ -1,13 +1,13 @@
import tkinter as tk
from pathlib import Path
from tkinter import ttk
from typing import NamedTuple
from pathlib import Path
from .errors import VMCompactErrors
from .data import _kinds_all, _configuration, _base_values
from .subject import Subject
from .builders import MainFrameBuilder
from .data import _base_values, _configuration, _kinds_all
from .errors import VMCompactErrors
from .menu import Menus
from .subject import Subject
class App(tk.Tk):
@@ -89,7 +89,7 @@ class App(tk.Tk):
if _configuration.extended:
self.nav_frame.extend.set(True)
self.nav_frame.extend_frame()
if self.kind.name == "Potato":
if self.kind.name == "potato":
self.builder.create_banner()
def on_update(self, subject, data):
@@ -145,7 +145,7 @@ class App(tk.Tk):
self.drag_id = ""
_apps = {kind.id: App.make(kind) for kind in _kinds_all}
_apps = {kind.name: App.make(kind) for kind in _kinds_all}
def connect(kind_id: str, vmr) -> App:

View File

@@ -1,15 +1,15 @@
import tkinter as tk
from tkinter import ttk
from functools import partial
import abc
import tkinter as tk
from functools import partial
from tkinter import ttk
import sv_ttk
from .data import _base_values, _configuration
from .channels import _make_channelframe
from .navigation import Navigation
from .config import StripConfig, BusConfig
from .banner import Banner
from .channels import _make_channelframe
from .config import BusConfig, StripConfig
from .data import _base_values, _configuration
from .navigation import Navigation
class AbstractBuilder(abc.ABC):
@@ -144,7 +144,7 @@ class NavigationFrameBuilder(AbstractBuilder):
variable=self.navframe.submix,
)
self.navframe.submix_button.grid(column=0, row=0)
if self.navframe.parent.kind.name != "Potato":
if self.navframe.parent.kind.name != "potato":
self.navframe.submix_button["state"] = "disabled"
def create_channel_button(self):
@@ -321,7 +321,7 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder):
"""Responsible for building channel configframe widgets"""
def setup(self):
if self.configframe.parent.kind.name == "Basic":
if self.configframe.parent.kind.name == "basic":
self.configframe.slider_params = ("audibility",)
self.configframe.slider_vars = (tk.DoubleVar(),)
else:
@@ -349,12 +349,12 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder):
tk.BooleanVar() for _ in self.configframe.params
)
if self.configframe.parent.kind.name in ("Banana", "Potato"):
if self.configframe.parent.kind.name in ("banana", "potato"):
if self.configframe.index == self.configframe.phys_in:
self.configframe.params = list(
map(lambda x: x.replace("mono", "mc"), self.configframe.params)
)
if self.configframe.parent.kind.name == "Banana":
if self.configframe.parent.kind.name == "banana":
pass
# karaoke modes not in RT Packet yet. May implement in future
"""

View File

@@ -1,6 +1,6 @@
import tkinter as tk
from tkinter import ttk
from math import log
from tkinter import ttk
from . import builders
from .data import _base_values, _configuration

View File

@@ -1,9 +1,9 @@
import tkinter as tk
from tkinter import ttk
from functools import partial
from tkinter import ttk
from . import builders
from .data import _configuration, _base_values
from .data import _base_values, _configuration
class Config(ttk.Frame):
@@ -96,7 +96,7 @@ class StripConfig(Config):
def make_row_0(self):
if self.index < self.phys_in:
if self.parent.kind.name == "Basic":
if self.parent.kind.name == "basic":
self.builder.create_audibility_slider()
else:
self.builder.create_comp_slider()

View File

@@ -1,6 +1,7 @@
import toml
from pathlib import Path
import tomllib
configuration = {}
config_path = [Path.cwd() / "configs"]
@@ -11,8 +12,9 @@ for path in config_path:
for filename in filenames:
name = filename.with_suffix("").stem
try:
configs[name] = toml.load(filename)
except toml.TomlDecodeError:
with open(filename, "rb") as f:
configs[name] = tomllib.load(f)
except tomllib.TOMLDecodeError:
print(f"Invalid TOML profile: configs/{filename.stem}")
for name, cfg in configs.items():

View File

@@ -1,5 +1,6 @@
from dataclasses import dataclass
from voicemeeter import kinds
from voicemeeterlib import kinds
from .configurations import get_configuration
@@ -51,7 +52,7 @@ class BaseValues(metaclass=SingletonMeta):
# a vban connection established
vban_connected: bool = False
# pdirty delay
pdelay: int = 5
pdelay: int = 1
# ldirty delay
ldelay: int = 5
@@ -59,7 +60,7 @@ class BaseValues(metaclass=SingletonMeta):
_base_values = BaseValues()
_configuration = Configurations()
_kinds = {kind.id: kind for kind in kinds.all}
_kinds = {kind.name: kind for kind in kinds.kinds_all}
_kinds_all = _kinds.values()

View File

@@ -1,6 +1,6 @@
import tkinter as tk
from tkinter import ttk
from math import log
from tkinter import ttk
from . import builders
from .data import _base_values, _configuration

View File

@@ -1,16 +1,12 @@
import tkinter as tk
from tkinter import ttk, messagebox
from functools import partial
import webbrowser
import sv_ttk
import vbancmd
from functools import partial
from tkinter import messagebox, ttk
from .data import (
get_configuration,
_base_values,
_configuration,
kind_get,
)
import sv_ttk
import vban_cmd
from .data import _base_values, _configuration, get_configuration, kind_get
class Menus(tk.Menu):
@@ -76,31 +72,31 @@ class Menus(tk.Menu):
command=partial(self.action_set_voicemeeter, "lock", False),
)
# profiles menu
menu_profiles = tk.Menu(self, tearoff=0)
self.add_cascade(menu=menu_profiles, label="Profiles")
self.menu_profiles_load = tk.Menu(menu_profiles, tearoff=0)
menu_profiles.add_cascade(menu=self.menu_profiles_load, label="Load profile")
defaults = {"base", "blank"}
if len(self.target.profiles) > len(defaults) and all(
key in self.target.profiles for key in defaults
# configs menu
menu_configs = tk.Menu(self, tearoff=0)
self.add_cascade(menu=menu_configs, label="Configs")
self.menu_configs_load = tk.Menu(menu_configs, tearoff=0)
menu_configs.add_cascade(menu=self.menu_configs_load, label="Load profile")
defaults = {"reset"}
if len(self.target.configs) > len(defaults) and all(
key in self.target.configs for key in defaults
):
[
self.menu_profiles_load.add_command(
self.menu_configs_load.add_command(
label=profile, command=partial(self.load_profile, profile)
)
for profile in self.target.profiles.keys()
for profile in self.target.configs.keys()
if profile not in defaults
]
else:
menu_profiles.entryconfig(0, state="disabled")
menu_profiles.add_command(label="Reset to defaults", command=self.load_defaults)
menu_configs.entryconfig(0, state="disabled")
menu_configs.add_command(label="Reset to defaults", command=self.load_defaults)
# layout menu
self.menu_layout = tk.Menu(self, tearoff=0)
self.add_cascade(menu=self.menu_layout, label="Layout")
# layout/submixes
# here we build menu regardless of kind but disable if not Potato
# here we build menu regardless of kind but disable if not potato
buses = tuple(f"A{i+1}" for i in range(5)) + tuple(f"B{i+1}" for i in range(3))
self.menu_submixes = tk.Menu(self.menu_layout, tearoff=0)
self.menu_layout.add_cascade(menu=self.menu_submixes, label="Submixes")
@@ -116,7 +112,7 @@ class Menus(tk.Menu):
for i in range(8)
]
self._selected_bus[_configuration.submixes].set(True)
if self.parent.kind.name != "Potato":
if self.parent.kind.name != "potato":
self.menu_layout.entryconfig(0, state="disabled")
# layout/extends
self.menu_extends = tk.Menu(self.menu_layout, tearoff=0)
@@ -211,14 +207,14 @@ class Menus(tk.Menu):
setattr(self.target.command, cmd, val)
def load_profile(self, profile):
self.target.apply_profile(profile)
self.target.apply_config(profile)
def load_defaults(self):
resp = messagebox.askyesno(
message="Are you sure you want to Reset values to defaults?\nPhysical strips B1, Virtual strips A1\nMono, Solo, Mute, EQ all OFF"
)
if resp:
self.target.apply_profile("base")
self.target.apply_config("reset")
def always_on_top(self):
self.parent.attributes("-topmost", self._is_topmost.get())
@@ -258,7 +254,7 @@ class Menus(tk.Menu):
if isinstance(menu, tk.Menu)
]
self.menu_lock.config(bg=f"{'black' if theme == 'dark' else 'white'}")
self.menu_profiles_load.config(bg=f"{'black' if theme == 'dark' else 'white'}")
self.menu_configs_load.config(bg=f"{'black' if theme == 'dark' else 'white'}")
[
menu.config(bg=f"{'black' if theme == 'dark' else 'white'}")
for menu in self.menu_vban.winfo_children()
@@ -280,7 +276,7 @@ class Menus(tk.Menu):
opts = {}
opts |= self.vban_config[f"connection-{i+1}"]
kind_id = opts.pop("kind")
self.vban = vbancmd.connect(kind_id, **opts)
self.vban = vban_cmd.api(kind_id, **opts)
# login to vban interface
self.vban.login()
# destroy the current App frames
@@ -294,7 +290,7 @@ class Menus(tk.Menu):
target_menu.entryconfig(0, state="disabled")
target_menu.entryconfig(1, state="normal")
self.menu_layout.entryconfig(
0, state=f"{'normal' if kind.name == 'Potato' else 'disabled'}"
0, state=f"{'normal' if kind.name == 'potato' else 'disabled'}"
)
def vban_disconnect(self, i):
@@ -311,7 +307,7 @@ class Menus(tk.Menu):
target_menu.entryconfig(0, state="normal")
target_menu.entryconfig(1, state="disabled")
self.menu_layout.entryconfig(
0, state=f"{'normal' if kind.name == 'Potato' else 'disabled'}"
0, state=f"{'normal' if kind.name == 'potato' else 'disabled'}"
)
self.after(15000, self.enable_vban_menus)