Esempio n. 1
0
    def solver_frame(self, frame):
        self.label_t_ind = ttk.Label(frame, text='Required inductance:')
        self.label_t_ind.grid(row=2,
                              column=1,
                              padx=self.padding,
                              pady=self.padding,
                              sticky='w')
        self.entry_t_ind = ttk.Entry(frame,
                                     width=20,
                                     textvariable=self.target_ind,
                                     validate='all',
                                     validatecommand=self.validate)
        self.entry_t_ind.grid(row=2, column=3)
        self.label_t_ind_units = ttk.Label(frame, text="H")
        self.label_t_ind_units.grid(row=2,
                                    column=5,
                                    padx=self.padding,
                                    pady=self.padding,
                                    sticky='e')
        tp.Tooltip(self.label_t_ind,
                   text=u'The required inductance in H',
                   wraplength=200)

        self.label_t_rho = ttk.Label(frame, text='Required rho:')
        self.label_t_rho.grid(row=3,
                              column=1,
                              padx=self.padding,
                              pady=self.padding,
                              sticky='w')
        self.entry_t_rho = ttk.Entry(frame,
                                     width=20,
                                     textvariable=self.target_rho,
                                     validate='all',
                                     validatecommand=self.validate)
        self.entry_t_rho.grid(row=3, column=3)
        self.label_t_rho_units = ttk.Label(frame, text="H")
        self.label_t_rho_units.grid(row=3,
                                    column=5,
                                    padx=self.padding,
                                    pady=self.padding,
                                    sticky='e')
        tp.Tooltip(self.label_t_rho,
                   text=u'Fill factor, \u03C1=(dout-din)/(dout+din)',
                   wraplength=200)

        self.button_fh = ttk.Button(frame,
                                    text='Find Parameters',
                                    state=NORMAL)
        self.button_fh.grid(row=4,
                            column=1,
                            padx=self.padding,
                            pady=self.padding,
                            sticky='w')
        self.button_fh.config(command=self.callback_solver)
        tp.Tooltip(
            self.button_fh,
            text=
            'Determine the parameters for the given inductance. Experiment with the value of "rho" to try and reduce the outer dimension',
            wraplength=100)
 def check_sample_name(self, samplename, widgetname):
     fname = self.config["path" +
                         str(self.number)] + "/" + str(samplename) + ".ely"
     entry = self.root.nametowidget(widgetname)
     if samplename != "" and os.path.isfile(fname):
         # if it exists, then give the entry a red border.
         entry.configure(bg="#ffb5b5")
         if "tooltip" in sys.modules:
             if hasattr(entry, "tooltip"):
                 entry.tooltip.bind()
             else:
                 entry.tooltip = tooltip.Tooltip(
                     entry,
                     text=
                     "This sample name already exists. Data will be appended to file "
                     + samplename + ".ely.",
                     waittime=0)
     else:
         entry.configure(bg="#ffffff")
         if "tooltip" in sys.modules:
             if hasattr(entry, "tooltip"):
                 entry.tooltip.unbind()
     return True
def update_name_description(row_index):
    ad = str.lower(str(Rows.widget_dict['Register Address'][row_index].get()))

    try:
        matching_name = Rows.name_dict[ad]
        matching_descript = Rows.description_dict[ad]
    except KeyError:
        return

    # Delete previous name
    Rows.widget_dict['Register Name'][row_index].config(text='')
    Rows.widget_dict['Register Name'][row_index].grid(
        row=row_index + 1, column=Rows.headerRow.index('Name'))

    # Fill in with new name
    Rows.widget_dict['Register Name'][row_index].config(text=matching_name,
                                                        justify=LEFT,
                                                        padx=5)
    Rows.widget_dict['Register Name'][row_index].grid(
        row=row_index + 1, column=Rows.headerRow.index('Name'))

    if matching_descript:
        tooltip.Tooltip(Rows.widget_dict['Register Name'][row_index],
                        matching_descript)
