From 823c138a5fbfd011ef26634a03388353278e04a9 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Sat, 14 May 2022 17:24:33 +0100 Subject: [PATCH] remove scale enter/leave binds, use hasattr, fix bug in on_mousewheel remove redundant scale_enter, scale_leave functions. use hasattr over in dir() fix bug in on_mousewheel patch bump --- setup.py | 2 +- vmcompact/builders.py | 2 -- vmcompact/channels.py | 11 ++--------- vmcompact/config.py | 4 ++-- vmcompact/gainlayer.py | 15 ++++----------- 5 files changed, 9 insertions(+), 25 deletions(-) diff --git a/setup.py b/setup.py index 3b00512..91222ce 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh: setuptools.setup( name="vmcompact", - version="1.2.3", + version="1.2.4", author="Onyx and Iris", author_email="code@onyxandiris.online", description="Compact Tkinter Voicemeeter Remote App", diff --git a/vmcompact/builders.py b/vmcompact/builders.py index a82524d..59f1312 100644 --- a/vmcompact/builders.py +++ b/vmcompact/builders.py @@ -235,9 +235,7 @@ class ChannelLabelFrameBuilder(AbstractBuilder): self.scale.grid(column=1, row=0) self.scale.bind("", self.labelframe.reset_gain) self.scale.bind("", self.labelframe.scale_press) - self.scale.bind("", self.labelframe.scale_enter) self.scale.bind("", self.labelframe.scale_release) - self.scale.bind("", self.labelframe.scale_leave) self.scale.bind("", self.labelframe._on_mousewheel) def add_gain_label(self): diff --git a/vmcompact/channels.py b/vmcompact/channels.py index 680de84..c7c4c62 100644 --- a/vmcompact/channels.py +++ b/vmcompact/channels.py @@ -39,11 +39,11 @@ class ChannelLabelFrame(ttk.LabelFrame): return self.parent.target def getter(self, param): - if param in dir(self.target): + if hasattr(self.target, param): return getattr(self.target, param) def setter(self, param, value): - if param in dir(self.target): + if hasattr(self.target, param): setattr(self.target, param, value) def scale_callback(self, *args): @@ -64,12 +64,6 @@ class ChannelLabelFrame(ttk.LabelFrame): self.setter("gain", 0) self.gain.set(0) - def scale_enter(self, *args): - pass - - def scale_leave(self, *args): - pass - def scale_press(self, *args): _base_values.in_scale_button_1 = True @@ -90,7 +84,6 @@ class ChannelLabelFrame(ttk.LabelFrame): elif self.gain.get() < -60: self.gain.set(-60) self.setter("gain", self.gain.get()) - self.parent.parent.nav_frame.info_text.set(round(self.gain.get(), 1)) def open_config(self): if self.conf.get(): diff --git a/vmcompact/config.py b/vmcompact/config.py index 0c9bf70..6437734 100644 --- a/vmcompact/config.py +++ b/vmcompact/config.py @@ -29,11 +29,11 @@ class Config(ttk.Frame): return self.parent.target def getter(self, param): - if param in dir(self.target): + if hasattr(self.target, param): return getattr(self.target, param) def setter(self, param, value): - if param in dir(self.target): + if hasattr(self.target, param): setattr(self.target, param, value) def scale_press(self, *args): diff --git a/vmcompact/gainlayer.py b/vmcompact/gainlayer.py index b1a5a80..26e6872 100644 --- a/vmcompact/gainlayer.py +++ b/vmcompact/gainlayer.py @@ -41,11 +41,11 @@ class GainLayer(ttk.LabelFrame): return "gainlayer" def getter(self, param): - if param in dir(self.target): + if hasattr(self.target, param): return getattr(self.target, param) def setter(self, param, value): - if param in dir(self.target): + if hasattr(self.target, param): setattr(self.target, param, value) def reset_gain(self, *args): @@ -65,19 +65,13 @@ class GainLayer(ttk.LabelFrame): def scale_release(self, *args): _base_values.in_scale_button_1 = False - def scale_enter(self, *args): - pass - - def scale_leave(self, *args): - pass - def _on_mousewheel(self, event): self.gain.set( self.gain.get() + ( - _base_values.mwscroll_step + _configuration.mwscroll_step if event.delta > 0 - else -_base_values.mwscroll_step + else -_configuration.mwscroll_step ) ) if self.gain.get() > 12: @@ -85,7 +79,6 @@ class GainLayer(ttk.LabelFrame): elif self.gain.get() < -60: self.gain.set(-60) self.setter("gain", self.gain.get()) - self.parent.parent.nav_frame.info_text.set(round(self.gain.get(), 1)) def set_on(self): """enables a gainlayer. sets its button colour"""