def add_file_info_box(self, mainframe, name, labeldict, btncallback, fvar):
        """
        Create and add a infobox containing the info about a loaded
        savegame.
        """
        title = {'source':'Copy face from source file:',
                 'target':'To target file:'}
        frame = LabelFrame(mainframe, text=title[name])
        frame.pack(anchor=N, fill=X, expand=1, side=TOP, padx=0, pady=0)
        frame.columnconfigure(1, weight=1)

        btn = Button(frame, text='Browse', command=btncallback)
        btn.grid(column=0, row=0, padx=2, pady=2)

        field = Entry(frame, width=50, textvariable=fvar)
        field.grid(column=1, row=0, columnspan=2, padx=2, pady=2, sticky=W+E)

        l = ('name','gender','level','race','location','save number','playing time')
        for n, (i, j) in enumerate([(x.capitalize()+':', x) for x in l]):
            Label(frame, text=i, state=DISABLED).grid(column=0, row=n+1, padx=4,
                                                      pady=3, sticky=E)
            labeldict[j] = StringVar()
            Label(frame, textvariable=labeldict[j]).grid(column=1, row=n+1,
                                                     padx=4, pady=3, sticky=W)
        self.screenshot[name] = Label(frame)
        self.screenshot[name].grid(column=2, row=1, rowspan=len(l),
                                   padx=4, pady=4)
Esempio n. 2
0
def settings():
    global settings_popup
    try: settings_popup.destroy()
    except: pass
    settings_styles = Style()
    settings_styles.configure(
        "SettingsLabelframe.TLabelframe.Label", font=("Verdana", 18, "normal"))
    settings_styles.configure(
        "SettingsLabelframe.TLabelframe.Label", foreground=COLORS['TEXTCOLOR'])

    settings_popup = Toplevel()
    settings_popup.title("Settings")
    settings_popup.transient(root)
    settings_popup.resizable(False, False)

    other_frame = LabelFrame(settings_popup, text="Settings", style="SettingsLabelframe.TLabelframe")
    basefreq_lbl = Label(other_frame, text="Octave")
    basefreq_om = OptionMenu(other_frame, OPTIONS['BASE_FREQ'], BASE_FREQS[-1], *BASE_FREQS)
    

    basefreq_lbl.grid(row=0, column=0, padx=5)
    basefreq_om.grid(row=0, column=1, padx=5)
    other_frame.pack(padx=15, pady=15, ipadx=5, ipady=5)

    settings_popup.mainloop()
Esempio n. 3
0
def statistics(df, dictionaries):
    """ фомрмирование статистик """
    global stat
    report = Toplevel()
    qty = StringVar(report)
    headers = [item for item in df if item not in ['Цена', 'Билет', 'Время']]
    q1 = LabelFrame(report, text='Качественные')
    q2 = LabelFrame(report, text='Количественные')
    choice = Combobox(q1, values=headers, textvariable=qty)
    qty.trace('w', lambda name, index, mode, sv=qty: updateBoxes(sv))
    qty.set(headers[0])
    choice.current(0)
    choice.pack(side=LEFT, padx=5, pady=5)
    q1.pack(side=TOP, padx=10, pady=10)
    choice2 = Combobox(q2, values=['Цена'])
    choice2.pack(side=LEFT, padx=5, pady=5)
    choice2.current(0)
    choice2.config(state=DISABLED)
    q2.pack(side=TOP, padx=10, pady=10)
    bframe = Frame(report)
    Button(bframe, text='Сформировать', command=lambda frame=df: text_report_old(frame))\
        .pack(side=LEFT, padx=10, pady=10)
    Button(bframe, text='Закрыть', command=lambda: report.destroy())\
        .pack(side=LEFT, padx=10, pady=10)
    bframe.pack(side=TOP)
Esempio n. 4
0
    def __init__(self, szulo, **kw):
        super().__init__(szulo, text="ajánlat", **kw)

        self._ajanlatiar = StringVar()
        self._leadva = StringVar()
        self._ervenyes = StringVar()
        self._megjegyzes = StringVar()
        self._esely = IntVar()

        rovidek = Frame(self)

        ar = LabelFrame(rovidek, text="ajánlati ár")
        self._fokusz = Entry(ar, textvariable=self._ajanlatiar, width=10)
        self._fokusz.pack(ipadx=2, ipady=2, side=LEFT)
        Label(ar, text="Ft").pack(ipadx=2, ipady=2)
        ar.pack(padx=2, ipady=2, side=LEFT)

        leadva = LabelFrame(rovidek, text="leadva")
        Entry(leadva, textvariable=self._leadva, width=10).pack(ipadx=2,
                                                                ipady=2)
        leadva.pack(ipadx=2, ipady=2, side=LEFT, padx=10)

        ervenyes = LabelFrame(rovidek, text="érvényes")
        Entry(ervenyes, textvariable=self._ervenyes, width=10).pack(ipadx=2,
                                                                    ipady=2)
        ervenyes.pack(ipadx=2, ipady=2, side=LEFT)

        rovidek.pack(ipadx=2, ipady=2, fill=BOTH)

        esely = LabelFrame(self, text="esélylatolgatás")
        Radiobutton(esely,
                    variable=self._esely,
                    text="bukott",
                    value=Esely.BUKOTT.ertek).pack(ipadx=2, ipady=2, side=LEFT)
        Radiobutton(esely,
                    variable=self._esely,
                    text="normál",
                    value=Esely.NORMAL.ertek).pack(ipadx=2, ipady=2, side=LEFT)
        Radiobutton(esely,
                    variable=self._esely,
                    text="érdekes",
                    value=Esely.ERDEKES.ertek).pack(ipadx=2,
                                                    ipady=2,
                                                    side=LEFT)
        Radiobutton(esely,
                    variable=self._esely,
                    text="végső",
                    value=Esely.VEGSO.ertek).pack(ipadx=2, ipady=2)
        esely.pack(ipadx=2, ipady=2, fill=BOTH)

        megjegyzes = LabelFrame(self, text="megjegyzés")
        Entry(megjegyzes, textvariable=self._megjegyzes,
              width=40).pack(ipadx=2, ipady=2, side=LEFT)
        megjegyzes.pack(ipadx=2, ipady=2, fill=BOTH)
Esempio n. 5
0
    def body(self, szulo):
        self._projekt_valaszto = Valaszto("megnevezés", self._projektek(),
                                          self)
        self._projekt_valaszto.set_callback(self._projekt_megjelenit)
        self._projekt_valaszto.pack(ipadx=2, ipady=2)

        megnevezes = LabelFrame(self, text="projekt neve")
        self._projekt_urlap = ProjektUrlap(megnevezes)
        self._projekt_urlap.pack(ipadx=2, ipady=2)
        self._projekt_megjelenit(1)
        megnevezes.pack(fill=X, padx=2, pady=2)

        return self._projekt_valaszto.valaszto
Esempio n. 6
0
 def get_info(self):
     x, y = (self.size[0]/2, self.size[1]/2)
     for i in self.info:
         label_frame= LabelFrame(self, text="name")
         label_frame.pack(fill="y")
         for entry in self.info[i]["Entry"]:
             frame = Frame(label_frame)
             frame.pack(fill="x")
             label = Label(label_frame, text=self.info[i]["Entry"][entry], width=6)
             label.pack(side="left", anchor="n", padx=5, pady=5)
         for text in self.info[i]["Text"]:
             frame = Frame(label_frame)
             frame.pack(fill="x")
             label = Label(label_frame, text=self.info[i]["Text"][text], width=6)
             label.pack(side="left", anchor="n", padx=5, pady=5)
     window = self.canvas.create_window(x, y, window=label_frame, tag="test")
Esempio n. 7
0
 def init_ui(self):
     self.master.title("Speech Demo")
     self.pack(fill=BOTH, expand=True)
     label_frame = LabelFrame(self, text="System words")
     label_frame.pack(fill=X, padx=40, pady=20)
     self.labels = []
     rows = 8
     cols = 2
     for j in range(rows):
         for i in range(cols):
             k = i + j * cols
             label = Label(label_frame, text=labels[k])
             label.config(font=("Cambria Math", 20))
             label.grid(row=j, column=i, padx=20, pady=10)
             self.labels += [label]
     self.selected = None
     self.after(100, self.ontick)
Esempio n. 8
0
def make_pivot(df, dicts):
    """ формирование сводной таблицы """
    report = Toplevel()
    radio = Frame(report)
    buttons = Frame(report)
    param1 = LabelFrame(radio, text='1-й параметр')
    param2 = LabelFrame(radio, text='2-й параметр')
    options = [item for item in df][:-1]
    options.pop(options.index('Цена'))
    value_var_1 = IntVar()
    value_var_2 = IntVar()
    count = 0
    for item in options:
        Radiobutton(param1, text=item, variable=value_var_1, value=count,
                    command=lambda num=value_var_1: trace_rb(num, None)) \
            .pack(side=TOP, anchor='w')
        Radiobutton(param2, text=item, variable=value_var_2, value=count,
                    command=lambda num=value_var_2: trace_rb(num, None)) \
            .pack(side=TOP, anchor='w')
        count += 1
    param1.pack(side=LEFT, padx=(20, 5), pady=(20, 10))

    res = {'Минимум': np.min, 'Максимум': np.max}
    picker = Frame(report)
    Label(picker, text='Метод агрегации') \
        .pack(side=LEFT, anchor='w', padx=10, pady=10)
    method = StringVar(report)
    m_combo = Combobox(picker,
                       values=[item for item in res.keys()],
                       textvariable=method)
    m_combo.current(0)
    m_combo.pack(side=LEFT, padx=10, pady=10, anchor='e')

    Button(buttons, text='Сформировать',
           command=lambda v0=df, v1=value_var_1, v2=value_var_2, v3=options, fr=report, m=method, m_dic=res:
           pivot_export(v0, v1, v2, v3, fr, m, m_dic)) \
        .pack(side=LEFT, anchor='w', padx=10, pady=10)
    param2.pack(side=LEFT, padx=(5, 20), pady=(20, 10))
    Button(buttons, text='Закрыть', command=lambda: report.destroy()) \
        .pack(side=RIGHT, anchor='e', padx=10, pady=10)

    radio.pack(side=TOP)
    picker.pack(side=TOP)
    buttons.pack(side=TOP)
    value_var_1.set(0)
    value_var_2.set(0)
Esempio n. 9
0
    def init_ui(self, rows=4, cols=3):
        """ setup the GUI for the app """
        self.master.title("Speech Demo")
        self.pack(fill=BOTH, expand=True)

        label_frame = LabelFrame(self, text="Try these categories")
        label_frame.pack(fill=X, padx=10, pady=10)
        self.labels = []

        for j in range(rows):
            for i in range(cols):
                k = i + j * cols
                label = Label(label_frame, text=self.skeet[k])
                label.config(font=("Courier", 36))
                label.grid(row=j, column=i, padx=10, pady=10)
                self.labels += [label]
        self.selected = None
        self.after(100, self.on_tick)
Esempio n. 10
0
 def update_history(self):
     if Task.tasks:
         for task in Task.tasks:
             if task.on_display == False:
                 history_instance = LabelFrame(self.moving_frame,
                                               text=task.task_name)
                 Label(
                     history_instance,
                     text=
                     f'Task Duration: {datetime.timedelta(seconds=task.task_duration)}'
                 ).pack()
                 Label(
                     history_instance,
                     text=f'Break Duration: {task.break_duration}').pack()
                 Label(history_instance,
                       text=f'Made on: {task.init_date}').pack()
                 history_instance.pack(anchor='n', fill='both')
                 task.on_display = True
Esempio n. 11
0
    def initUI(self):

        self.parent.title("LabelFrame")
        self.pack(fill=BOTH, expand=True)

        labFrame = LabelFrame(self, text="Address")

        nameLbl = Label(labFrame, text="Street:")
        nameLbl.grid(row=0, column=0, padx=10, pady=10, sticky=E)
        self.streetEntry = Entry(labFrame)
        self.streetEntry.grid(row=0, column=1)

        addrLbl = Label(labFrame, text="Postal code:")
        addrLbl.grid(row=1, column=0, padx=10, sticky=E)
        self.postEntry = Entry(labFrame)
        self.postEntry.grid(row=1, column=1)

        labFrame.pack(anchor=N + W, ipadx=20, ipady=20, padx=15, pady=15)

        btn = Button(self, text="OK", command=self.buttonClick)
        btn.pack(pady=20)
