예제 #1
0
    def change_interval(self, event=None):
        try:
            val = int(self.inter_ctl.get())
            oldval = self.data_store.get_hole_interval(self.index)
            if val != oldval:
                if val > 0 and val < 5:
                    self.data_store.set_hole_interval(self.index, val)
                    self.logger.debug("change interval from %d to %d"%(oldval, val))
                    raise_event("UPDATE_NOTES_EVENT")
                    self.data_store.set_change_flag()
                else:
                    self.logger.error("invalid value for interval: %s"%(str(self.inter_ctl.get())))
                    messagebox.showerror("ERROR", "Intervals must be an integer between 1 and 4")
                    self.inter_ctl.delete(0, tkinter.END)
                    self.inter_ctl.insert(0, str(self.data_store.get_hole_interval(self.index)))
                    return False
            else:
                self.logger.debug("ignore")
        except ValueError:
            self.logger.error("invalid integer for interval: %s"%(str(self.inter_ctl.get())))
            messagebox.showerror("ERROR", "Cannot convert the string \"%s\" to an integer between 1 1nd 4"%(self.inter_ctl.get()))
            self.inter_ctl.delete(0, tkinter.END)
            self.inter_ctl.insert(0, str(self.data_store.get_hole_interval(self.index)))
            return False
        except IndexError:
            pass  # always ignore

        return True
 def wallThicknessCommand(self, event=None):
     try:
         v = self.wallThicknessEntry.get()
         n = float(v)
         if n != self.data_store.get_wall_thickness():
             self.logger.debug("change wall from %f to %f"%(self.data_store.get_wall_thickness(), n))
             self.data_store.set_wall_thickness(n)
             self.wallThicknessEntry.delete(0, tkinter.END)
             self.wallThicknessEntry.insert(0, str(n))
             raise_event("CALCULATE_EVENT")
             self.data_store.set_change_flag()
         else:
             self.logger.debug("ignore")
         return True
     except ValueError as e:
         self.logger.error(str(e))
         messagebox.showerror("Error", "Could not convert wall thickness to a floating point number.\nRead value was \"%s\"." % (v))
         self.wallThicknessEntry.delete(0, tkinter.END)
         self.wallThicknessEntry.insert(0, str(self.data_store.get_wall_thickness()))
         return False
     except IndexError:
         self.logger.error(str(e))
         self.wallThicknessEntry.delete(0, tkinter.END)
         self.wallThicknessEntry.insert(0, str(self.data_store.get_wall_thickness()))
     except Exception as e:
         self.logger.error(str(e))
         messagebox.showerror("Unknown Error", "Unknown exception trying convert wall thickness to a floating point number.\nRead value was \"%s\".\nException %s" % (v, str(e)))
         self.wallThicknessEntry.delete(0, tkinter.END)
         self.wallThicknessEntry.insert(0, str(self.data_store.get_wall_thickness()))
예제 #3
0
 def loadCommand(self):
     f = filedialog.askopenfilename(initialfile=self.data.get_file_name(), filetypes=(("Whistle Files","*.wis"), ("all files", "*.*")))
     if f != '':
         self.logger.debug("loading file: %s"%(f))
         self.data.load(f)
         self.data.set_file_name(f)
         raise_event("UPDATE_LOWER_FRAME_EVENT")
         self.set_state()
     else:
         self.logger.debug("cancel")
 def update_notes(self):
     sel = self.data_store.get_bell_note_select()
     for index, line in enumerate(self.line_widgits):
         sel += self.data_store.get_hole_interval(index)
         self.data_store.set_hole_freq(
             index, self.data_store.note_table[sel]["frequency"])
         self.data_store.set_hole_note(
             index, self.data_store.note_table[sel]["note"])
         line.set_state()
     raise_event("CALCULATE_EVENT")