def insert_row_value(csv_file):
    """
    Takes in a list of lists with values: ['register val','val'] or ['register val'] and inserts these values
    into the register GUI display
    :param csv_file:
    :return:
    """

    # Create regular expressions for the addresses and values (program expects hex values)
    reg_ad_regex = re.compile(r'(0x)?([0-9a-f]{1,4})', re.IGNORECASE)
    value_regex = re.compile(r'(0x)?([0-9a-f]{1,2})', re.IGNORECASE)

    # Create regular expressions for Header labels
    header_name_regex = re.compile(r'Register Name', re.IGNORECASE)
    header_ad_regex = re.compile(r'Address', re.IGNORECASE)
    header_value_regex = re.compile(r'Value', re.IGNORECASE)
    header_descript_regex = re.compile(r'Description', re.IGNORECASE)

    # Create an array of of header regexes;
    header_arr = [
        header_name_regex, header_ad_regex, header_value_regex,
        header_descript_regex
    ]

    # Try to find the header along the top of the file; else the file is invalid
    try:
        header_name = header_name_regex.search(
            csv_file[0][header_arr.index(header_name_regex)])
        header_ad = header_ad_regex.search(
            csv_file[0][header_arr.index(header_ad_regex)])
        header_value = header_value_regex.search(
            csv_file[0][header_arr.index(header_value_regex)])
        header_descript = header_descript_regex.search(
            csv_file[0][header_arr.index(header_descript_regex)])
    except IndexError:
        invalid_csv_file()
        return

    for i in range(len(csv_file)):
        try:
            # Delete all values in the 'Register Address' and 'Hex Value' columns
            # Delete all messages from processor
            Rows.widget_dict['Register Address'][i].delete(0, END)
            Rows.widget_dict['Hex Value'][i].delete(0, END)
            Rows.widget_dict['Binary Display'][i].display_hex_to_binary(i, '0')
            widgets.edit_message(Rows.widget_dict['Message'][i], Rows.msg_dict,
                                 -1, '')
        except IndexError:
            # If additional rows need to be created, create them
            create_row(Rows.widget_dict['Register Control Frame'],
                       Rows.headerRow)

        # Because of the header row, account for the difference in row index
        reg_index = i
        if header_name and header_ad and header_value and header_descript:
            reg_index = i - 1
            if i == 0:
                continue

        # Get the inputted register name (if there is one)
        inputted_register_name = csv_file[i][header_arr.index(
            header_name_regex)]
        Rows.widget_dict['Register Name'][reg_index].config(
            text=inputted_register_name, justify=LEFT, padx=5)
        Rows.widget_dict['Register Name'][reg_index].grid(
            row=i, column=Rows.headerRow.index('Name'))

        try:
            # Get the register address in the csv file
            register_address = reg_ad_regex.search(
                csv_file[i][header_arr.index(header_ad_regex)])
            # Insert that register address into the GUI row
            Rows.widget_dict['Register Address'][reg_index].insert(
                0, register_address.group(2))
        except AttributeError:
            widgets.edit_message(Rows.widget_dict['Message'][reg_index],
                                 Rows.msg_dict, 'er: Invalid hex')
            Rows.widget_dict['Message'][reg_index].grid(
                row=i, column=Rows.headerRow.index('Message'))
            continue

        add_name(register_address.group(2), inputted_register_name)

        # Values are optional
        # If there is a value, insert it into the GUI row
        if csv_file[i][header_arr.index(header_value_regex)]:
            try:
                value = value_regex.search(
                    csv_file[i][header_arr.index(header_value_regex)])
                try:
                    Rows.widget_dict['Binary Display'][
                        reg_index].display_hex_to_binary(
                            reg_index, value.group(2))
                except AttributeError:
                    pass
                try:
                    Rows.widget_dict['Hex Value'][reg_index].insert(
                        0, value.group(2))
                except AttributeError:
                    widgets.edit_message(
                        Rows.widget_dict['Message'][reg_index], Rows.msg_dict,
                        'er: Invalid hex')
                    Rows.widget_dict['Message'][reg_index].grid(
                        row=i, column=Rows.headerRow.index('Message'))
            except IndexError:
                pass

        # Descriptions are optional
        # register_descript = csv_file[i][header_arr.index(header_descript_regex)]
        # add_description(register_address.group(2), register_descript)
        # tooltip.Tooltip(Rows.widget_dict['Register Name'][reg_index], register_descript)
        try:
            register_descript = csv_file[i][header_arr.index(
                header_descript_regex)]
            add_description(register_address.group(2), register_descript)
            if register_descript:
                tooltip.Tooltip(Rows.widget_dict['Register Name'][reg_index],
                                register_descript)
        except IndexError:
            pass