Esempio n. 12
0
    def __init__(self, szulo, kon):
        self._kon = kon
        super().__init__(szulo)

        self._erkezett = StringVar()
        self._hatarido = StringVar()
        self._megjegyzes = StringVar()

        self._kontakt_valaszto = Valaszto("ajánlatkérő", self._kontaktszemelyek(), self)
        self._kontakt_valaszto.pack(ipadx=2, ipady=2)
        self._jelleg_valaszto = Valaszto("projekt", self._jellegek(), self)
        self._jelleg_valaszto.pack(ipadx=2, ipady=2)

        megjegyzes = LabelFrame(self, text="megjegyzés")
        Entry(megjegyzes, textvariable=self._megjegyzes, width=40).pack(ipadx=2, ipady=2, side=LEFT)
        megjegyzes.pack(ipadx=2, ipady=2, side=BOTTOM, fill=BOTH)

        self._temafelelos_valaszto = Valaszto("témafelelős", self._kontaktszemelyek(2), self)
        self._temafelelos_valaszto.pack(ipadx=2, ipady=2, side=BOTTOM)

        erkezett = LabelFrame(self, text="érkezett")
        Entry(erkezett, textvariable=self._erkezett, width=10).pack(ipadx=2, ipady=2)
        erkezett.pack(ipadx=2, ipady=2, side=LEFT)
        hatarido = LabelFrame(self, text="leadási határidő")
        Entry(hatarido, textvariable=self._hatarido, width=10).pack(ipadx=2, ipady=2)
        hatarido.pack(ipadx=2, ipady=2, side=LEFT)        
        ma = date.isoformat(date.today())
        egyhetmulva = date.isoformat(date.today() + timedelta(days=7))
        self._erkezett.set(ma)
        self._hatarido.set(egyhetmulva)
Esempio n. 13
0
    def add_file_info_box(self, mainframe, name, labeldict, btncallback, fvar):
        """
        Create and add a infobox containing the info about a loaded
        savegame.
        """
        title = {
            'source': 'Copy face from source file:',
            'target': 'To target file:'
        }
        frame = LabelFrame(mainframe, text=title[name])
        frame.pack(anchor=N, fill=X, expand=1, side=TOP, padx=0, pady=0)
        frame.columnconfigure(1, weight=1)

        btn = Button(frame, text='Browse', command=btncallback)
        btn.grid(column=0, row=0, padx=2, pady=2)

        field = Entry(frame, width=50, textvariable=fvar)
        field.grid(column=1, row=0, columnspan=2, padx=2, pady=2, sticky=W + E)

        l = ('name', 'gender', 'level', 'race', 'location', 'save number',
             'playing time')
        for n, (i, j) in enumerate([(x.capitalize() + ':', x) for x in l]):
            Label(frame, text=i, state=DISABLED).grid(column=0,
                                                      row=n + 1,
                                                      padx=4,
                                                      pady=3,
                                                      sticky=E)
            labeldict[j] = StringVar()
            Label(frame, textvariable=labeldict[j]).grid(column=1,
                                                         row=n + 1,
                                                         padx=4,
                                                         pady=3,
                                                         sticky=W)
        self.screenshot[name] = Label(frame)
        self.screenshot[name].grid(column=2,
                                   row=1,
                                   rowspan=len(l),
                                   padx=4,
                                   pady=4)
Esempio n. 14
0
 def get_info(self):
     x, y = (self.size[0] / 2, self.size[1] / 2)
     for i in self.info:
         label_frame = LabelFrame(self, text="name")
         label_frame.pack(fill="y")
         for entry in self.info[i]["Entry"]:
             frame = Frame(label_frame)
             frame.pack(fill="x")
             label = Label(label_frame,
                           text=self.info[i]["Entry"][entry],
                           width=6)
             label.pack(side="left", anchor="n", padx=5, pady=5)
         for text in self.info[i]["Text"]:
             frame = Frame(label_frame)
             frame.pack(fill="x")
             label = Label(label_frame,
                           text=self.info[i]["Text"][text],
                           width=6)
             label.pack(side="left", anchor="n", padx=5, pady=5)
     window = self.canvas.create_window(x,
                                        y,
                                        window=label_frame,
                                        tag="test")
Esempio n. 15
0
    def body(self, szulo):

        megnevezes = LabelFrame(self, text="projekt neve")
        self._projekt_urlap = ProjektUrlap(megnevezes)
        self._projekt_urlap.pack(ipadx=2, ipady=2)
        self._projekt_urlap.projektszam = "{}/{}".format(self._ev, self._szam)
        megnevezes.pack(fill=X, padx=2, pady=2)

        cim = LabelFrame(self, text="projekt címe")
        self._cim_urlap = CimUrlap(cim)
        self._cim_urlap.pack(ipadx=2, ipady=2)
        cim.pack(padx=2, pady=2)

        munkaresz = LabelFrame(self, text="munkarész")
        self._munkaresz_urlap = MunkareszUrlap(munkaresz)
        self._munkaresz_urlap.pack(ipadx=2, ipady=2)
        munkaresz.pack(fill=X, padx=2, pady=2)

        jelleg = LabelFrame(self, text="jelleg")
        self._jelleg_urlap = JellegUrlap(jelleg)
        self._jelleg_urlap.pack(ipadx=2, ipady=2)
        jelleg.pack(fill=X, padx=2, pady=2)

        return self._projekt_urlap.fokusz
Esempio n. 16
0
    def body(self, szulo):
        self._projekt_valaszto = Valaszto("projekt", self._projektek(), self)
        self._projekt_valaszto.set_callback(self._cim_megjelenit)
        self._projekt_valaszto.pack(ipadx=2, ipady=2)

        munkaresz = LabelFrame(self, text="munkarész")
        self._munkaresz_urlap = MunkareszUrlap(munkaresz)
        self._munkaresz_urlap.pack(ipadx=2, ipady=2)
        munkaresz.pack(fill=X, padx=2, pady=2)

        cim = LabelFrame(self, text="munkarész címe")
        self._cim_urlap = CimUrlap(cim)
        self._cim_urlap.pack(ipadx=2, ipady=2)
        self._cim_megjelenit(1)
        cim.pack(padx=2, pady=2)

        jelleg = LabelFrame(self, text="munkarész jellege")
        self._jelleg_urlap = JellegUrlap(jelleg)
        self._jelleg_urlap.pack(ipadx=2, ipady=2)
        jelleg.pack(fill=X, padx=2, pady=2)

        return self._projekt_valaszto.valaszto
Esempio n. 17
0
    def init_project_frame( self ) :
        projframe = Frame(self)
        
        ######################
        #The Project Entry Form
        #
        #Current design inherited from others
        #is very bad. It should have been made as
        #json or dictionary as is in this point
        #then the subsequent coding will be much
        #eaiser.
        #BK
        ######################
        BS=StringVar()

        self.eprojectid = eprojectid= StringVar()
        self.eorganism = eorganism=StringVar()
        self.eanalyst = eanalyst=StringVar()
        self.epoc = epoc=StringVar()
        self.epi = epi=StringVar()
        self.euser = euser=StringVar()
        self.eflowcell = eflowcell=StringVar()
        self.eplatform = eplatform=StringVar()
        eplatform.set("Illumina")
        self.technique = technique=StringVar()
        self.pipehome = pipehome=StringVar()
        pipehome.set(PIPELINER_HOME)

        editframe = Frame( self )
        editframe.grid( column=0, row=3, columnspan=3 )
        
        projpanel1 = LabelFrame(editframe,text="Project Information") 
        #,fg=textLightColor,bg=baseColor)
        projpanel1.pack( side = TOP, fill=X, padx=10, pady=5, expand=YES )
        
        pipeline_panel = LabelFrame(editframe, text="Global Settings")
        pipeline_panel.pack( side=TOP, fill=X, padx=10, pady=5, expand=YES )
        
        l=Label( pipeline_panel, text="Genome:" )
        l.grid(row=1,column=3,sticky=W,padx=0,pady=5)
        l = Label( pipeline_panel, text="Pipeline Family:" )
        l.grid(row=1,column=1,sticky=W,padx=0,pady=5)
        
        annotations=['hg19','mm10','mm9','hg38','GRCh38']
        self.annotation = annotation = StringVar()
        annotation.set(annotations[0])
        #annotation.trace('w', lambda *_ :settargets(annotation) )
        
        om = OptionMenu(pipeline_panel, annotation, *annotations, command=self.set_pipeline)
        #, command=lambda _:makejson("refsets"))
        om.config() #bg = widgetBgColor,fg=widgetFgColor)
        om["menu"].config() #bg = widgetBgColor,fg=widgetFgColor)
        om.grid(row=1,column=4,sticky=W,padx=10,pady=10)
        
        pfamilys = ['exomeseq', 'rnaseq', 'genomeseq', 'mirseq', 'ChIPseq', 'scrnaseq']
        self.pfamily = pfamily = StringVar()
        pfamily.set('Select a pipeline')
        om = OptionMenu(pipeline_panel, pfamily, *pfamilys, command=self.set_pipeline)
        #, command=lambda _:makejson(pfamily.get()))
        om.config() #bg = widgetBgColor,fg=widgetFgColor)
        om["menu"].config() #bg = widgetBgColor,fg=widgetFgColor)
        om.grid(row=1,column=2,sticky=W,padx=10,pady=5)
        #add_button = Button( pipeline_panel, 
        #                    text="Set a pipeline", 
        #                    command=self.add_pipeline
        #                   )
        #add_button.grid(row=1, column=5, sticky=W, padx=10, pady=5)
        
        self.notebook = notebook = Notebook( editframe )
        self.pipelineframe = None #the pipeline frame in the notebook frame!
        
        projpanel2 = Frame(notebook) #,fg=textLightColor,bg=baseColor)
        projpanel2.pack( side = LEFT, fill=BOTH, padx=10, pady=5, expand=YES )
        notebook.add( projpanel2, text="Project Description" )
        notebook.pack( side=LEFT, fill=BOTH, padx=10, pady=5, expand=YES )

        Dscrollbar = Scrollbar(projpanel2)
        Dscrollbar.grid(row=2,column=4,rowspan=40)
        
        self.description =description= Text(projpanel2,
                           width=75,
                           height=28,
                           #bg=commentBgColor,
                           #fg=commentFgColor,
                           font=("nimbus mono bold","10"),
                           yscrollcommand = Dscrollbar.set)  
        
        description.delete("1.0", END)
        description.insert(INSERT, "Enter CCBR Project Description and Notes here.")
        #description.bind('<FocusOut>',lambda _:makejson("none"))
        description.grid(row=2,column=3,sticky="e",padx=10,pady=5)
        Dscrollbar['command']=description.yview
        
        L=Label(projpanel1, text="Project Id", anchor="ne" )
        #,bg=baseColor,fg=textLightColor)
        E = Entry(projpanel1, 
                  bd =2, 
                  width=20, 
                  #bg=entryBgColor, 
                  #fg=entryFgColor, 
                  textvariable=eprojectid 
                 )
        #L.pack(pady=5,padx=5)
        #E.pack(pady=1,padx=5)
        L.grid(row=0, column=0, sticky=W, padx=10, pady=5)
        E.grid(row=0, column=2, sticky=W, padx=10, pady=5)
        eprojectid.set("project")
        #eprojectid.trace('w', makejson)
        L2=Label(projpanel1,
                 text = "(Examples: CCBR-nnn,Labname or short project name)",
                 anchor="ne"
                )#,bg="firebrick",fg="white")
        L2.grid(row=0, column=3, padx=10, pady=5, sticky="w")

        L=Label( projpanel1,
                text="Email address",
                anchor="ne")#,bg=baseColor,fg=textLightColor)
        
        E = Entry( projpanel1, 
                  bd =2, 
                  width=20, 
                  #bg=entryBgColor, 
                  #fg=entryFgColor,
                  textvariable=euser)
        
        L3 = Label(projpanel1,
                   text ="(Mandatory field: must use @nih.gov email address)",
                   anchor="ne")
        L3.grid(row=1,column=3,padx=10,pady=5,sticky="w")
        L.grid(row=1,column=0,sticky=W,padx=10,pady=5)
        E.grid(row=1,column=2,sticky=W,padx=10,pady=5)

        #euser.trace('w', makejson)

        L=Label(projpanel1,text="Flow Cell ID",anchor="ne")
        E = Entry(projpanel1, bd =2, width=20, textvariable=eflowcell )#, bg=entryBgColor)
        L4=Label( projpanel1,
                 text="(Examples: FlowCellID, Labname, date or short project name)",
                 anchor="ne" 
                )#,bg="firebrick",fg="white")
        L4.grid(row=2,column=3,padx=10,pady=5,sticky="w")
        L.grid(row=2,column=0,sticky=W,padx=10,pady=5)
        E.grid(row=2,column=2,sticky=W,padx=10,pady=5)
        eflowcell.set("stats")
        #eflowcell.trace('w', makejson)

        Projscrollbar = Scrollbar(projframe)
        Projscrollbar.grid(row=2,column=4,rowspan=30 )
        self.jsonconf = jsonconf = Text( projframe,
                        width=80,
                        height=30,
                        #bg=projectBgColor,
                        #fg=projectFgColor,
                        font=("nimbus mono bold","11"),
                        yscrollcommand = Projscrollbar.set)
        
        Projscrollbar['command']=jsonconf.yview
        jsonconf.grid(row=3,column=0,sticky="e",padx=10,pady=5)
