diff --git a/vmcompact/builders.py b/vmcompact/builders.py index 697d7e3..b2615d5 100644 --- a/vmcompact/builders.py +++ b/vmcompact/builders.py @@ -249,7 +249,13 @@ class ChannelLabelFrameBuilder(AbstractBuilder): self.scale.bind("", self.labelframe.reset_gain) self.scale.bind("", self.labelframe.scale_press) self.scale.bind("", self.labelframe.scale_release) - self.scale.bind("", self.labelframe._on_mousewheel) + self.scale.bind( + "", + partial( + self.labelframe.pause_updates, + self.labelframe._on_mousewheel, + ), + ) def add_gain_label(self): self.labelframe.gain_label = ttk.Label( @@ -263,7 +269,7 @@ class ChannelLabelFrameBuilder(AbstractBuilder): self.button_mute = ttk.Checkbutton( self.labelframe, text="MUTE", - command=partial(self.labelframe.toggle_mute, "mute"), + command=partial(self.labelframe.pause_updates, self.labelframe.toggle_mute), style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{self.identifier}Mute{self.index}.TButton'}", variable=self.labelframe.mute, ) @@ -283,7 +289,7 @@ class ChannelLabelFrameBuilder(AbstractBuilder): self.button_on = ttk.Checkbutton( self.labelframe, text="ON", - command=self.labelframe.set_on, + command=partial(self.labelframe.pause_updates, self.labelframe.set_on), style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{self.identifier}On{self.index}.TButton'}", variable=self.labelframe.on, ) @@ -486,7 +492,9 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder): ttk.Checkbutton( self.configframe, text=param, - command=partial(self.configframe.toggle_a, param), + command=partial( + self.configframe.pause_updates, self.configframe.toggle_a, param + ), style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{param}.TButton'}", variable=self.configframe.phys_out_params_vars[ self.configframe.phys_out_params.index(param) @@ -507,7 +515,9 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder): ttk.Checkbutton( self.configframe, text=param, - command=partial(self.configframe.toggle_b, param), + command=partial( + self.configframe.pause_updates, self.configframe.toggle_b, param + ), style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{param}.TButton'}", variable=self.configframe.virt_out_params_vars[ self.configframe.virt_out_params.index(param) @@ -528,7 +538,9 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder): ttk.Checkbutton( self.configframe, text=param, - command=partial(self.configframe.toggle_p, param), + command=partial( + self.configframe.pause_updates, self.configframe.toggle_p, param + ), style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{param}.TButton'}", variable=self.configframe.param_vars[i], ) @@ -578,10 +590,16 @@ class BusConfigFrameBuilder(ChannelConfigFrameBuilder): column=0, row=0, columnspan=2, sticky=(tk.W) ) self.configframe.busmode_button.bind( - "", self.configframe.rotate_bus_modes_right + "", + partial( + self.configframe.pause_updates, self.configframe.rotate_bus_modes_right + ), ) self.configframe.busmode_button.bind( - "", self.configframe.rotate_bus_modes_left + "", + partial( + self.configframe.pause_updates, self.configframe.rotate_bus_modes_left + ), ) def create_param_buttons(self): @@ -589,7 +607,9 @@ class BusConfigFrameBuilder(ChannelConfigFrameBuilder): ttk.Checkbutton( self.configframe, text=param, - command=partial(self.configframe.toggle_p, param), + command=partial( + self.configframe.pause_updates, self.configframe.toggle_p, param + ), style=f"{'Toggle.TButton' if _configuration.themes_enabled else f'{param}.TButton'}", variable=self.configframe.param_vars[i], ) diff --git a/vmcompact/channels.py b/vmcompact/channels.py index a9fab78..1d79c43 100644 --- a/vmcompact/channels.py +++ b/vmcompact/channels.py @@ -88,17 +88,27 @@ class ChannelLabelFrame(ttk.LabelFrame): self.parent.target.event.add("ldirty") self.after(500, self.resume_updates) + def pause_updates(self, func, *args): + """function wrapper, adds a 50ms delay on updates""" + _base_values.run_update = False + + func(*args) + + self.after(50, self.resume_updates) + def resume_updates(self): _base_values.run_update = True def _on_mousewheel(self, event): - _base_values.run_update = False self.gain.set( - self.gain.get() - + ( - _configuration.mwscroll_step - if event.delta > 0 - else -_configuration.mwscroll_step + round( + self.gain.get() + + ( + _configuration.mwscroll_step + if event.delta > 0 + else -_configuration.mwscroll_step + ), + 1, ) ) if self.gain.get() > 12: @@ -106,7 +116,7 @@ class ChannelLabelFrame(ttk.LabelFrame): elif self.gain.get() < -60: self.gain.set(-60) self.setter("gain", self.gain.get()) - self.after(1, self.resume_updates) + self.gainlabel.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 8d650b5..5db9528 100644 --- a/vmcompact/config.py +++ b/vmcompact/config.py @@ -68,6 +68,14 @@ class Config(ttk.Frame): self.parent.target.event.add("ldirty") self.after(350, self.resume_updates) + def pause_updates(self, func, *args): + """function wrapper, adds a 50ms delay on updates""" + _base_values.run_update = False + + func(*args) + + self.after(50, self.resume_updates) + def resume_updates(self): _base_values.run_update = True diff --git a/vmcompact/gainlayer.py b/vmcompact/gainlayer.py index e1acfe3..04cad6c 100644 --- a/vmcompact/gainlayer.py +++ b/vmcompact/gainlayer.py @@ -78,6 +78,14 @@ class GainLayer(ttk.LabelFrame): self.parent.target.event.add("ldirty") self.after(500, self.resume_updates) + def pause_updates(self, func, *args): + """function wrapper, adds a 50ms delay on updates""" + _base_values.run_update = False + + func(*args) + + self.after(50, self.resume_updates) + def resume_updates(self): _base_values.run_update = True