Esempio n. 5
0
File: gui.py Progetto: Delor4/Planer
 def add_tooltip_for_day(self, form, day):
     text = []
     for n in self.state.get_textnotes(day):
         text.append(n['value'])
     tooltip.Tooltip(form, text="\n------\n".join(text))
Esempio n. 6
0
    def calculation_frame(self, frame):
        # dout; outer dimension of coil
        self.label_calc_dout = ttk.Label(
            frame, text='Calculated  outer diameter (dout):')
        self.label_calc_dout.grid(row=12,
                                  column=1,
                                  padx=self.padding,
                                  pady=self.padding,
                                  sticky='w')
        self.entry_calc_dout = ttk.Entry(frame, width=20)
        self.entry_calc_dout.grid(row=12, column=3, sticky='w')
        self.label_calc_dout = ttk.Label(frame, text="mm")
        self.label_calc_dout.grid(row=12,
                                  column=5,
                                  padx=self.padding,
                                  pady=self.padding,
                                  sticky='e')

        # rho; fill factor
        self.label_calc_rho = ttk.Label(frame,
                                        text='Calculated fill factor (rho):')
        self.label_calc_rho.grid(row=14,
                                 column=1,
                                 padx=self.padding,
                                 pady=self.padding,
                                 sticky='w')
        self.entry_calc_rho = ttk.Entry(frame, width=20)
        self.entry_calc_rho.grid(row=14, column=3, sticky='w')
        tp.Tooltip(self.label_calc_rho,
                   text=u'Fill factor, \u03C1=(dout-din)/(dout+din)',
                   wraplength=200)

        # modified wheeler
        self.label_calc_mw = ttk.Label(frame, text='Modified Wheeler:')
        self.label_calc_mw.grid(row=16,
                                column=1,
                                padx=self.padding,
                                pady=self.padding,
                                sticky='w')
        self.entry_calc_mw = ttk.Entry(frame, width=20)
        self.entry_calc_mw.grid(row=16, column=3, sticky='w')
        self.label_calc_mw_units = ttk.Label(frame, text="H")
        self.label_calc_mw_units.grid(row=16,
                                      column=5,
                                      padx=self.padding,
                                      pady=self.padding,
                                      sticky='e')
        tp.Tooltip(self.label_calc_mw,
                   text=u'A modification of the original Wheeler formula.',
                   wraplength=200)

        # current sheet
        self.label_calc_cs = ttk.Label(frame, text='Current Sheet:')
        self.label_calc_cs.grid(row=18,
                                column=1,
                                padx=self.padding,
                                pady=self.padding,
                                sticky='w')
        self.entry_calc_cs = ttk.Entry(frame, width=20)
        self.entry_calc_cs.grid(row=18, column=3, sticky='w')
        self.label_calc_cs = ttk.Label(frame, text="H")
        self.label_calc_cs.grid(row=18,
                                column=5,
                                padx=self.padding,
                                pady=self.padding,
                                sticky='e')

        # monomial fit
        self.label_calc_mf = ttk.Label(frame, text='Monomial Fit:')
        self.label_calc_mf.grid(row=20,
                                column=1,
                                padx=self.padding,
                                pady=self.padding,
                                sticky='w')
        self.entry_calc_mf = ttk.Entry(frame, width=20)
        self.entry_calc_mf.grid(row=20, column=3, sticky='w')
        self.label_calc_mf = ttk.Label(frame, text="H")
        self.label_calc_mf.grid(row=20,
                                column=5,
                                padx=self.padding,
                                pady=self.padding,
                                sticky='e')

        # Fasthenry`
        self.label_calc_fh = ttk.Label(frame, text='Fasthenry:')
        self.label_calc_fh.grid(row=22,
                                column=1,
                                padx=self.padding,
                                pady=self.padding,
                                sticky='w')
        self.entry_calc_fh = ttk.Entry(frame, width=20)
        self.entry_calc_fh.grid(row=22, column=3, sticky='w')
        self.label_calc_fh = ttk.Label(frame, text="H")
        self.label_calc_fh.grid(row=22,
                                column=5,
                                padx=self.padding,
                                pady=self.padding,
                                sticky='e')