예제 #5
0
 def do_calc(self):
     # self.isound = self.data.get_vsound_in()
     # self.msound = self.data.get_vsound_mm()
     self.data.clear_hole_data()
     if self.data.get_calc_type() == 0:
         self.quadratic()
         #self.iterative()
     else:
         self.iterative()
     raise_event("UPDATE_LINES_EVENT")
     raise_event("UPDATE_UPPER_EVENT")
    def displayFormatCallback(self, event):
        if self.displayFormatOpt.current() == 0:
            val = False
        else:
            val = True

        if val != self.data_store.get_disp_frac():
            self.data_store.set_disp_frac(val)
            raise_event("UPDATE_HOLE_EVENT")
            self.logger.debug("current format set to: %s"%(str(self.data_store.get_disp_frac())))
            self.data_store.set_change_flag()
        else:
            self.logger.debug("ignore")
    def incr_command(self):
        siz = self.data_store.get_hole_size(self.index)
        siz = siz + self.data_store.get_hole_inc()

        if siz > self.data_store.get_hole_max():
            siz = self.data_store.get_hole_max()
        elif siz < self.data_store.get_hole_min():
            siz = self.data_store.get_hole_min()

        self.data_store.set_hole_size(self.index, siz)
        self.update_val() # update the GUI
        raise_event("CALCULATE_EVENT")
        self.data_store.set_change_flag()
 def bellSelectCallback(self, event):
     '''
     Change the data_store to match the new bell selection
     '''
     val = self.bellNoteCombo.current()
     if val != self.data_store.get_bell_note_select():
         self.data_store.set_bell_note_select(val)
         self.data_store.set_bell_freq(self.data_store.note_table[val]['frequency'])
         self.logger.debug("current bell selection set to: %d: %f"%(self.data_store.get_bell_note_select(), self.data_store.get_bell_freq()))
         raise_event("UPDATE_NOTES_EVENT")
         self.data_store.set_change_flag()
     else:
         self.logger.debug("ignore")
     self.set_state()
    def change_units(self):
        '''
        When this is called, the assumption is that the GUI and the
        data_store have the wrong units. This function takes what ever
        is in the data_sore and converts if to the units that it finds
        there.  Then it updates the GUI.
        '''
        if self.data_store.get_units(): # true of units are mm
            self.data_store.set_inside_dia(utility.in_to_mm(self.data_store.get_inside_dia()))
            self.data_store.set_wall_thickness(utility.in_to_mm(self.data_store.get_wall_thickness()))
        else:
            self.data_store.set_inside_dia(utility.mm_to_in(self.data_store.get_inside_dia()))
            self.data_store.set_wall_thickness(utility.mm_to_in(self.data_store.get_wall_thickness()))

        self.set_state()
        # Cause the other frames to update
        raise_event("CHANGE_UNITS_EVENT")
        raise_event('CALCULATE_EVENT')
        self.data_store.set_change_flag()
예제 #10
0
 def numHolesCommand(self, event=None):
     n = 0
     try:
         v = self.numHolesEntry.get()
         n = int(v)
         if n >= 1 and n <= 12:
             # only raise the event if the number of holes is different from
             # what is in the data_store
             if n != self.data_store.get_number_holes():
                 self.logger.debug("change number of holes from %d to %d"%(self.data_store.get_number_holes(), n))
                 self.data_store.set_number_holes(n)
                 raise_event('UPDATE_LOWER_FRAME_EVENT')
                 self.data_store.set_change_flag()
             else:
                 self.logger.debug("ignore")
             return True
         else:
             self.logger.error("range error on number of holes: %s"%(str(n)))
             messagebox.showerror("Error", message="Number of holes must be an integer between 1 and 12.\nRead value was \"%s\"." % (v))
             self.numHolesEntry.delete(0, tkinter.END)
             self.numHolesEntry.insert(0, str(self.data_store.get_number_holes()))
             return False
     except ValueError as e:
         self.logger.error(str(e))
         messagebox.showerror("Error", message="Could not convert number of holes to an integer.\nRead value was \"%s\"." % (v))
         self.numHolesEntry.delete(0, tkinter.END)
         self.numHolesEntry.insert(0, str(self.data_store.get_number_holes()))
         return False
     except IndexError as e:
         self.logger.error(str(e))
         self.numHolesEntry.delete(0, tkinter.END)
         self.numHolesEntry.insert(0, str(self.data_store.get_number_holes()))
     except Exception as e:
         self.logger.error(str(e))
         messagebox.showerror("Unknown Error", message="Unknown exception trying to convert number of holes to an integer.\nRead value was \"%s\".\nException: %s" % (v, str(e)))
         self.wallThicknessEntry.delete(0, tkinter.END)
         self.wallThicknessEntry.insert(0, str(self.data_store.get_wall_thickness()))
예제 #11
0
 def constCommand(self):
     dialogs.ConstDialog(self.master)
     raise_event("UPDATE_LOWER_FRAME_EVENT")
     raise_event("UPDATE_UPPER_EVENT")
예제 #12
0
 def emboCommand(self):
     dialogs.EmbouchureDialog(self.master)
     raise_event("UPDATE_LOWER_FRAME_EVENT")
     raise_event("UPDATE_UPPER_EVENT")
예제 #13
0
 def refreshButtonCommand(self):
     self.refreshButton.focus_set()
     self.get_state()
     #raise_event('UPDATE_LINES_EVENT')
     raise_event('UPDATE_LOWER_FRAME_EVENT')
     self.set_state()