Esempio n. 18
0
    def init_ui(self):
        """ setup the GUI for the app """
        self.master.title("Test")
        self.pack(fill=BOTH, expand=True)

        # Input section
        input_frame = LabelFrame(self, text="Input")
        input_frame.bind("-", self.on_minus_key)
        input_frame.bind("+", self.on_plus_key)
        input_frame.pack(fill=X)
        self.play_button = Button(input_frame, text="Play", command=self.on_play_button_click)
        self.play_button.pack(side=RIGHT, padx=4)
        self.rec_button = Button(input_frame, text="Rec", command=self.on_rec_button_click)
        self.rec_button.pack(side=RIGHT, padx=4)
        self.wav_filename_entry = Entry(input_frame, width=24)
        self.wav_filename_entry.pack(fill=X)
        self.wav_filename_entry.delete(0, END)
        if self.wav_filename:
            self.wav_filename_entry.insert(0, self.wav_filename)

        # Feature section
        features_frame = LabelFrame(self, text="Features")
        features_frame.pack(fill=X)

        features_control_frame = Frame(features_frame)
        features_control_frame.pack(fill=X)
        load_features_button = Button(features_control_frame, text="Load", command=self.on_load_featurizer_model)
        load_features_button.pack(side=RIGHT)
        self.features_entry = Entry(features_control_frame, width=8)
        self.features_entry.pack(fill=X)
        self.features_entry.delete(0, END)
        if self.featurizer_model:
            self.features_entry.insert(0, self.featurizer_model)

        viz_frame = Frame(features_frame)
        viz_frame.pack(fill=X)
        self.features_figure = Figure(figsize=(5, 4), dpi=100)
        self.subplot = self.features_figure.add_subplot(111)

        canvas = FigureCanvasTkAgg(self.features_figure, master=viz_frame)
        canvas.draw()
        canvas.show()
        canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=True)

        # Classifier section
        classifier_frame = LabelFrame(self, text="Classifier")
        classifier_frame.pack(fill=X)
        load_classifier_button = Button(classifier_frame, text="Load", command=self.on_load_classifier)
        load_classifier_button.pack(side=RIGHT)
        self.classifier_entry = Entry(classifier_frame, width=8)
        self.classifier_entry.pack(fill=X)
        self.classifier_entry.delete(0, END)
        if self.classifier_model:
            self.classifier_entry.insert(0, self.classifier_model)

        # Output section
        output_frame = LabelFrame(self, text="Output")
        output_frame.pack(fill=BOTH, expand=True)

        self.output_text = Text(output_frame)
        self.output_text.pack(fill=BOTH, padx=4, expand=True) 
Esempio n. 19
0
    def configure_gui1(self):
        self.master.title("501")
        self.master.geometry("800x600")

        # function binding return key to entry box
        self.master.bind('<Return>', lambda e: self.score_Entered())

        #create menu
        def callback():
            print("called the callback!")

        # create a menu
        menu = Menu(root)
        root.config(menu=menu)

        filemenu = Menu(menu)
        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="New", command=callback)
        filemenu.add_command(label="Open...", command=callback)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=callback)

        helpmenu = Menu(menu)
        menu.add_cascade(label="Help", menu=helpmenu)
        helpmenu.add_command(label="About...", command=callback)

        #create frames
        labFrame1 = LabelFrame(self.master, text="Player1 Stats")
        labFrame2 = LabelFrame(self.master, text="Player2 Stats")
        labFrame3 = LabelFrame(self.master, text="Player1 Scores")
        labFrame4 = LabelFrame(self.master, text="Player2  Scores")
        labFrame5 = LabelFrame(self.master, text="Enter Scores")
        """
        #make frames visible using grid
        labFrame1.grid(row=0, column=0, rowspan=2, sticky='ew')
        labFrame3.grid(row=0, column=1, sticky='ew')
        labFrame4.grid(row=0, column=2, sticky='ew')
        labFrame2.grid(row=0, column=3, rowspan=2, sticky='ew')
        labFrame5.grid(row=1, column=1, columnspan=2, sticky='ew')
        """

        #make frames visible using pack
        labFrame1.pack(side="left", fill="both", expand=True)

        labFrame2.pack(side="right", fill="both", expand=True)
        labFrame5.pack(side="bottom", fill="x", expand=True)
        labFrame3.pack(side="left", fill="both", expand=True)
        labFrame4.pack(side="right", fill="both", expand=True)

        #stringvars
        self.pl1name = StringVar()
        self.pl2name = StringVar()
        self.pl1sets = StringVar()
        self.pl1legs = StringVar()
        self.pl160 = StringVar()
        self.pl180 = StringVar()
        self.pl1100 = StringVar()
        self.pl1140 = StringVar()
        self.pl1180 = StringVar()
        self.pl1avg = StringVar()
        self.pl1chtpc = StringVar()
        self.pl1chtnumbs = StringVar()

        #player to go boolean
        self.player1_togo = True

        #frame 1 widgets
        Label(labFrame1, text="Totals").grid(row=0, column=0, sticky='w')
        Label(labFrame1, text="Sets:").grid(row=1, column=0, sticky='w')
        Label(labFrame1, textvariable=self.pl1sets).grid(row=1, column=1)
        Label(labFrame1, text="Legs:").grid(row=2, column=0, sticky='w')
        Label(labFrame1, textvariable=self.pl1legs).grid(row=2, column=1)
        Label(labFrame1, text="60+:").grid(row=3, column=0, sticky='w')
        Label(labFrame1, textvariable=self.pl160).grid(row=3, column=1)
        Label(labFrame1, text="80+:").grid(row=4, column=0, sticky='w')
        Label(labFrame1, textvariable=self.pl180).grid(row=4, column=1)
        Label(labFrame1, text="100+:").grid(row=5, column=0, sticky='w')
        Label(labFrame1, textvariable=self.pl1100).grid(row=5, column=1)
        Label(labFrame1, text="140+:").grid(row=6, column=0, sticky='w')
        Label(labFrame1, textvariable=self.pl1140).grid(row=6, column=1)
        Label(labFrame1, text="180:").grid(row=7, column=0, sticky='w')
        Label(labFrame1, textvariable=self.pl1180).grid(row=7, column=1)
        Label(labFrame1, text="Averages").grid(row=8, column=0, sticky='w')
        Label(labFrame1, text="Score:").grid(row=9, column=0, sticky='w')
        Label(labFrame1, textvariable=self.pl1avg).grid(row=9, column=1)
        Label(labFrame1, text="Checkout %:").grid(row=10, column=0, sticky='w')
        Label(labFrame1, textvariable=self.pl1chtpc).grid(row=10, column=1)
        Label(labFrame1, text="Checkout Hit/Thrown:").grid(row=11,
                                                           column=0,
                                                           sticky='w')
        Label(labFrame1, textvariable=self.pl1chtnumbs).grid(row=11, column=1)

        #stringvars
        self.pl2sets = StringVar()
        self.pl2legs = StringVar()
        self.pl260 = StringVar()
        self.pl280 = StringVar()
        self.pl2100 = StringVar()
        self.pl2140 = StringVar()
        self.pl2180 = StringVar()
        self.pl2avg = StringVar()
        self.pl2chtpc = StringVar()
        self.pl2chtnumbs = StringVar()

        #frame 2 widgets
        Label(labFrame2, text="Totals").grid(row=0, column=0, sticky='w')
        Label(labFrame2, text="Sets:").grid(row=1, column=0, sticky='w')
        Label(labFrame2, textvariable=self.pl2sets).grid(row=1, column=1)
        Label(labFrame2, text="Legs:").grid(row=2, column=0, sticky='w')
        Label(labFrame2, textvariable=self.pl2legs).grid(row=2, column=1)
        Label(labFrame2, text="60+:").grid(row=3, column=0, sticky='w')
        Label(labFrame2, textvariable=self.pl260).grid(row=3, column=1)
        Label(labFrame2, text="80+:").grid(row=4, column=0, sticky='w')
        Label(labFrame2, textvariable=self.pl280).grid(row=4, column=1)
        Label(labFrame2, text="100+:").grid(row=5, column=0, sticky='w')
        Label(labFrame2, textvariable=self.pl2100).grid(row=5, column=1)
        Label(labFrame2, text="140+:").grid(row=6, column=0, sticky='w')
        Label(labFrame2, textvariable=self.pl2140).grid(row=6, column=1)
        Label(labFrame2, text="180:").grid(row=7, column=0, sticky='w')
        Label(labFrame2, textvariable=self.pl2180).grid(row=7, column=1)
        Label(labFrame2, text="Averages").grid(row=8, column=0, sticky='w')
        Label(labFrame2, text="Score:").grid(row=9, column=0, sticky='w')
        Label(labFrame2, textvariable=self.pl2avg).grid(row=9, column=1)
        Label(labFrame2, text="Checkout %:").grid(row=10, column=0, sticky='w')
        Label(labFrame2, textvariable=self.pl2chtpc).grid(row=10, column=1)
        Label(labFrame2, text="Checkout Hit/Thrown:").grid(row=11,
                                                           column=0,
                                                           sticky='w')
        Label(labFrame2, textvariable=self.pl2chtnumbs).grid(row=11, column=1)

        #frame 3 widgets
        self.pl1remaining = StringVar()
        Label(labFrame3, text="Player:").grid(row=0, column=0)
        Label(labFrame3, textvariable=self.pl1name).grid(row=0, column=1)
        Label(labFrame3).grid(row=1)
        Label(labFrame3, text="Remaining").grid(row=2,
                                                column=0,
                                                columnspan=2,
                                                sticky='ew')
        self.remlabel1 = Label(labFrame3, textvariable=self.pl1remaining)
        self.remlabel1.grid(row=3, column=0, columnspan=2)
        self.remlabel1.configure(width=3, background='white', font=(None, 35))

        #self.pl1remaining.set(self.pl1dict['score'])
        #self.pl1name.set(game_state.player1)

        #frame 4 widgets
        self.pl2remaining = StringVar()
        Label(labFrame4, text="Player:").grid(row=0, column=0)
        Label(labFrame4, textvariable=self.pl2name).grid(row=0, column=1)
        Label(labFrame4).grid(row=1)
        Label(labFrame4, text="Remaining").grid(row=2,
                                                column=0,
                                                columnspan=2,
                                                sticky='ew')
        self.remlabel2 = Label(labFrame4, textvariable=self.pl2remaining)
        self.remlabel2.grid(row=3, column=0, columnspan=2)
        self.remlabel2.configure(width=3, background='white', font=(None, 35))
        #self.pl2remaining.set(self.pl2dict['score'])
        #self.pl2name.set(game_state.player2)

        #frame 5 widgets
        self.playertogo = StringVar()
        self.scoreEntered = StringVar()
        Label(labFrame5, text="    ").grid(row=0, column=0)
        #Label(labFrame5).grid(row=0, column=1)
        #Label(labFrame5).grid(row=0, column=2)
        Label(labFrame5, text="To Go:").grid(row=1, column=1)
        playerLabel = Label(labFrame5, textvariable=self.playertogo)
        playerLabel.grid(row=2, column=1)
        playerLabel.configure(font=(None, 20))

        self.number_entry = Entry(labFrame5,
                                  textvariable=self.scoreEntered,
                                  width=5)
        self.number_entry.grid(row=2, column=2)
        self.number_entry.configure(background='white', font=(None, 20))
        self.number_entry.focus()
    def __init__(self):
        """__init__ creates the tkinter gui"""
        self.__settings = {}
        self.__importer = CsvXmlImporter()

        # ***--*** main window and menu band ***---***
        self.__root = ThemedTk(theme=theme)
        self.__root.title("Csv/Xml Importer")
        self.__root.minsize(560, 1)
        menu = Menu(self.__root)
        self.__root.config(menu=menu)

        filemenu = Menu(menu, tearoff=0)
        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="Add Files", command=self.add_files)
        filemenu.add_command(label="Remove All", command=self.remove_all)
        filemenu.add_separator()
        filemenu.add_command(label="Add xsl File", command=self.add_xslfile)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.exit)

        helpmenu = Menu(menu, tearoff=0)
        menu.add_cascade(label="Help", menu=helpmenu)
        helpmenu.add_command(label="?", command=self.ask_help)
        helpmenu.add_command(label="About", command=self.ask_about)

        # ***---*** source file frame dialog ***---***
        srcfilesframe = LabelFrame(self.__root, text="Sourcefiles")
        buttonframe = Frame(srcfilesframe)
        addbutton = Button(buttonframe,
                           text="Add Files",
                           command=self.add_files)
        addbutton.pack(fill=X)
        removefilesbutton = Button(buttonframe,
                                   text="Remove Selected",
                                   command=self.remove_files)
        removefilesbutton.pack(fill=X)
        removeallbutton = Button(buttonframe,
                                 text="Remove All",
                                 command=self.remove_all)
        removeallbutton.pack(fill=X)
        buttonframe.grid(column=1, row=1)
        self.__srcfileslistbox = Listbox(srcfilesframe,
                                         selectmode="extended",
                                         width=100,
                                         height=5)
        self.__srcfileslistbox.grid(column=2, row=1)

        Label(srcfilesframe, text="Encoding").grid(column=1, row=2, sticky=E)
        self.__settings["encoding"] = StringVar()
        self.__settings["encoding"].trace_add("write", self.update_settings)
        encCombobox = Combobox(srcfilesframe,
                               textvariable=self.__settings["encoding"],
                               values=encodings,
                               state="readonly")
        encCombobox.bind("<FocusOut>", self.update_settings)
        encCombobox.grid(column=2, row=2, pady=10)
        srcfilesframe.pack(fill=X)

        # ***---*** xsl file dialog ***---***
        xslfileframe = LabelFrame(self.__root, text="XSL-File")
        Button(xslfileframe, text="Add .xsl",
               command=self.add_xslfile).grid(column=1, row=1)
        self.__xsllistbox = Listbox(xslfileframe, width=100, height=1)
        self.__xsllistbox.grid(column=2, row=1, sticky="w")
        buttonframe = Frame(xslfileframe)
        Button(buttonframe,
               text="Apply Parameter",
               command=self.apply_xslparameter).pack(fill=X)
        Button(buttonframe,
               text="Restore Default",
               command=self.reset_xslparameter).pack(fill=X)
        buttonframe.grid(column=1, row=2)
        box = Frame(xslfileframe)
        self.__xslparametertext = Text(box, height=3, width=75)
        self.__xslparametertext.grid(column=0, row=1, sticky="nsew")
        scrollbar = Scrollbar(box, command=self.__xslparametertext.yview)
        scrollbar.grid(column=0, row=1, sticky="nse")
        box.grid(column=2, row=2, sticky="we")
        self.__xslparametertext["yscrollcommand"] = scrollbar.set
        xslfileframe.pack(fill=X)

        # ***---*** file format settings dialog ***---***
        # small help function
        def limit_character(entry_text):
            """limit_characters cuts down the characters of an entry text to one"""
            if len(entry_text.get()) > 0:
                # take only last input character and throw away the rest
                entry_text.set(entry_text.get()[-1])

        fileformatsettingsframe = LabelFrame(self.__root,
                                             text="File Format Settings")

        Label(fileformatsettingsframe, text="Delimiter").grid(column=1,
                                                              row=1,
                                                              sticky=E)
        self.__settings["delimiter"] = StringVar()
        seperatorentry = Entry(fileformatsettingsframe,
                               textvariable=self.__settings["delimiter"],
                               width=1)
        self.__settings["delimiter"].trace_add(
            "write", lambda *_: limit_character(self.__settings["delimiter"]))
        seperatorentry.bind("<Return>", self.update_settings)
        seperatorentry.bind("<FocusOut>", self.update_settings)
        seperatorentry.grid(column=2, row=1, sticky=W, padx=15)

        Label(fileformatsettingsframe, text="Quotechar").grid(column=1,
                                                              row=2,
                                                              sticky=E)
        self.__settings["quotechar"] = StringVar()
        quotecharentry = Entry(fileformatsettingsframe,
                               textvariable=self.__settings["quotechar"],
                               width=1)
        self.__settings["quotechar"].trace_add(
            "write", lambda *_: limit_character(self.__settings["quotechar"]))
        quotecharentry.bind("<Return>", self.update_settings)
        quotecharentry.bind("<FocusOut>", self.update_settings)
        quotecharentry.grid(column=2, row=2, sticky=W, padx=15)

        Label(fileformatsettingsframe, text="Doublequote").grid(column=1,
                                                                row=3,
                                                                sticky=E)
        self.__settings["doublequote"] = BooleanVar()
        Checkbutton(fileformatsettingsframe,
                    variable=self.__settings["doublequote"],
                    command=self.update_settings).grid(column=2,
                                                       row=3,
                                                       sticky=W,
                                                       padx=10)

        Label(fileformatsettingsframe, text="Quoting").grid(column=1,
                                                            row=5,
                                                            sticky=E)
        quotingopt = {"minimal": 0, "all": 1, "non numeric": 2, "none": 3}
        self.__settings["quoting"] = IntVar()
        for i, (key, value) in enumerate(quotingopt.items()):
            Radiobutton(
                fileformatsettingsframe,
                text=key,
                value=value,
                variable=self.__settings["quoting"],
                command=self.update_settings,
            ).grid(
                column=2 + i,
                row=5,
                padx=10,
                sticky=W,
            )

        Label(fileformatsettingsframe,
              text="Ignore spaces at beginning").grid(column=1,
                                                      row=6,
                                                      sticky=E)
        self.__settings["skipinitialspace"] = BooleanVar()
        self.__settings["skipinitialspace"].set(False)
        Checkbutton(fileformatsettingsframe,
                    variable=self.__settings["skipinitialspace"],
                    command=self.update_settings).grid(column=2,
                                                       row=6,
                                                       sticky=W,
                                                       padx=10)

        fileformatsettingsframe.pack(fill=X)

        # ***---*** preview frame ***---***
        previewframe = LabelFrame(self.__root, text="Preview")
        self.__pdtable = Table(parent=previewframe,
                               dataframe=self.__importer.dfx)
        self.__pdtable.show()
        previewframe.pack(fill="both", expand=True)

        # ***---*** export button ***---***
        exportframe = LabelFrame(self.__root, text="Export")
        Button(exportframe, text="Export",
               command=self.create_exportdialog).pack()
        exportframe.pack(fill="both", expand=True)

        # save settings to check for changes on update
        self.__prevsettings = self.__unpack_settings(self.__settings)