Esempio n. 7
0
    def input_frame(self, frame):
        self.label_n = ttk.Label(frame,
                                 text="Number of turns (n):",
                                 background='')
        self.label_n.grid(row=1,
                          column=1,
                          padx=self.padding,
                          pady=self.padding,
                          sticky='wn')
        self.label_d = ttk.Label(frame, text="Inner dimension (din)")
        self.label_d.grid(row=3,
                          column=1,
                          padx=self.padding,
                          pady=self.padding,
                          sticky='w')
        self.label_w = ttk.Label(frame, text="Track width (w:)")
        self.label_w.grid(row=5,
                          column=1,
                          padx=self.padding,
                          pady=self.padding,
                          sticky='w')
        self.label_s = ttk.Label(frame, text="Spacing between turns (s):")
        self.label_s.grid(row=7,
                          column=1,
                          padx=self.padding,
                          pady=self.padding,
                          sticky='w')

        self.entry_n = ttk.Entry(frame,
                                 width=20,
                                 textvariable=self.n,
                                 validate='all',
                                 validatecommand=self.validate)
        self.entry_n.grid(row=1, column=3)
        self.entry_n.focus()
        self.entry_d = ttk.Entry(frame,
                                 width=20,
                                 textvariable=self.din,
                                 validate='all',
                                 validatecommand=self.validate)
        self.entry_d.grid(row=3, column=3)
        self.entry_w = ttk.Entry(frame,
                                 width=20,
                                 textvariable=self.w,
                                 validate='all',
                                 validatecommand=self.validate)
        self.entry_w.grid(row=5, column=3)
        self.entry_s = ttk.Entry(frame,
                                 width=20,
                                 textvariable=self.s,
                                 validate='all',
                                 validatecommand=self.validate)
        self.entry_s.grid(row=7, column=3)

        self.label_n_units = ttk.Label(frame, text="")
        self.label_n_units.grid(row=1,
                                column=5,
                                padx=self.padding,
                                pady=self.padding,
                                sticky='e')
        self.label_d_units = ttk.Label(frame, text="mm")
        self.label_d_units.grid(row=3,
                                column=5,
                                padx=self.padding,
                                pady=self.padding,
                                sticky='e')
        self.label_w_units = ttk.Label(frame, text="mm")
        self.label_w_units.grid(row=5,
                                column=5,
                                padx=self.padding,
                                pady=self.padding,
                                sticky='e')
        self.label_s_units = ttk.Label(frame, text="mm")
        self.label_s_units.grid(row=7,
                                column=5,
                                padx=self.padding,
                                pady=self.padding,
                                sticky='e')

        self.button_calc = ttk.Button(frame,
                                      text='Calculate Inductance',
                                      state=NORMAL)
        self.button_calc.grid(row=9,
                              column=1,
                              padx=self.padding,
                              pady=self.padding,
                              sticky='w')
        self.button_calc.config(command=self.callback_calc)

        self.button_clr = ttk.Button(frame, text='Reset')
        self.button_clr.grid(row=9,
                             column=3,
                             padx=self.padding,
                             pady=self.padding,
                             sticky='w')
        self.button_clr.config(command=self.callback_clr)

        self.button_example = ttk.Button(frame, text='Example')
        self.button_example.grid(row=9,
                                 column=5,
                                 padx=self.padding,
                                 pady=self.padding,
                                 sticky='w')
        self.button_example.config(command=self.callback_dfts)
        tp.Tooltip(
            self.button_example,
            text=
            'Example parameters will be placed into the parameter fields that result in an inductance of 16.5e-06H',
            wraplength=100)
        tp.Tooltip(
            self.button_calc,
            text=
            'Reference: Simple Accurate Expressions for Planar Spiral Inductances, IEEE Journal of Solid-State Circuits, Oct. 1999, pp. 1419-25.',
            wraplength=100)

        self.entry_n.focus()
