diff options
author | Walter Bender <walter.bender@gmail.com> | 2012-06-25 15:19:41 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2012-06-25 15:19:41 (GMT) |
commit | 4abaaad42a6c5b807f3c170e6d132c857342f5d7 (patch) | |
tree | d6fd97a2795f4db6d6bba2ff4dbe2f1b15e9eaa5 | |
parent | 6b753db043b9bd78f7edb8af1c74c77268584b69 (diff) |
Switch to freq. base if harmonics button pushed
-rw-r--r-- | tuning_toolbar.py | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/tuning_toolbar.py b/tuning_toolbar.py index b3c5160..144def1 100644 --- a/tuning_toolbar.py +++ b/tuning_toolbar.py @@ -248,6 +248,9 @@ class TuningToolbar(gtk.Toolbar): if self.activity.wave.harmonics: self._harmonic.set_icon('harmonics-off') self._harmonic.set_tooltip(_('Hide harmonics.')) + if self.activity.wave.instrument is None and \ + self.activity.wave.tuning_line == 0.0: + self._load_tuning_line() else: self._harmonic.set_icon('harmonics') self._harmonic.set_tooltip(_('Show harmonics.')) @@ -260,20 +263,24 @@ class TuningToolbar(gtk.Toolbar): self._new_tuning_line.set_tooltip(_('Show tuning line.')) self._show_tuning_line = False else: - freq = self._freq_entry.get_text() - try: - self.activity.wave.tuning_line = float(freq) - if freq < 0: - freq = -freq - self._new_tuning_line.set_icon('tuning-tools-off') - self._new_tuning_line.set_tooltip(_('Hide tuning line.')) - self._show_tuning_line = True - except ValueError: - self.activity.wave.tuning_line = 0.0 - self._freq_entry.set_text('0') - # If we are not already in freq. base, switch. - if not self.activity.wave.get_fft_mode(): - self.activity.timefreq_control() + self._load_tuning_line() + + def _load_tuning_line(self): + ''' Read the freq entry and use value to set tuning line ''' + freq = self._freq_entry.get_text() + try: + self.activity.wave.tuning_line = float(freq) + if freq < 0: + freq = -freq + self._new_tuning_line.set_icon('tuning-tools-off') + self._new_tuning_line.set_tooltip(_('Hide tuning line.')) + self._show_tuning_line = True + except ValueError: + self.activity.wave.tuning_line = 0.0 + self._freq_entry.set_text('0') + # If we are not already in freq. base, switch. + if not self.activity.wave.get_fft_mode(): + self.activity.timefreq_control() def play_cb(self, *args): ''' Play a tone at current frequency ''' |