re-run through ruff formatter

This commit is contained in:
2025-01-15 20:56:37 +00:00
parent 752d1d7dd9
commit e4fc68c1ad
12 changed files with 387 additions and 382 deletions

View File

@@ -29,10 +29,10 @@ class App(tk.Tk):
"""
APP_cls = type(
f"Voicemeeter{kind}.Compact",
f'Voicemeeter{kind}.Compact',
(cls,),
{
"kind": kind,
'kind': kind,
},
)
return APP_cls
@@ -41,30 +41,34 @@ class App(tk.Tk):
super().__init__()
self.logger = logger.getChild(self.__class__.__name__)
self._vmr = vmr
self._vmr.event.add(["pdirty", "ldirty"])
self._vmr.event.add(['pdirty', 'ldirty'])
self.subject = Subject()
self.start_updates()
self._vmr.init_thread()
icon_path = Path(__file__).parent.resolve() / "img" / "cat.ico"
if icon_path.is_file():
self.iconbitmap(str(icon_path))
for pn in (
Path(__file__).parent.resolve() / 'img' / 'cat.ico',
Path.cwd() / '_internal' / 'img' / 'cat.ico',
):
if pn.is_file():
self.iconbitmap(str(pn))
break
self.minsize(275, False)
self._configs = None
self.protocol("WM_DELETE_WINDOW", self.on_close_window)
self.menu = self["menu"] = Menus(self, vmr)
self.protocol('WM_DELETE_WINDOW', self.on_close_window)
self.menu = self['menu'] = Menus(self, vmr)
self.styletable = ttk.Style()
if _configuration.config:
vmr.apply_config(_configuration.config)
self.build_app()
self.drag_id = ""
self.bind("<Configure>", self.dragging)
self.drag_id = ''
self.bind('<Configure>', self.dragging)
self.after(1, self.healthcheck_step)
def __str__(self):
return f"{type(self).__name__}App"
return f'{type(self).__name__}App'
@property
def target(self):
@@ -80,8 +84,8 @@ class App(tk.Tk):
frame
for frame in self.winfo_children()
if isinstance(frame, ttk.Frame)
and "!stripconfig" in str(frame)
or "!busconfig" in str(frame)
and '!stripconfig' in str(frame)
or '!busconfig' in str(frame)
)
def build_app(self, kind=None, vban=None):
@@ -97,22 +101,22 @@ class App(tk.Tk):
self.submix_frame = None
self.builder = MainFrameBuilder(self)
self.builder.setup()
self.builder.create_channelframe("strip")
self.builder.create_channelframe('strip')
self.builder.create_separator()
self.builder.create_navframe()
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_pdirty(self):
if _base_values.run_update:
self.after(1, self.subject.notify, "pdirty")
self.after(1, self.subject.notify, 'pdirty')
def on_ldirty(self):
if not _base_values.dragging:
self.after(1, self.subject.notify, "ldirty")
self.after(1, self.subject.notify, 'ldirty')
def _destroy_top_level_frames(self):
"""
@@ -132,14 +136,14 @@ class App(tk.Tk):
def dragging(self, event, *args):
if event.widget is self:
if self.drag_id == "":
if self.drag_id == '':
_base_values.dragging = True
else:
self.after_cancel(self.drag_id)
self.drag_id = self.after(100, self.stop_drag)
def stop_drag(self):
self.drag_id = ""
self.drag_id = ''
_base_values.dragging = False
@cached_property
@@ -149,11 +153,11 @@ class App(tk.Tk):
def start_updates(self):
def init():
self.logger.debug("updates started")
self.logger.debug('updates started')
_base_values.run_update = True
if self._vmr.gui.launched_by_api:
self.subject.notify("pdirty")
self.subject.notify('pdirty')
self.after(12000, init)
else:
init()
@@ -163,10 +167,10 @@ class App(tk.Tk):
try:
self._vmr.version
except voicemeeterlib.error.CAPIError:
resp = messagebox.askyesno(message="Restart Voicemeeter GUI?")
resp = messagebox.askyesno(message='Restart Voicemeeter GUI?')
if resp:
self.logger.debug(
"healthcheck failed, rebuilding the app after GUI restart."
'healthcheck failed, rebuilding the app after GUI restart.'
)
self._vmr.end_thread()
self._vmr.run_voicemeeter(self._vmr.kind.name)
@@ -175,13 +179,13 @@ class App(tk.Tk):
self.after(8000, self.start_updates)
self._destroy_top_level_frames()
self.build_app(self._vmr.kind)
vban_config = get_configuration("vban")
vban_config = get_configuration('vban')
for i, _ in enumerate(vban_config):
target = getattr(self.menu, f"menu_vban_{i+1}")
target.entryconfig(0, state="normal")
target.entryconfig(1, state="disabled")
target = getattr(self.menu, f'menu_vban_{i + 1}')
target.entryconfig(0, state='normal')
target.entryconfig(1, state='disabled')
[
self.menu.menu_vban.entryconfig(j, state="normal")
self.menu.menu_vban.entryconfig(j, state='normal')
for j, _ in enumerate(self.menu.menu_vban.winfo_children())
]
else:
@@ -203,5 +207,5 @@ def connect(kind_id: str, vmr) -> App:
try:
VMMIN_cls = _apps[kind_id]
except KeyError:
raise VMCompactError(f"Invalid kind: {kind_id}")
raise VMCompactError(f'Invalid kind: {kind_id}')
return VMMIN_cls(vmr)