Esempio n. 8
0
    def minimum_params_frame(self, frame):

        self.label_n_min = ttk.Label(frame, text='Minimum number of turns:')
        self.label_n_min.grid(row=0,
                              column=1,
                              padx=self.padding,
                              pady=self.padding,
                              sticky='w')
        self.entry_n_min = ttk.Entry(frame,
                                     width=20,
                                     textvariable=self.min_n,
                                     validate='all',
                                     validatecommand=self.validate)
        self.entry_n_min.grid(row=0, column=3)
        self.label_n_min_units = ttk.Label(frame, text="")
        self.label_n_min_units.grid(row=0,
                                    column=5,
                                    padx=self.padding,
                                    pady=self.padding,
                                    sticky='e')
        tp.Tooltip(self.label_n_min,
                   text=u'The minimum number of turns allowed, an integer.',
                   wraplength=200)

        self.label_d_min = ttk.Label(frame, text='Minimum inner dimension:')
        self.label_d_min.grid(row=2,
                              column=1,
                              padx=self.padding,
                              pady=self.padding,
                              sticky='w')
        self.entry_d_min = ttk.Entry(frame,
                                     width=20,
                                     textvariable=self.min_din,
                                     validate='all',
                                     validatecommand=self.validate)
        self.entry_d_min.grid(row=2, column=3)
        self.label_d_min_units = ttk.Label(frame, text="mm")
        self.label_d_min_units.grid(row=2,
                                    column=5,
                                    padx=self.padding,
                                    pady=self.padding,
                                    sticky='e')
        tp.Tooltip(
            self.label_d_min,
            text=
            u'The minimum inner dimension based on via dimensions. You will not noramally need to change this value.',
            wraplength=200)

        self.label_w_min = ttk.Label(frame, text='Minimum track width:')
        self.label_w_min.grid(row=4,
                              column=1,
                              padx=self.padding,
                              pady=self.padding,
                              sticky='w')
        self.entry_w_min = ttk.Entry(frame,
                                     width=20,
                                     textvariable=self.min_w,
                                     validate='all',
                                     validatecommand=self.validate)
        self.entry_w_min.grid(row=4, column=3)
        self.label_w_min_units = ttk.Label(frame, text="mm")
        self.label_w_min_units.grid(row=4,
                                    column=5,
                                    padx=self.padding,
                                    pady=self.padding,
                                    sticky='e')
        tp.Tooltip(
            self.label_w_min,
            text=
            u'The minimum track width. This value is obtained from the PCB manufacturer.',
            wraplength=200)

        self.label_s_min = ttk.Label(frame,
                                     text='Minimum spacing between tracks:')
        self.label_s_min.grid(row=6,
                              column=1,
                              padx=self.padding,
                              pady=self.padding,
                              sticky='w')
        self.entry_s_min = ttk.Entry(frame,
                                     width=20,
                                     textvariable=self.min_s,
                                     validate='all',
                                     validatecommand=self.validate)
        self.entry_s_min.grid(row=6, column=3)
        self.label_s_min_units = ttk.Label(frame, text="mm")
        self.label_s_min_units.grid(row=6,
                                    column=5,
                                    padx=self.padding,
                                    pady=self.padding,
                                    sticky='e')
        tp.Tooltip(
            self.label_s_min,
            text=
            u'The minimum spacing between turns. This value is obtained from the PCB manufacturer.',
            wraplength=200)

        self.label_c = ttk.Label(frame, text='Track thickness:')
        self.label_c.grid(row=8,
                          column=1,
                          padx=self.padding,
                          pady=self.padding,
                          sticky='w')
        self.entry_c = ttk.Entry(frame,
                                 width=20,
                                 textvariable=self.min_c,
                                 validate='all',
                                 validatecommand=self.validate)
        self.entry_c.grid(row=8, column=3)
        self.label_c_units = ttk.Label(frame, text="mm")
        self.label_c_units.grid(row=8,
                                column=5,
                                padx=self.padding,
                                pady=self.padding,
                                sticky='e')
        tp.Tooltip(
            self.label_c,
            text=
            u'The track thickness for the type of PCB substrate being used. It is only used by FastHenry in determining the parameters for a given inductance.',
            wraplength=200)