Esempio n. 21
0
    def init_ui(self):
        """ setup the GUI for the app """
        self.master.title("Test")
        self.pack(fill=BOTH, expand=True)

        # Input section
        input_frame = LabelFrame(self, text="Input")
        input_frame.bind("-", self.on_minus_key)
        input_frame.bind("+", self.on_plus_key)
        input_frame.pack(fill=X)
        self.play_button = Button(input_frame,
                                  text="Play",
                                  command=self.on_play_button_click)
        self.play_button.pack(side=RIGHT, padx=4)

        self.rgb_canvas = tk.Canvas(input_frame, width=20, height=20, bd=0)
        self.rgb_oval = self.rgb_canvas.create_oval(2,
                                                    2,
                                                    20,
                                                    20,
                                                    fill='#FF0000',
                                                    width=0)
        self.rgb_canvas.pack(side=RIGHT, padx=4)

        self.rec_button = Button(input_frame,
                                 text="Rec",
                                 command=self.on_rec_button_click)
        self.rec_button.pack(side=RIGHT, padx=4)

        self.wav_filename_entry = Entry(input_frame, width=24)
        self.wav_filename_entry.pack(fill=X)
        self.wav_filename_entry.delete(0, END)
        if self.wav_filename:
            self.wav_filename_entry.insert(0, self.wav_filename)

        # Feature section
        features_frame = LabelFrame(self, text="Features")
        features_frame.pack(fill=X)

        features_control_frame = Frame(features_frame)
        features_control_frame.pack(fill=X)
        load_features_button = Button(features_control_frame,
                                      text="Load",
                                      command=self.on_load_featurizer_model)
        load_features_button.pack(side=RIGHT)
        self.features_entry = Entry(features_control_frame, width=8)
        self.features_entry.pack(fill=X)
        self.features_entry.delete(0, END)
        if self.featurizer_model:
            self.features_entry.insert(0, self.featurizer_model)

        self.spectrogram_widget = SpectrogramImage(features_frame)
        self.spectrogram_widget.pack(fill=X)

        # Classifier section
        classifier_frame = LabelFrame(self, text="Classifier")
        classifier_frame.pack(fill=X)
        load_classifier_button = Button(classifier_frame,
                                        text="Load",
                                        command=self.on_load_classifier)
        load_classifier_button.pack(side=RIGHT)
        self.classifier_entry = Entry(classifier_frame, width=8)
        self.classifier_entry.pack(fill=X)
        self.classifier_entry.delete(0, END)
        if self.classifier_model:
            self.classifier_entry.insert(0, self.classifier_model)

        # Output section
        output_frame = LabelFrame(self, text="Output")
        output_frame.pack(fill=BOTH, expand=True)

        self.output_text = Text(output_frame)
        self.output_text.pack(fill=BOTH, padx=4, expand=True)
Esempio n. 22
0
class InfoManager(Frame):
    """This is a class to manage the information panel in the GUI.

    The information panel shows the main information of the machine, all the
    transitions in the selected transition, if any, and the status bar.

    Attributes:
        machine (utils.Machine): The machine of the user.
    """
    def __init__(self, master, machine):
        """Initialize this manager with the given machine and update the info
        that is shown to the user.

        Parameters:
            machine (utils.Machine): The machine of the user.
        """
        super().__init__(master=master)
        self.pack(side='right', fill='y')
        self.machine = machine
        self._info_frame = LabelFrame(self, text='Main Info', labelanchor='n')
        self._info_frame.pack()
        # number of states
        self._info_label1 = Label(self._info_frame, text='# of states')
        self._info_label1.grid(row=0, column=0)
        self._info_var1 = StringVar(self._info_frame)
        self._machine_info1 = Label(self._info_frame,
                                    textvariable=self._info_var1,
                                    width=3)
        self._machine_info1.grid(row=0, column=1)
        # init state
        self._info_label2 = Label(self._info_frame, text='Initial state')
        self._info_label2.grid(row=1, column=0)
        self._info_var2 = StringVar(self._info_frame)
        self._machine_info2 = Label(self._info_frame,
                                    textvariable=self._info_var2,
                                    width=3)
        self._machine_info2.grid(row=1, column=1)
        # nonfinal states
        self._info_label3 = Label(self._info_frame,
                                  text='# of non-final states')
        self._info_label3.grid(row=2, column=0)
        self._info_var3 = StringVar(self._info_frame)
        self._machine_info3 = Label(self._info_frame,
                                    textvariable=self._info_var3,
                                    width=3)
        self._machine_info3.grid(row=2, column=1)
        # final states
        self._info_label4 = Label(self._info_frame, text='# of final states')
        self._info_label4.grid(row=3, column=0)
        self._info_var4 = StringVar(self._info_frame)
        self._machine_info4 = Label(self._info_frame,
                                    textvariable=self._info_var4,
                                    width=3)
        self._machine_info4.grid(row=3, column=1)
        # number of transitions
        self._info_label5 = Label(self._info_frame, text='# of transitions')
        self._info_label5.grid(row=4, column=0)
        self._info_var5 = StringVar(self._info_frame)
        self._machine_info5 = Label(self._info_frame,
                                    textvariable=self._info_var5,
                                    width=3)
        self._machine_info5.grid(row=4, column=1)
        # transitions info
        self._trans_frame = LabelFrame(self,
                                       text='Transitions Info',
                                       labelanchor='n')
        self._trans_frame.pack(fill='both', expand=True)
        self._trans_info1 = Label(self._trans_frame, anchor='n')
        self._trans_info1.pack(side='top')
        self._trans_info2 = Label(self._trans_frame, anchor='n')
        self._trans_info2.pack(side='top')
        # status bar
        self._status_bar = Label(self)
        self._status_bar.pack()
        # update the info
        self.update_info()

    def update_info(self):
        """Update the info that is shown to the user."""
        info = self.machine.get_info()
        self._info_var1.set(info['# of states'])
        self._info_var2.set(info['Initial state'])
        self._info_var3.set(info['# of non-final states'])
        self._info_var4.set(info['# of final states'])
        self._info_var5.set(info['# of transitions'])

    def update_status(self, text):
        """Update the status bar with the given text

        Parameters:
            text (str): The text to be displayed in the status bar.
        """
        self._status_bar.config(text=text)

    def clear_status(self):
        """Clear the status bar."""
        self._status_bar.config(text='')

    def show_transitions(self, from_state, to_state):
        """Show the transitions pertaining to (from_state -> to_state).

        Parameters:
            from_state (int): The state number of the source of the transition.
            to_state (int): The state number of the target of the transition.
        """
        info1 = None
        info2 = None
        if self.machine.get_transition_count(from_state, to_state) > 0:
            info1 = '{} -> {}\n'.format(from_state, to_state)
            info1 += '\n'.join(
                self.machine.get_transitions(from_state, to_state))
        try:
            if from_state != to_state and from_state in self.machine.transitions[
                    to_state]:
                info2 = '{} -> {}\n'.format(to_state, from_state)
                info2 += '\n'.join(
                    self.machine.get_transitions(to_state, from_state))
        except KeyError:
            pass
        if info2 is not None and info1 is None:
            self._trans_info1.config(text=info2)
            self._trans_info2.config(text='')
        elif info2 is None and info1 is not None:
            self._trans_info1.config(text=info1)
            self._trans_info2.config(text='')
        elif info1 is None and info2 is None:
            self._trans_info1.config(text='')
            self._trans_info2.config(text='')
        else:
            if from_state > to_state:
                temp = info1
                info1 = info2
                info2 = temp
            self._trans_info1.config(text=info1)
            self._trans_info2.config(text=info2)

    def hide_transitions(self):
        """Clear the transition info shown to the user."""
        self._trans_info1.config(text='')
        self._trans_info2.config(text='')
Esempio n. 23
0
    def start(self):
        """Called when initialised to create test widgets."""

        self.img = ScalingImage(file=self.imgpath)

        self.my_label = Label(Toplevel(self), image=self.img)
        self.my_label.__image = self.img
        # The window snaps to the right size faster with these pack options
        self.my_label.pack(fill="both",
                           expand="true",
                           side="left",
                           anchor="nw")

        self.numer_var = IntVar()
        self.denom_var = IntVar()
        self.numer_display_var = IntVar()
        self.denom_display_var = IntVar()

        self.numer_var.set(10)
        self.denom_var.set(20)
        self.numer_display_var.set(10)
        self.denom_display_var.set(20)

        frac_frame = LabelFrame(self, text="Full Fraction")
        frac_frame.pack(side="left",
                        fill="both",
                        expand="true",
                        padx=5,
                        pady=5)

        frac_numer_scale = Scale(frac_frame,
                                 variable=self.numer_var,
                                 from_=1,
                                 to=100,
                                 orient="vertical",
                                 command=lambda i: self.on_frac_changed())
        frac_numer_scale.bind("<ButtonRelease>", lambda e: self.on_end_zoom())
        frac_numer_scale.pack(side="left")

        frac_denom_scale = Scale(frac_frame,
                                 variable=self.denom_var,
                                 from_=1,
                                 to=100,
                                 orient="vertical",
                                 command=lambda i: self.on_frac_changed())
        frac_denom_scale.bind("<ButtonRelease>", lambda e: self.on_end_zoom())
        frac_denom_scale.pack(side="left")

        Label(frac_frame, textvariable=self.numer_display_var).pack()
        Label(frac_frame, text="__\n").pack()
        Label(frac_frame, textvariable=self.denom_display_var).pack()

        numer_scale_frame = LabelFrame(self, text="Numeric Scale")
        numer_scale_frame.pack(side="left",
                               fill="both",
                               expand="true",
                               padx=5,
                               pady=5)

        self.numer_scale_var = IntVar()
        self.numer_scale_display_var = IntVar()
        self.numer_scale_var.set(20)
        self.numer_scale_display_var.set(20)

        zoom_scale = Scale(numer_scale_frame,
                           from_=1,
                           to=60,
                           variable=self.numer_scale_var,
                           orient="horizontal",
                           command=lambda i: self.on_numer_scale_changed())
        zoom_scale.bind("<ButtonRelease>", lambda e: self.on_end_zoom())
        zoom_scale.pack(fill="x")

        Label(numer_scale_frame,
              textvariable=self.numer_scale_display_var).pack()
        Label(numer_scale_frame, text="__\n\n20").pack()

        decimal_frame = LabelFrame(self, text="Decimal")
        decimal_frame.pack(side="left",
                           fill="both",
                           expand="true",
                           padx=5,
                           pady=5)

        self.decimal_scale_var = DoubleVar()
        self.decimal_display_var = DoubleVar()
        self.decimal_scale_var.set(1)
        self.decimal_display_var.set(1)

        decimal_scale = Scale(decimal_frame,
                              variable=self.decimal_scale_var,
                              from_=0.01,
                              to=3,
                              command=lambda i: self.on_decimal_changed())
        decimal_scale.bind("<ButtonRelease>", lambda e: self.on_end_zoom())
        decimal_scale.pack()

        Label(decimal_frame, textvariable=self.decimal_display_var).pack()

        Button(self, text="Reset", command=self.on_reset).pack(side="left")
Esempio n. 24
0
    leftFrame.pack(side="left")
# левая панель
    Button(leftFrame, text="Граф из примера", bg='green', command=fill).pack()
    Label(leftFrame, text="Введите матрицу: ", font=('arial', 10, 'bold')).pack(side="top")
# логика
    textFrame = Frame(leftFrame); textFrame.pack()
    Label(textFrame, text="Размер:").pack(side="left")
    sizeEntry = Entry(textFrame, width=3); sizeEntry.pack(side="left")
    getSizeBtn = Button(textFrame, text="OK", width=3, command=lambda: setSize(sizeEntry.get()))
    getSizeBtn.pack(padx=10, side="left")
# матрица
    matrixFrame = Frame(leftFrame); matrixFrame.pack(pady=5, padx=5)
# кнопки
    btnsFrame = Frame(leftFrame); btnsFrame.pack(side="bottom")
    Button(btnsFrame, text="Обновить", width=10, command=update).pack(side="left")
    Button(btnsFrame, text="Отрисовать", width=10, command=drawGraph).pack(side="right")
# панель с графиком
    graphFrame = Frame(window); graphFrame.pack(side='left')
    img1 = ImageTk.PhotoImage(Image.open('plaseholder.png'))
    panel = Label(graphFrame, image=img1); panel.pack(fill='both')
# правая панель
    rightFrame = Frame(window); rightFrame.pack(side='right')
    pointsFrame = LabelFrame(rightFrame, text="Узлы:"); pointsFrame.pack()
    fromEntry = Entry(pointsFrame, width=3); fromEntry.pack(side='left')
    toEntry = Entry(pointsFrame, width=3); toEntry.pack(side='left')
    Button(pointsFrame, text='OK', command=calculate).pack(side='left')
    pathText = Label(rightFrame, text='Путь:', font=('arial', 10, 'bold')); pathText.pack()
    lengthText = Label(rightFrame, text='Длина пути:', font=('arial', 10, 'bold')); lengthText.pack()

    window.mainloop()
Esempio n. 25
0
class window(tk.Tk):
	def __init__(self):
		tk.Tk.__init__(self)
		self.title("Open Shop Channel Downloader - Library")
		self.geometry(f"{WIDTH}x{HEIGHT}")
		self.wait_visibility(self)
		self.outer_frame = Frame(self)
		self.outer_frame.pack(fill = "both", expand = 1, padx = 5, pady = 5)


		self.left_column = LabelFrame(self.outer_frame, text = "Apps Library")
		self.left_column.pack(side = 'left', expand = 1, fill = "both", padx = 5, pady = 5)

		self.apps_listbox = ScrolledListbox(self.left_column)
		self.apps_listbox.pack(expand = 1, fill = "both", padx = 5, pady = 5)
		self.apps_listbox.bind("<<ListboxSelect>>", self.on_selection)

		self.right_column = Frame(self.outer_frame)
		self.right_column.pack(side = 'right', expand = 0, fill = "both", padx = 5, pady = 5)

		self.metadata_frame = LabelFrame(self.right_column, text = "Application Metadata")
		self.metadata_frame.pack(side = "top", expand = 0, fill = "both")

		self.mgr = Notebook(self.metadata_frame)
		self.mgr.pack(side = "top", expand = 0, fill = "both", padx = 5, pady = 5)
		self.general_page = general_page(self.mgr)
		self.mgr.add(self.general_page, text = "General")
		self.description_page = description_page(self.mgr)
		self.mgr.add(self.description_page, text = "Description")

		self.checkbutton_frame = Frame(self.metadata_frame)
		self.checkbutton_frame.pack(side = 'top', fill = 'x', expand = 0)
		self.extract_var = tk.IntVar()
		self.extract_checkbutton = tk.Checkbutton(self.checkbutton_frame, text = "Extract Downloaded App", variable = self.extract_var)
		self.extract_checkbutton.pack(side = 'left', fill = 'x', expand = 0)

		self.filename_entry = labeledEntry('Output File', self.metadata_frame)
		self.filename_entry.pack(side = 'top', expand = 0, fill = 'x', padx = 5, pady = 5)

		self.download_button = Button(self.metadata_frame, text = "Download App")
		self.download_button.pack(side = "left", expand = 0, padx = 5, pady = 5)

		self.download_progress_bar = Progressbar(self.metadata_frame)
		self.download_progress_bar.pack(side = "left", padx = 5, pady = 5)

		self.icon_frame = LabelFrame(self.right_column, text = "Application Icon")
		self.icon_frame.pack(side = "top", expand = 1, fill = "both")
		self.icon = Label(self.icon_frame)
		self.icon.pack(fill = "both")

		self.populate()

	def populate(self):
		for item in parsecontents.list():
			self.apps_listbox.insert('end', item)

	def on_selection(self, event):
		w = event.widget
		selection = w.get(w.curselection()[0])
		info = metadata.dictionary(selection)
		self.general_page.update(info)
		self.update_icon(download(metadata.icon(selection)))

	def update_icon(self,image_path):
		maxheight = self.icon_frame.winfo_height()
		maxwidth = self.icon_frame.winfo_width()
		if maxwidth > 0 and maxheight > 0:
			image = Image.open(image_path)
			wpercent = (maxwidth/float(image.size[0]))
			hsize = int((float(image.size[1])*float(wpercent)))
			if hsize <= 0:
				return
			new_image = image.resize((maxwidth,hsize), Image.ANTIALIAS)
			if new_image.size[1] > maxheight:
				hpercent = (maxheight/float(image.size[1]))
				wsize = int((float(image.size[0])*float(hpercent)))
				new_image = image.resize((wsize,maxheight), Image.ANTIALIAS)

			image = ImageTk.PhotoImage(new_image)

			self.icon.configure(image=image)
			self.icon.image = image
Esempio n. 26
0
    def _create_descrip_tab(self, nb):
        # frame to hold contents
        frame = Frame(nb, name='descrip')

        # widgets to be displayed on 'Description' tab
        # position and set resize behaviour

        frame.rowconfigure(1, weight=1)
        frame.columnconfigure((0, 1), weight=1, uniform=1)
        lf = LabelFrame(frame, text='Animals')
        lf.pack(pady=5, padx=5, side='left', fill='y')
        themes = ['horse', 'elephant', 'crocodile', 'bat', 'grouse']
        self.ttkbut = []
        for t in themes:
            b = Button(lf, text=t)
            b.pack(pady=2)
            self.ttkbut.append(b)

        lF2 = LabelFrame(frame, text="Theme Combobox")
        lF2.pack(pady=5, padx=5)
        themes = list(sorted(
            self.style.theme_names()))  # get_themes # used in ttkthemes
        themes.insert(0, "Pick a theme")
        self.cb = cb = Combobox(lF2,
                                values=themes,
                                state="readonly",
                                height=10)
        cb.set(themes[0])
        #cb.bind('<<ComboboxSelected>>', self.change_style)
        cb.grid(row=0, column=0, sticky='nw', pady=5)

        lf1 = LabelFrame(frame, text='Checkbuttons')
        lf1.pack(pady=5, padx=5, side='left', fill='y')

        # control variables
        self.enabled = IntVar()
        self.cheese = IntVar()
        self.tomato = IntVar()
        self.basil = IntVar()
        self.oregano = IntVar()
        # checkbuttons
        self.cbOpt = Checkbutton(lf1,
                                 text='Enabled',
                                 variable=self.enabled,
                                 command=self._toggle_opt)
        cbCheese = Checkbutton(text='Cheese',
                               variable=self.cheese,
                               command=self._show_vars)
        cbTomato = Checkbutton(text='Tomato',
                               variable=self.tomato,
                               command=self._show_vars)
        sep1 = Separator(orient='h')
        cbBasil = Checkbutton(text='Basil',
                              variable=self.basil,
                              command=self._show_vars)
        cbOregano = Checkbutton(text='Oregano',
                                variable=self.oregano,
                                command=self._show_vars)
        sep2 = Separator(orient='h')

        self.cbs = [
            self.cbOpt, sep1, cbCheese, cbTomato, sep2, cbBasil, cbOregano
        ]
        for opt in self.cbs:
            if opt.winfo_class() == 'TCheckbutton':
                opt.configure(onvalue=1, offvalue=0)
                opt.setvar(opt.cget('variable'), 0)

            opt.pack(in_=lf1,
                     side='top',
                     fill='x',
                     pady=2,
                     padx=5,
                     anchor='nw')

        lf2 = LabelFrame(frame, text='Radiobuttons', labelanchor='n')
        lf2.pack(pady=5, padx=5, side='left', fill='y')

        self.rb = []
        self.happiness = StringVar()
        for s in ['Great', 'Good', 'OK', 'Poor', 'Awful']:
            b = Radiobutton(lf2,
                            text=s,
                            value=s,
                            variable=self.happiness,
                            command=lambda s=s: self._show_vars())
            b.pack(anchor='nw', side='top', fill='x', pady=5, padx=5)
            self.rb.append(b)

        right = LabelFrame(frame, text='Control Variables')
        right.pack(pady=5, padx=5, side='left', fill='y')

        self.vb0 = Label(right, font=('Courier', 10))
        self.vb1 = Label(right, font=('Courier', 10))
        self.vb2 = Label(right, font=('Courier', 10))
        self.vb3 = Label(right, font=('Courier', 10))
        self.vb4 = Label(right, font=('Courier', 10))
        self.vb5 = Label(right, font=('Courier', 10))

        self.vb0.pack(anchor='nw', pady=5, padx=5)
        self.vb1.pack(anchor='nw', pady=5, padx=5)
        self.vb2.pack(anchor='nw', pady=5, padx=5)
        self.vb3.pack(anchor='nw', pady=5, padx=5)
        self.vb4.pack(anchor='nw', pady=5, padx=5)
        self.vb5.pack(anchor='nw', pady=5, padx=5)

        self._show_vars()
        # add to notebook (underline = index for short-cut character)
        nb.add(frame, text='Description', underline=0, padding=2)
Esempio n. 27
0
class App(Tk):
    DEFAULT_SIGN_WIDTH = 150.0
    DEFAULT_SIGN_HEIGHT = 22.0
    DEFAULT_SHEET_WIDHT = 300.0
    DEFAULT_SHEET_HEIGHT = 300.0
    DEFAULT_SHEETS_PER_FILE = 0
    MAX_SHEET_WIDTH = 470
    MAX_SHEET_HEIGHT = 310
    MAX_SHEETS_PER_FILE = 100
    SPINBOX_WIDTH = 8
    PADDING = 2
    DXF_VERSIONS = ('R2000', 'R2004', 'R2007', 'R2010', 'R2013', 'R2018')

    # Initialize GUI layout.
    def __init__(self) -> None:
        super().__init__()
        self.title('KylttiMaker')
        self.minsize(640, 480)

        # Tree widget that displays fields and their relative marks in a hierarchy.
        self.tree = Treeview(self, selectmode='browse')
        self.tree.heading('#0', text='Fields', command=self.remove_selection)
        self.tree.bind('<Button-3>', self.tree_right_click)
        self.tree.bind('<<TreeviewSelect>>', self.tree_selection_changed)
        self.tree.bind('<Double-Button-1>', self.rename)
        self.bind('<Escape>', self.remove_selection)
        self.bind('<Delete>', self.remove)
        self.tree.pack(side=LEFT, fill=BOTH)
        self.properties = LabelFrame(self, text='Properties')
        self.properties.pack(side=RIGHT, fill=BOTH, expand=1)
        self.fields = {}
        self.selected_iid = None

        # Entry field that get's temporarily shown to the user whilst renaming a field or a mark.
        self.new_name = StringVar(self.tree)
        self.new_name_entry = Entry(self.tree, textvariable=self.new_name)
        self.new_name_entry.bind('<Key-Return>', self.new_name_entered)

        # Output options that get's shown to the user when nothing else is selected from the hierarchy.
        self.frame = Frame(self.properties)
        Label(self.frame, text='Sheet size').grid(column=0,
                                                  row=0,
                                                  sticky='E',
                                                  pady=App.PADDING)
        self.sheet_width_var = StringVar(self.frame)
        self.sheet_width_var.set(App.DEFAULT_SHEET_WIDHT)
        Spinbox(self.frame,
                to=App.MAX_SHEET_WIDTH,
                textvariable=self.sheet_width_var,
                width=App.SPINBOX_WIDTH).grid(column=1, row=0, sticky='WE')
        Label(self.frame, text='x').grid(column=2, row=0)
        self.sheet_height_var = StringVar(self.frame)
        self.sheet_height_var.set(App.DEFAULT_SHEET_HEIGHT)
        Spinbox(self.frame,
                to=App.MAX_SHEET_HEIGHT,
                textvariable=self.sheet_height_var,
                width=App.SPINBOX_WIDTH).grid(column=3, row=0, sticky='WE')
        Label(self.frame, text='Sign size').grid(column=0,
                                                 row=1,
                                                 sticky='E',
                                                 pady=App.PADDING)
        self.sign_width_var = StringVar(self.frame)
        self.sign_width_var.set(App.DEFAULT_SIGN_WIDTH)
        Spinbox(self.frame,
                to=App.MAX_SHEET_WIDTH,
                textvariable=self.sign_width_var,
                width=App.SPINBOX_WIDTH).grid(column=1, row=1, sticky='WE')
        Label(self.frame, text='x').grid(column=2, row=1)
        self.sign_height_var = StringVar(self.frame)
        self.sign_height_var.set(App.DEFAULT_SIGN_HEIGHT)
        Spinbox(self.frame,
                to=App.MAX_SHEET_HEIGHT,
                textvariable=self.sign_height_var,
                width=App.SPINBOX_WIDTH).grid(column=3, row=1, sticky='WE')
        Label(self.frame, text='Layers per sheet').grid(column=0,
                                                        row=2,
                                                        sticky='W',
                                                        pady=App.PADDING)
        self.layers_per_sheet_var = StringVar(self.frame)
        self.layers_per_sheet_var.set(App.DEFAULT_SHEETS_PER_FILE)
        Spinbox(self.frame,
                to=App.MAX_SHEETS_PER_FILE,
                textvariable=self.layers_per_sheet_var,
                width=App.SPINBOX_WIDTH).grid(column=1, row=2, sticky='WE')
        Label(self.frame, text='(0 = No limit)').grid(column=2,
                                                      row=2,
                                                      columnspan=2,
                                                      sticky='W')
        Label(self.frame, text='DXF version').grid(column=0,
                                                   row=4,
                                                   sticky='E',
                                                   pady=App.PADDING)
        self.dxf_version = StringVar(self.frame)
        OptionMenu(self.frame, self.dxf_version, App.DXF_VERSIONS[0],
                   *App.DXF_VERSIONS).grid(column=1, row=4, sticky='W')
        Button(self.frame, text='Create',
               command=self.create).grid(column=2, row=4, columnspan=2)
        self.frame.pack()

    # Display a popup menu with relevant options when right clicking on the tree widget item.
    def tree_right_click(self, event: Event) -> None:
        menu = Menu(self, tearoff=0)
        iid = self.tree.identify_row(event.y)
        if iid:
            if iid in self.fields:
                menu.add_command(label='Add QR',
                                 command=lambda: self.add_mark(QR, iid))
                menu.add_command(label='Add Text',
                                 command=lambda: self.add_mark(Text, iid))
                menu.add_command(label='Add Hole',
                                 command=lambda: self.add_mark(Hole, iid))
            menu.add_command(label='Rename',
                             command=lambda: self.rename(iid=iid))
            menu.add_command(label='Remove',
                             command=lambda: self.remove(iid=iid))
        else:
            menu.add_command(label='Add field', command=self.add_field)
        menu.tk_popup(event.x_root, event.y_root)

    # Display the properties of the selected item.
    def tree_selection_changed(self, event: Event) -> None:
        # Hide the items previously shown in the properties pane.
        self.new_name_entry.place_forget()
        for child in self.properties.winfo_children():
            child.pack_forget()

        selected_items = self.tree.selection()
        if selected_items:
            self.selected_iid = selected_items[0]
            # Check if the selected item is a field or a mark object, in which case show its properties.
            if self.selected_iid in self.fields:
                self.fields[self.selected_iid].frame.pack()
            else:
                for field_iid in self.fields:
                    if self.selected_iid in self.fields[field_iid].marks:
                        self.fields[field_iid].marks[
                            self.selected_iid].frame.pack()
        else:
            # Clear the properties pane.
            self.selected_iid = None
            self.frame.pack()

    # Create a new field object and add a corresponding node to the hierarchy.
    def add_field(self) -> None:
        iid = self.tree.insert('', END, text='Field')
        self.fields[iid] = Field(self.properties)

    # Display a entry for the user to input a new name for the item to be renamed.
    def rename(self, event: Event = None, iid: int = None) -> None:
        if not iid:
            if self.selected_iid:
                iid = self.selected_iid
            else:
                return
        self.editing_iid = iid
        self.new_name.set(self.tree.item(iid)['text'])
        self.new_name_entry.place(x=20, y=0)
        self.new_name_entry.focus_set()
        self.new_name_entry.select_range(0, END)

    # Display the renamed item in the hierarchy.
    def new_name_entered(self, event: Event) -> None:
        self.tree.item(self.editing_iid, text=self.new_name.get())
        self.new_name_entry.place_forget()

    # Link a new mark speciefied by mark_type parameter to the field speciefied by field_iid parameter.
    def add_mark(self,
                 mark_type: Union[QR, Text, Hole],
                 field_iid: int = None) -> None:
        if not field_iid:
            if self.selected_iid in self.fields:
                field_iid = self.selected_iid
            else:
                print('Select a field first.')
                return
        iid = self.tree.insert(field_iid, END, text=mark_type.__name__)
        self.fields[field_iid].marks[iid] = mark_type(self.properties)
        self.tree.see(iid)

    # Remove a tree item speciefied by iid parameter, else removes the currently selected item.
    def remove(self, event: Event = None, iid: int = None) -> None:
        if not iid:
            if self.selected_iid:
                iid = self.selected_iid
            else:
                print('Select something first.')
                return
        # Check if the item to be removed is a field item, else check if it is a mark item.
        if iid in self.fields:
            self.remove_selection()
            self.tree.delete(iid)
            del self.fields[iid]
        else:
            for field_iid in self.fields:
                if iid in self.fields[field_iid].marks:
                    self.remove_selection()
                    self.tree.delete(iid)
                    del self.fields[field_iid].marks[iid]

    # Clear the selection.
    def remove_selection(self, event: Event = None) -> None:
        for item in self.tree.selection():
            self.tree.selection_remove(item)

    # Create sheets according to entered settings.
    def create(self) -> None:
        if not self.fields:
            print('No fields.')
            return

        # Calculate the length of the longest field (some fields can have less values than others).
        total_signs = 0
        for field_iid in self.fields:
            total_signs = max(total_signs, len(self.fields[field_iid].data))
        if total_signs == 0:
            print('No fields with data.')
            return
        try:
            sheet_width = float(self.sheet_width_var.get())
            sheet_height = float(self.sheet_height_var.get())
            sign_width = float(self.sign_width_var.get())
            sign_height = float(self.sign_height_var.get())
            layers_per_sheet = int(self.layers_per_sheet_var.get())
            assert sign_width > 0, 'Sign width must be greater than 0.'
            assert sign_height > 0, 'Sign height must be greater than 0.'
            assert sheet_width >= sign_width, 'Sheet width must be greater than sign width.'
            assert sheet_height >= sign_height, 'Sheet height must be greater than sign height.'
        except ValueError:
            print('Invalid dimensions.')
            return
        except AssertionError as e:
            print(e)
            return

        # Show progress bar.
        progress_bar = Progressbar(self.frame)
        progress_bar.grid(column=0, row=5, columnspan=4, sticky='WE')

        # Calculate the needed values to define sheet layout.
        signs_per_row = int(sheet_width // sign_width)
        signs_per_column = int(sheet_height // sign_height)
        signs_per_layer = signs_per_row * signs_per_column
        # Ceiling division.
        total_layers = -int(-total_signs // signs_per_layer)
        if layers_per_sheet > 0:
            total_sheets = -int(-total_layers // layers_per_sheet)
        else:
            total_sheets = 1

        print(
            f'Marking total of {total_signs} signs ({sign_width} x {sign_height}).'
        )
        print(
            f'Sheet size of {sheet_width} x {sheet_height} fits {signs_per_row} x {signs_per_column} signs,'
        )
        print(
            f'so the effective sheet size is {signs_per_row * sign_width} x {signs_per_column * sign_height}.'
        )
        print(f'Total of {total_layers} layer(s) are needed.')
        if layers_per_sheet == 0:
            print(
                'There is no limit on the maximum amount of layers per sheet,')
        else:
            print(
                f'There are maximum of {layers_per_sheet} layer(s) per sheet,')
        print(f'so total of {total_sheets} sheet(s) are needed.')

        # Create needed sheet objects.
        print('Creating sheets.')
        sheets = []
        for _ in range(total_sheets):
            sheets.append(ezdxf.new(self.dxf_version.get()))

        # Iterate over all layers and draw their outline based on how many signs that layer will have.
        print('Drawing layer outlines.')
        for layer in range(total_layers):
            max_x = sign_width * signs_per_row
            max_y = -sign_height * signs_per_column
            if layer == total_layers - 1:  # If last layer.
                signs_in_last_sheet = total_signs - layer * signs_per_layer
                if signs_in_last_sheet < signs_per_row:
                    max_x = sign_width * signs_in_last_sheet
                max_y = sign_height * (-signs_in_last_sheet // signs_per_row)
            if layers_per_sheet > 0:
                sheet_index = layer // layers_per_sheet
            else:
                sheet_index = 0
            # Draw layer outline (left and top side bounds).
            sheets[sheet_index].modelspace().add_lwpolyline(
                [(0, max_y), (0, 0), (max_x, 0)],
                dxfattribs={'layer': str(layer)})

        # Iterate over each sign.
        print('Drawing marks.')
        for sign_index in range(total_signs):
            # Update progress bar value.
            progress_bar['value'] = (sign_index + 1) / total_signs * 100
            progress_bar.update()

            # Calculate in which position, in which layer of which sheet the current sign should be drawn.
            layer = sign_index // signs_per_layer
            layer_position = sign_index % signs_per_layer
            sign_origin_x = (layer_position % signs_per_row) * sign_width
            sign_origin_y = -(layer_position // signs_per_row) * sign_height
            if layers_per_sheet > 0:
                sheet_index = layer // layers_per_sheet
            else:
                sheet_index = 0
            sheet = sheets[sheet_index]

            # Draw marks (QR, Text and Hole objects).
            for field_iid in self.fields:
                try:
                    self.fields[field_iid].draw(sign_index, sheet, layer,
                                                sign_origin_x, sign_origin_y,
                                                sign_width, sign_height)
                except Exception as e:
                    print(e)
                    progress_bar.grid_forget()
                    return

            # Draw sign outline (right and bottom side bounds).
            sign_outline = [(sign_origin_x, sign_origin_y - sign_height),
                            (sign_origin_x + sign_width,
                             sign_origin_y - sign_height),
                            (sign_origin_x + sign_width, sign_origin_y)]
            sheet.modelspace().add_lwpolyline(sign_outline,
                                              dxfattribs={'layer': str(layer)})

        # Save sheets.
        # Get a output directory if there are multiple sheets to be saved, otherwise get path for the single output (.dxf) file.
        print('Saving.')
        if total_sheets > 1:
            if directory := tkinter.filedialog.askdirectory():
                for index, sheet in enumerate(sheets):
                    # Indicate save progress.
                    progress_bar['value'] = (index + 1) / len(sheets) * 100
                    progress_bar.update()
                    sheet.saveas(Path(directory) / f'sheet{index}.dxf')
        elif path := tkinter.filedialog.asksaveasfilename(
                defaultextension='.dxf',
                filetypes=(('DXF', '*.dxf'), ('All files', '*.*'))):
            sheets[0].saveas(path)
Esempio n. 28
0
class explorer(tk.Toplevel):
    def __init__(self, *args, **kwargs):
        tk.Toplevel.__init__(self, *args, **kwargs)
        self.geometry(f"{WIDTH}x{HEIGHT}")
        self.title("Explorer")
        """
		Map to connect the string id's of the various nodes with layout:
		{
			{"entry" : DirEntry, "built" : False},
			{"entry" : DirEntry, "built" : False},
			...
		}
		"built" indicates whether or not the node has been populated
		assuming it has children nodes.

		DirEntry is an object produced by the itterable os.scandir()
		It has several methods  it similar to those in the module os.path
		such as is_file, is_dir, and stat, and the object caches these
		values for later calls, resulting in better performance.

		The root node is mapped to "" and uses an artifical DirEntry.
		The rest are mapped to their string id's provided at the time of the node's creation.
		"""
        self.node_map = {}

        self.style = Style(self)
        #Style treeview, not styling means
        #later calls to tag_configure() don't work
        self.style.map("Treeview",
                       foreground=[("disabled", "white")],
                       background=[("disabled", "black")])

        #If a path was passed set the current dir to it
        #Otherwise set it to the user's home dir
        if "path" in args: self.current_dir = kwargs.pop("path")
        else: self.current_dir = os.path.expanduser("~")

        self.set_title(self.current_dir)
        self.file_icon = load_tk_image_from_bytes_array(file_image_bytes)
        self.folder_icon = load_tk_image_from_bytes_array(folder_image_bytes)

        self.outer_frame = LabelFrame(self)
        self.outer_frame.pack(fill="both", expand=1, padx=5, pady=5)

        #Top row, frame to add a path to enter a path and button to go to it
        self.path_frame = Frame(self.outer_frame)
        self.path_frame.pack(side="top", expand=0, fill="x")
        self.path_box = Entry(self.path_frame)
        self.path_box.pack(side="left",
                           expand=1,
                           fill="both",
                           padx=5,
                           pady=(1, 5))
        self.submit_path_button = Button(self.path_frame,
                                         text="⏎",
                                         command=self.submit_path)
        self.submit_path_button.pack(side="right",
                                     expand=0,
                                     fill="both",
                                     padx=(0, 4),
                                     pady=(0, 4))  #Buttons have weird padding

        self.tree = ScrolledTree(self.outer_frame,
                                 columns=("size", "modified"))
        self.tree.pack(side="top", expand=1, fill="both", padx=5, pady=(0, 5))
        self.tree.bind("<Double-1>", self.on_double_click)
        self.tree.bind("<<TreeviewOpen>>", self.on_open)
        self.tree.column("#0", width=150)
        self.tree.column("size", width=60, minwidth=60, stretch="no")
        self.tree.column("modified", width=150, minwidth=150, stretch="no")
        self.tree.heading("#0", text="...", anchor="w")
        self.tree.heading("size", text="Size", anchor="w")
        self.tree.heading("modified", text="Modified", anchor="w")

        self.populate(self.current_dir)

    def set_title(self, string):
        self.title(f"TK Explorer - {string}")

    def submit_path(self):
        self.populate(self.tree.selection()[0])

    def on_open(self, event):
        #Get current node and attempt to build it
        #build_node will immediately return if already built
        self.build_node(self.tree.focus())

    def populate(self, dir: os.path):
        self.current_dir = dir
        self.node_map = {}  #Clear node map
        self.tree.delete(*self.tree.get_children())
        self.set_title(self.current_dir)
        self.build_tree()
        self.outer_frame.configure(
            text=self.current_dir)  #Set frame label text

    def build_tree(self):
        """Fills the tree with the contents of the path at self.current_dir"""
        #Create entry in the node map for the tree root
        self.node_map[""] = {
            "entry": DirEntry(self.current_dir),
            "built": False
        }
        self.build_node("")  #Build tree root

    def build_node(self, node: id):
        """"""
        node_dict = self.node_map[node]
        if node_dict["built"]: return

        path = node_dict["entry"]
        self.tree.delete(*self.tree.get_children(node))
        try:
            dir_items = os.scandir(path.path)
        except PermissionError:
            dir_items = []

        files, folders_then_both = [], []
        for entry in dir_items:  #Sort files from folders
            files.append(
                entry) if entry.is_file() else folders_then_both.append(entry)
        folders_then_both.extend(files)  #Sort folders-first
        for entry in folders_then_both:
            if entry.is_file():
                size = _sizeof_fmt(os.path.getsize(
                    entry.path))  #Get friendly file size
                modified = _get_human_mtime(
                    entry.path)  #Get human modified time
            else:
                size = ""
                modified = ""

            branch = self.tree.insert(node,
                                      "end",
                                      text=entry.name,
                                      values=(size, modified, ""))
            self.build_branch(branch, entry)  #Flesh out the branch
            #Built status is set to false if it's a dir since it may have children
            self.node_map[branch] = {"entry": entry, "built": entry.is_file()}

        self.node_map[node]["built"] = True

    def build_branch(self, branch: id, entry: DirEntry):
        #Flesh out an empty branch
        #Adds an image to the branch based on its type (file or folder)
        #Also adds a + to the node if it has children
        if entry.is_dir():
            try:
                self.tree.item(branch, image=self.folder_icon)
                if os.scandir(entry.path):
                    #Insert a single empty node in the branch.
                    #This is so the branch has a clickable +,
                    #when the + is clicked build_node(branch) is called.
                    #The empty node gets erased when build_node gets called.
                    self.tree.insert(branch,
                                     "end",
                                     text=".",
                                     values=("", "", ""))
            except PermissionError:  #make folder appear empty if no permission to access it
                print(entry.path)
                pass
        else:
            self.tree.item(branch, image=self.file_icon)

    def on_double_click(self, event):
        region = self.tree.identify("region", event.x, event.y)
        column = self.tree.identify_column(event.x) == "#0"
        if region == "heading" and column:  # If clicking on the "..." on the top left
            self.populate(os.path.dirname(self.current_dir))
        else:
            node_dict = self.node_map[self.tree.selection()[0]]
            if node_dict["entry"].is_dir():
                self.populate(node_dict["entry"].path)
Esempio n. 29
0
class RandomSelector(Frame):
    def __init__(self, master):
        super().__init__(master)
        self.set_vars()
        self.set_frames()
        self.set_widgets()
        self.set_menu()
        self._items = []

    def set_vars(self):
        # tkinter variable
        self.item = StringVar()
        self.item.set('Item Name')
        self.hide = BooleanVar()
        self.hide.set(False)

    def set_frames(self):
        self.seladd_frame = Frame(self)
        self.itemframe = LabelFrame(self, text='Items')
        self.seladd_frame.pack()
        self.itemframe.pack(fill='both', expand=1)

    def set_widgets(self):
        self.entry = Entry(self.seladd_frame, width=30, textvariable=self.item)
        self.entry.pack(side='left')
        self.sel_button = Button(self.seladd_frame,
                                 text="Select",
                                 command=self.sel,
                                 width=8)
        self.add_button = Button(self.seladd_frame,
                                 text="Add",
                                 command=self.add,
                                 width=8)
        self.sel_button.pack(side='left')
        self.add_button.pack(side='left')
        self.listbox = Listbox(self.itemframe)
        self.listbox.pack(fill='both', expand=1)

    def set_menu(self):
        self.top_menu = Menu(self)
        self.cmd_menu = Menu(self.top_menu)
        self.cmd_menu.add(itemType='command', command=self.sel, label='Select')
        self.cmd_menu.add(itemType='command', command=self.add, label='Add')
        self.cmd_menu.add(itemType='separator')
        self.cmd_menu.add(itemType='command', command=self.quit, label='Quit')
        self.view_menu = Menu(self.top_menu)
        self.view_menu.add(itemType='checkbutton',
                           label='Hide items',
                           onvalue=1,
                           offvalue=0,
                           variable=self.hide,
                           command=self.show)
        self.top_menu.add_cascade(menu=self.cmd_menu,
                                  label='Command',
                                  underline=0)
        self.top_menu.add_cascade(menu=self.view_menu,
                                  label='View',
                                  underline=0)
        self.master['menu'] = self.top_menu

    def sel(self):
        if self._items:
            self.item.set(random.choice(self._items))

    def add(self):
        self._items.append(self.item.get())
        self.listbox.insert('end', self.item.get())

    def show(self):
        if self.hide.get():
            self.itemframe.pack_forget()
        else:
            self.itemframe.pack(fill="both", expand="1")

    def quit(self):
        self.master.destroy()
Esempio n. 30
0
class Varos(object):
    def __init__(self, parent, master, empire, matrozokszama=5):
        self.matrozokszama = IntVar()
        self.matrozokszama.set(matrozokszama)
        self.boss = parent
        self.master = master
        self.empire = empire

    @property
    def nev(self):
        return self.empire.capital

    @property
    def zaszlo(self):
        return self.empire.adjective

    def aktival(self):
        "Működteti a kikötőt."
        self.letrehoz()

    def letrehoz(self):
        self.ablak = Toplevel()
        if self.nev == 'portroyal':
            self.ablak.title((s.language.port + ' - Port Royal'))
        else:
            self.ablak.title((s.language.port, '-', self.nev.capitalize()))
        self.ablak.transient(self.master)
        self.ablak.grab_set()
        self.ujMatrozok(
        )  # A játékos belépésekor a kocka által mutatott számot hozzáadjuk a helyi matrózok létszámához.
        self.tevekenysegek = Frame(
            self.ablak)  # Főkeret: tartalma panelek és gombok
        self.tevekenysegek.pack(side=TOP, ipadx=5)
        # A kép panel
        self.kep = Label(self.tevekenysegek, image=Gallery.get(self.nev))
        self.kep.pack(side=LEFT, pady=5, padx=5, fill=Y)
        # A fogadó panel
        self.fogado = LabelFrame(self.tevekenysegek, text=s.language.tavern)
        line1 = Frame(self.fogado)  # a bérelhető létszám
        Label(line1, text=(s.language.sailors_to_hire + ':')).pack(side=LEFT)
        self.matrozokszama_kiirva = Label(
            line1, textvariable=self.matrozokszama).pack(side=RIGHT)
        line1.pack(side=TOP, fill=X)
        line2 = Frame(self.fogado)  # legénység / hajó max. kapacitás
        Label(line2, text=(s.language.crew + ':')).pack(side=LEFT)
        Label(line2,
              textvariable=self.boss.aktivjatekos.crew_limit).pack(side=RIGHT)
        Label(line2, text='/').pack(side=RIGHT)
        Label(line2, textvariable=self.boss.aktivjatekos.crew).pack(side=RIGHT)
        line2.pack(side=TOP, fill=X)
        Separator(self.fogado, orient=HORIZONTAL).pack(side=TOP,
                                                       fill=X,
                                                       pady=5,
                                                       padx=5)
        line3 = Frame(self.fogado)  # a skála címe
        szoveg = s.language.crew_new
        szoveg = szoveg + ' ' * (33 - len(szoveg))
        Label(line3, text=szoveg).pack(side=LEFT)
        line3.pack(side=TOP, fill=X)
        self.line4 = Frame(self.fogado)  # a skála
        self.berskala = Scale(self.line4)
        self.line4.pack(side=TOP, fill=X)
        self.line5 = Frame(
            self.fogado)  # a skálán beállított értéket érvényesítő gomb
        self.skalaCimke = Label(self.line5)
        self.felberel = Button(self.line5,
                               text=s.language.crew_hire,
                               command=self.matrozFelberelese)
        self.felberel.pack(side=RIGHT, padx=5, pady=5)
        self.line5.pack(side=TOP, fill=X)
        self.fogado.pack(side=LEFT, pady=5, padx=5, fill=Y)
        # A hajóács panel
        self.hajoacs = LabelFrame(self.tevekenysegek,
                                  text=s.language.shipwright)
        self.hajoacs_lekepez()
        self.hajoacs.pack(side=LEFT, fill=Y, pady=5)
        # A kormányzó panel
        pontok = 0
        kormanyzo_mondja = StringVar()
        for pontforras in self.boss.aktivjatekos.scores.keys():
            pontok += self.boss.aktivjatekos.scores[pontforras].get()
        self.kormanyzo = LabelFrame(self.tevekenysegek,
                                    text=s.language.governor)
        if self.empire == 'pirate':
            elsullyesztettHelyiHajok = 0  # A kalózok nem birodalom, nem büntetnek az elsüllyedt kalózhajókért
        else:
            elsullyesztettHelyiHajok = self.boss.aktivjatekos.scores[
                self.empire.adjective].get()
        if elsullyesztettHelyiHajok > 0:
            kormanyzo_mondja.set(s.language.governor_punish %
                                 elsullyesztettHelyiHajok)
            self.boss.aktivjatekos.update_turns_to_miss(
                elsullyesztettHelyiHajok)
            self.boss.aktivjatekos.scores[self.empire.adjective].set(0)
        else:
            maxJutalom = self.jutalomszamolo() * 8
            kormanyzo_mondja.set(s.language.governor_reward % maxJutalom)
            self.boss.aktivjatekos.update_gold(maxJutalom)
            self.penzszamolo()
            for birodalom in self.boss.aktivjatekos.scores.keys():
                self.boss.aktivjatekos.scores[birodalom].set(0)
        Label(self.kormanyzo, wraplength=125,
              textvariable=kormanyzo_mondja).pack(side=LEFT)
        if self.empire != 'pirate' and pontok > 0:
            self.kormanyzo.pack(side=LEFT, pady=5, padx=5, fill=Y)
        # Gombok
        Button(self.ablak, text=s.language.done,
               command=self.ablak.destroy).pack(side=BOTTOM, pady=5)
        self.ablak.update_idletasks()
        w, h = self.ablak.winfo_width(), self.ablak.winfo_height()
        bx, by = self.master.get_window_position()
        bh, bw = self.master.height, self.master.width
        self.ablak.geometry('+' + str(int(bx + (bw + (bh / 3) - w) / 2)) +
                            '+' + str(int(by + (bh - h) / 2)))
        self.master.wait_window(self.ablak)

    def hajoacs_lekepez(self):
        "A hajóácspanel."
        self.hajoframek = {}
        self.hajogombok = {}
        for hajo in self.boss.vehetoHajok:
            self.hajoframek[hajo] = Frame(self.hajoacs)
            self.hajogombok[hajo] = Button(
                self.hajoframek[hajo],
                image=Gallery.get(hajo),
                command=lambda hajo=hajo: self.ujHajo(hajo))
            self.hajogombok[hajo].pack(side=LEFT)
            if self.boss.aktivjatekos.ship in self.boss.vehetoHajok:
                if self.boss.vehetoHajok.index(
                        self.boss.aktivjatekos.ship
                ) < self.boss.vehetoHajok.index(hajo):
                    ar = self.boss.hajotipustar[
                        hajo].price - self.boss.hajotipustar[
                            self.boss.aktivjatekos.ship].price
                    Label(self.hajoframek[hajo],
                          text='%s: %i %s' %
                          (s.language.price, ar, s.language.gold)).pack(
                              side=LEFT, fill=X)
                else:
                    Label(self.hajoframek[hajo],
                          text=s.language.already_bought).pack(side=LEFT,
                                                               fill=X)
            else:
                Label(self.hajoframek[hajo],
                      text='%s: %i %s' %
                      (s.language.price, self.boss.hajotipustar[hajo].price,
                       s.language.gold)).pack(side=LEFT, fill=X)
            self.hajoframek[hajo].pack(side=TOP, pady=5, padx=5, fill=X)
        self.penzszamolo()
        self.hajoacs.pack(fill=Y, pady=5)

    def jutalomszamolo(self):
        "Megmutatja, mennyi jutalmat vehet át a játékos legfeljebb."
        scores = self.boss.aktivjatekos.scores
        pontszam = 0
        for birodalom in scores.keys():
            helyiPontszam = scores[birodalom].get()
            if helyiPontszam / 5 > 0:
                pontszam += int(helyiPontszam / 5) * 7
                helyiPontszam = helyiPontszam % 5
            if helyiPontszam / 3 > 0:
                pontszam += int(helyiPontszam / 3) * 4
                helyiPontszam = helyiPontszam % 3
            pontszam += helyiPontszam
        return pontszam

    def penzszamolo(self):
        "A játékos anyagi lehetőségeinek fényében engedélyezi a hajók vásárlását."
        current_ship = self.boss.aktivjatekos.ship
        if current_ship in self.boss.vehetoHajok:
            for hajo in self.boss.vehetoHajok:
                price = self.boss.hajotipustar[hajo].price
                if hajo == current_ship:
                    self.hajogombok[hajo].config(state=DISABLED)
                elif price < self.boss.hajotipustar[current_ship].price:
                    self.hajogombok[hajo].config(state=DISABLED)
                elif price - self.boss.hajotipustar[
                        current_ship].price > self.boss.aktivjatekos.gold.get(
                        ):
                    self.hajogombok[hajo].config(state=DISABLED)
                else:
                    self.hajogombok[hajo].config(state=NORMAL)
        else:
            for hajo in self.boss.vehetoHajok:
                if self.boss.hajotipustar[
                        hajo].price > self.boss.aktivjatekos.gold.get():
                    self.hajogombok[hajo].config(state=DISABLED)
                else:
                    self.hajogombok[hajo].config(state=NORMAL)
        self.berskalat_letrehoz()

    def berskalat_letrehoz(self):
        "Létrehozza a skálát, a felbérelendő matrózok számának kijelöléséhez."
        crew_limit = self.boss.hajotipustar[
            self.boss.aktivjatekos.
            ship].crew_limit - self.boss.aktivjatekos.crew.get()
        locally_available_sailors = self.matrozokszama.get()
        berskalahossz = min(crew_limit, locally_available_sailors,
                            self.boss.aktivjatekos.gold.get())
        self.berskala.destroy()
        self.skalaCimke.destroy()
        if not berskalahossz:
            if self.boss.hajotipustar[
                    self.boss.aktivjatekos.
                    ship].crew_limit - self.boss.aktivjatekos.crew.get() == 0:
                visszajelzes = s.language.crew_ship_full
            elif self.matrozokszama.get() == 0:
                visszajelzes = s.language.crew_port_empty
            else:
                visszajelzes = s.language.crew_no_money
            self.berskala = Label(self.line4, text=visszajelzes)
            self.felberel.config(state=DISABLED)
        else:
            self.berskala = Scale(self.line4,
                                  from_=0,
                                  to=berskalahossz,
                                  orient=HORIZONTAL,
                                  resolution=1,
                                  takefocus=0,
                                  showvalue=0,
                                  command=self.berskalaErtek)
            self.skalaCimke = Label(self.line5)
            self.skalaCimke.pack()
            self.felberel.config(state=NORMAL)
        self.berskala.pack(side=TOP, fill=X)

    def berskalaErtek(self, event):
        self.skalaCimke.config(text=str(self.berskala.get()))

    def ujMatrozok(self):
        self.matrozokszama.set(self.matrozokszama.get() +
                               self.boss.boss.menu.game_tab.die._current_value)

    def matrozFelberelese(self):
        "Lebonyolítja a metrózok felbérelésével járó tranzakciót"
        delta = self.berskala.get()
        if not delta:
            return
        else:
            self.boss.aktivjatekos.update_crew(delta)
            self.boss.aktivjatekos.update_gold(-delta)
            self.matrozokszama.set(self.matrozokszama.get() - delta)
            self.berskalat_letrehoz()
        self.penzszamolo()

    def ujHajo(self, tipus=''):
        "Lebonyolítja az új hajó vásárlásával járó tranzakciót"
        ar = self.boss.hajotipustar[tipus].price - self.boss.hajotipustar[
            self.boss.aktivjatekos.ship].price
        self.boss.aktivjatekos.update_ship(tipus)
        self.boss.aktivjatekos.update_gold(-ar)
        self.boss.aktivjatekos.crew_limit.set(
            self.boss.hajotipustar[tipus].crew_limit)
        for hajo in self.boss.vehetoHajok:
            self.hajoframek[hajo].destroy()
            self.hajogombok[hajo].destroy()
        self.hajoacs_lekepez()

    def export_matroz(self):
        "Átadja saját adatait a mentéshez."
        return self.matrozokszama.get()
Esempio n. 31
0
    def init_ui(self):
        self.master.title("VAD Test")
        self.pack(side="top", fill=BOTH, expand=True)

        # VAD Controls section for controlling these VAD settings:
        controls_frame = LabelFrame(self, text="Controls", height=30)
        Label(controls_frame, text="tau_up:").grid(row=0, column=0)
        self.tau_up = Entry(controls_frame, width=15)
        self.tau_up.grid(row=1, column=0)

        Label(controls_frame, text="tau_down:").grid(row=0, column=1)
        self.tau_down = Entry(controls_frame, width=15)
        self.tau_down.grid(row=1, column=1)

        Label(controls_frame, text="threshold_up:").grid(row=0, column=2)
        self.threshold_up = Entry(controls_frame, width=15)
        self.threshold_up.grid(row=1, column=2)

        Label(controls_frame, text="threshold_down:").grid(row=0, column=3)
        self.threshold_down = Entry(controls_frame, width=15)
        self.threshold_down.grid(row=1, column=3)

        Label(controls_frame, text="large_input:").grid(row=0, column=4)
        self.large_input = Entry(controls_frame, width=15)
        self.large_input.grid(row=1, column=4)

        Label(controls_frame, text="gain_att:").grid(row=0, column=5)
        self.gain_att = Entry(controls_frame, width=15)
        self.gain_att.grid(row=1, column=5)

        Label(controls_frame, text="level_threshold:").grid(row=0, column=6)
        self.level_threshold = Entry(controls_frame, width=15)
        self.level_threshold.grid(row=1, column=6)
        controls_frame.pack(side=TOP)

        # Input section
        input_frame = LabelFrame(self, text="Input")
        input_frame.bind("-", self.on_minus_key)
        input_frame.bind("+", self.on_plus_key)
        input_frame.pack(fill=X)
        self.play_button = Button(input_frame,
                                  text="Play",
                                  command=self.on_play_button_click)
        self.play_button.pack(side=RIGHT, padx=4)
        self.rec_button = Button(input_frame,
                                 text="Rec",
                                 command=self.on_rec_button_click)
        self.rec_button.pack(side=RIGHT, padx=4)
        self.wav_filename_entry = Entry(input_frame, width=24)
        self.wav_filename_entry.pack(fill=X)
        self.wav_filename_entry.delete(0, END)

        # Feature section
        features_frame = LabelFrame(self, text="Features")
        features_frame.pack(fill=X)

        features_control_frame = Frame(features_frame)
        features_control_frame.pack(fill=X)
        load_features_button = Button(features_control_frame,
                                      text="Load",
                                      command=self.on_load_featurizer_model)
        load_features_button.pack(side=RIGHT)
        self.features_entry = Entry(features_control_frame, width=8)
        self.features_entry.pack(fill=X)
        self.features_entry.delete(0, END)

        viz_frame = Frame(features_frame)
        viz_frame.bind("%w", self.on_resized)
        viz_frame.pack(fill=X)
        self.features_figure = Figure(figsize=(5, 4), dpi=96)
        self.subplot = self.features_figure.add_subplot(211)

        self.subplot2 = self.features_figure.add_subplot(212)

        self.canvas = FigureCanvasTkAgg(self.features_figure, master=viz_frame)
        self.canvas.draw()
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=True)

        # Output section
        output_frame = LabelFrame(self, text="Output")
        output_frame.pack(fill=BOTH, expand=True)
        self.bind("<Configure>", self.on_resized)

        self.output_text = Text(output_frame)
        self.output_text.pack(fill=BOTH, padx=4, expand=True)
Esempio n. 32
0
from tkinter import Frame, Tk
from tkinter.ttk import LabelFrame, Style

root = Tk()

s = Style()
ch = 'lightgreen'  # change label colour here, we could program different colours to suit the application requirements
s.configure(ch + '.TLabelframe.Label',
            background=ch)  # altering label - anciliary part
s.configure('pink.TLabelframe', background='pink')  # altering main part
s.configure('both.TLabelframe', background='#40E0D0')  # altering both parts
s.configure('both.TLabelframe.Label',
            background='light blue')  # altering both parts

# LabelFrame with altered anciliary part
lf = LabelFrame(root, text="Label", style=ch +
                ".TLabelframe")  # do not use ch+".TLabelframe.Label"
lf.pack(anchor="w", ipadx=10, ipady=5, padx=10, pady=0, side="top")
Frame(lf, width=100, height=100, bg='yellow').pack()

# LabelFrame with altered main part
lf1 = LabelFrame(root, text="Frame", style="pink.TLabelframe")
lf1.pack(anchor="w", ipadx=10, ipady=5, padx=10, pady=5, side="top")
Frame(lf1, width=100, height=100, bg='yellow').pack()

# LabelFrame with both parts altered
lf2 = LabelFrame(root, text="Both", style="both.TLabelframe")
lf2.pack(anchor="w", ipadx=10, ipady=5, padx=10, pady=0, side="top")
Frame(lf2, width=100, height=100, bg='yellow').pack()
root.mainloop()