コード例 #1
0
    def __init__(self, parent, controller):
        blok = StringVar()
        rno = StringVar()

        def rdet(block, rno):
            cur.execute("select * from room where block='%s' and rno=%s" %
                        (block, rno))
            res = cur.fetchall()
            size = res[0]['beds']
            avail = res[0]['taken']
            if (res[0]['Type'] == 'A'):
                rtype = 'AC'
            elif (res[0]['Type'] == 'N'):
                rtype = 'Non AC'
            if (avail == 1):
                avail = 'No'
            elif (avail == 0):
                avail = 'Yes'
            rinfo = tk.Toplevel()
            rinfo.title("{} Block {} Room info".format(block, rno))
            rinfo.geometry("550x400")
            photo1 = tk.PhotoImage(file="map.png")
            w1 = tk.Label(rinfo, image=photo1)
            w1.image = photo1
            w1.pack()
            if (size == 1):
                p = tk.PhotoImage(file="bed1.png")
                w = tk.Label(rinfo, image=p)
                w.image = p
                w.pack(padx=10, pady=0, side=tk.LEFT)
            else:
                for k in range(0, int(size / 2)):
                    p = tk.PhotoImage(file="bed.png")
                    w = tk.Label(rinfo, image=p)
                    w.image = p
                    w.pack(side=tk.LEFT)

            num = tk.Label(
                rinfo,
                text="No of beds={}\nBLOCK={}\nROOM NO:{}\nTYPE:{}\nAVAIL:{}".
                format(size, block, rno, rtype, avail),
                font=F_FONT)
            num.pack(pady=10, padx=10, side=tk.TOP)

        tk.Frame.__init__(self, parent)
        photo = tk.PhotoImage(file="rdetails.png")
        w = tk.Label(self, image=photo)
        w.image = photo
        w.pack()
        block = tk.Label(self, text="Block:", fg="#383239", bg="#a1dbcd")
        b_ent = tk.Entry(self, textvariable=blok)
        r_no = tk.Label(self, text="Room No:", fg="#383239", bg="#a1dbcd")
        r_ent = tk.Entry(self, textvariable=rno)
        block.pack(pady=10, padx=10)
        b_ent.pack(pady=5, padx=5)
        r_no.pack(pady=10, padx=10)
        r_ent.pack(pady=5, padx=5)
        getinfo = ttk.Button(self,
                             text="Get Room details",
                             command=lambda: rdet(blok.get(), rno.get()))
        getinfo.pack(pady=7, padx=7)
        button = ttk.Button(self,
                            text="Back to Login Page",
                            command=lambda: controller.show_frame(loginpage))
        button.pack()
コード例 #2
0
timer.iconbitmap('icon.ico')
bg = PhotoImage(file='Untitled-2.png')
timer.title("timer")

hour = IntVar()
minute = IntVar()
second = IntVar()

bg_label = Label(timer, image=bg, relief='flat', bd=0)
bg_label.place(x=0, y=0)
h_spin = ttk.Spinbox(timer, from_=00, to=23, width=5, textvariable=hour)
h_spin.place(x=55, y=70)
m_spin = ttk.Spinbox(timer, from_=00, to=59, width=5, textvariable=minute)
m_spin.place(x=110, y=70)
s_spin = ttk.Spinbox(timer, from_=00, to=59, width=5, textvariable=second)
s_spin.place(x=165, y=70)
start = ttk.Button(timer, text='start', command=start_)
start.place(x=100, y=100)
stop = ttk.Button(timer, text='stop', command=stop_)  #135

pause = ttk.Button(timer, text='pause', command=pause_)  #60

continue_ = ttk.Button(timer, text='continue', command=continue__)
h_Label = ttk.Label(timer, textvariable=hour)
m_Label = ttk.Label(timer, textvariable=minute)
s_Label = ttk.Label(timer, textvariable=second)

m1 = ttk.Label(timer, text=':')
m2 = ttk.Label(timer, text=':')

timer.mainloop()
コード例 #3
0
ファイル: MainPage.py プロジェクト: Lafayette-FSAE/BCID
    def setupGUI(self, parent, controller):
        ### Initialise Frame
        tk.Frame.__init__(self, parent)

        ### Matplotlib 2 Tk Stuff
        canvas = FigureCanvasTkAgg(self.fig, self)
        canvas.draw()
        canvas.get_tk_widget().grid(row=0,column=0)
        #canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)

        ## Setup up toolbar in its own frame since it likes to pack shit
        toolbarFrame = ttk.Frame(self)
        toolbarFrame.grid(row=0, column=0, sticky="NW")
        toolbar = NavigationToolbar2Tk(canvas, toolbarFrame)
        toolbar.update()
        ## Draw the new canvas ting
        canvas._tkcanvas.grid(row=0,column=0)


        ### Set Current Button
        self.setCurrentButton = ttk.Button(controller)
        self.setCurrentButton.configure(text="Set Current", command=self.setCurrentLevel)
        self.setCurrentButton.grid(row=2, column=0, sticky="W")

        ### Live Label
        self.liveLabel = ttk.Label(controller, text="Live Values:")
        self.liveLabel.grid(row=1, column=0)

        ### Live Current Measurement
        self.liveCurrentLabel = ttk.Label(controller, text=str(self.liveCurrent)+"A")
        self.liveCurrentLabel.grid(row=2, column=0)

        ## Live Voltage Measurement
        self.liveVoltageLabel = ttk.Label(controller, text=str(self.liveVoltage)+"V")
        self.liveVoltageLabel.grid(row=3, column=0)

        ### Current Entry Field
        self.currentSetEntryWidget = ttk.Entry(controller)
        self.currentSetEntryWidget.grid(row=2,column=0, sticky="E")
        self.currentSetEntryWidget.insert(0,"Enter Desired Current")

        ### Set Cutoff Voltage Button
        self.setVoltageCutoffButton = ttk.Button(controller)
        self.setVoltageCutoffButton.configure(text="Set Cutoff Voltage", command=self.setVoltageCutoffLevel)
        self.setVoltageCutoffButton.grid(row=3, column=0, sticky="W")

        ### Voltage Cutoff Entry Field
        self.voltageCutoffEntryWidget = ttk.Entry(controller)
        self.voltageCutoffEntryWidget.grid(row=3, column=0, sticky="E")
        self.voltageCutoffEntryWidget.insert(0, "Enter Cutoff Voltage")

        ### Start Button
        self.startButton = ttk.Button(controller)
        self.startButton.configure(text="Start", command=self.startTest)
        self.startButton.grid(row=1, column=0, sticky="W")

        ### Stop Button
        self.stopButton = ttk.Button(controller)
        self.stopButton.configure(text="Stop", command=self.stopTest)
        self.stopButton.grid(row=1, column=0, sticky="E")

        ### COM List
        self.COMList = ttk.OptionMenu(controller, self.COMPort, *self.COMPorts)
        self.COMList.grid(row=0, column=0, stick="NE")

        ### Set COM Button
        self.setCOMButton = ttk.Button(controller)
        self.setCOMButton.configure(text="Connect", command=self.connectToSerial)
        self.setCOMButton.grid(row=0, column=0, sticky="NE", pady=25)

        ## Set Current Offset Scale
        self.setCurrentOffsetScale = tk.Scale(self.currentOffset, orient='horizontal', from_=-5, to=5, length=1000, resolution=0.01)
        self.setCurrentOffsetScale.grid(row=4, column=0)

        ## Set Current Offset Button
        self.setCurrentOffsetButton = ttk.Button(controller)
        self.setCurrentOffsetButton.configure(text="Set Current Offset", command=self.setCurrentOffset)
        self.setCurrentOffsetButton.grid(row=4, column=0, sticky="W")

        ## Set Voltage Offset Scale
        self.setVoltageOffsetScale = tk.Scale(self.voltageOffset, orient='horizontal', from_=-5, to=5, length=1000, resolution=0.01)
        self.setVoltageOffsetScale.grid(row=5, column=0)

        ## Set Voltage Offset Button
        self.setVoltageOffsetButton = ttk.Button(controller)
        self.setVoltageOffsetButton.configure(text="Set Voltage Offset", command=self.setVoltageOffset)
        self.setVoltageOffsetButton.grid(row=5, column=0, sticky="W")

        ### mAh Title
        self.mahTitleLabel = ttk.Label(controller, text="mAh")
        self.mahTitleLabel.grid(row=4, column=0, sticky="E", pady=30)

        ### mAh Count
        self.mahCountLabel = ttk.Label(controller, text="0")
        self.mahCountLabel.grid(row=5, column=0, sticky="E")
コード例 #4
0
def find_func(event=None):
    ##using tag inbuilt function
    def find():
        word = find_input.get()
        text_editor.tag_remove('match', '1.0', tk.END)
        matches = 0
        if word:
            start_pos = '1.0'
            while True:
                start_pos = text_editor.search(word,
                                               start_pos,
                                               stopindex=tk.END)
                if (not start_pos):
                    break
                end_pos = f'{start_pos}+{len(word)}c'
                text_editor.tag_add('match', start_pos, end_pos)
                matches += 1
                start_pos = end_pos
                text_editor.tag_config('match',
                                       foreground='red',
                                       background='')

    def replace():
        word = find_input.get()
        replace_text = replace_input.get()
        content = text_editor.get(1.0, tk.END)
        new_content = content.replace(word, replace_text)
        text_editor.delete(1.0, tk.END)
        text_editor.insert(1.0, new_content)

    find_dialogue = tk.Toplevel()
    find_dialogue.geometry('450x250+500+200')
    find_dialogue.resizable(0, 0)

    ## frame
    find_frame = ttk.LabelFrame(find_dialogue, text='Find/Replace')
    find_frame.pack(pady=20)

    ## labels
    text_find_label = ttk.Label(find_frame, text='Find :')
    text_replace_label = ttk.Label(find_frame, text='Replace')

    ##entry boxes
    find_input = ttk.Entry(find_frame, width=30)
    replace_input = ttk.Entry(find_frame, width=30)

    ## Button
    find_button = ttk.Button(find_frame, text='Find', command=find)
    replace_button = ttk.Button(find_frame, text='Replace', command=replace)

    ##label grid
    text_find_label.grid(row=0, column=0, padx=4, pady=4)
    text_replace_label.grid(row=1, column=0, padx=4, pady=4)

    ##entry grid
    find_input.grid(row=0, column=1, padx=4, pady=4)
    replace_input.grid(row=1, column=1, padx=4, pady=4)

    ##button grid
    find_button.grid(row=2, column=0, padx=8, pady=4)
    replace_button.grid(row=2, column=1, padx=8, pady=4)

    find_dialogue.mainloop()
コード例 #5
0
    def create_feature_widgets(self, argument):

        # ===== Create styles for use with ttk widgets =====
        self.style = ttk.Style()

        # Create a Green style for the label when the On button is used
        self.style.configure('green.TLabel', foreground='black',
                             background='#00ff00', font=('FreeSans', 16),
                             padding=10)

        # Create a Red style for the label when the Off button is used
        self.style.configure('red.TLabel', foreground='white',
                             background='#ff0000', font=('FreeSans', 16),
                             padding=10)  # borderwidth=10)

        # Create a Blue style for the label is 0
        self.style.configure('blue.TLabel', foreground='white',
                             background='#0000ff', font=('FreeSans', 16),
                             padding=10)

        # Create a inc style for Increment button
        self.style.configure('inc.TButton',
                             background='#004400',  # Dark Green background
                             foreground='#008800',  # Mid Green characters
                             borderwidth=5,  # bevelling amount raised button
                             highlightthickness='20',  # no effect?
                             font=('FreeSans', 18, 'bold'))
        self.style.map('inc.TButton',
                       foreground=[('disabled', '#aaaaaa'),  # Light grey
                                   ('pressed', '#008800'),  # Mid Green
                                   ('active', '#00ff00')],  # Light Green
                       background=[('disabled', '#cccccc'),  # Light Grey
                                   ('pressed', '#00ff00'),  # Light Green
                                   ('active', '#008800')],  # Mid Green
                       highlightcolor=[('focus', 'green'),  # no effect?
                                       ('!focus', 'red')],  # no effect?
                       relief=[('pressed', 'sunken'),       # Also groove,
                               ('!pressed', 'raised')])     # flat and ridge

        # Create a dec style for Decrement button
        self.style.configure('dec.TButton',
                             background='#440000',  # Dark Red background
                             foreground='#880000',  # Mid Red characters
                             borderwidth=5,  # bevelling to the raised button
                             highlightthickness='20',  # no effect?
                             font=('FreeSans', 18, 'bold'))
        self.style.map('dec.TButton',
                       foreground=[('disabled', '#aaaaaa'),  # Light grey
                                   ('pressed', '#880000'),
                                   ('active', '#ff0000')],  # Light Red
                       background=[('disabled', '#cccccc'),  # Light Grey
                                   ('pressed', '#ff0000'),
                                   ('active', '#880000')],  # Mid Red
                       highlightcolor=[('focus', 'green'),  # no effect?
                                       ('!focus', 'red')],  # no effect?
                       relief=[('pressed', 'sunken'),       # Also groove,
                               ('!pressed', 'raised')])     # ridge flat

        # Create more styles here...

        # ===== Create Widgets =====
        # Create Labels:
        # label_1 - Main label to display the status of the switches
        self.label_1 = ttk.Label(self, text="")

        # Create Buttons:
        # Button On
        self.button_1 = ttk.Button(self, text=BUTTON_1_TEXT,
                                   style='inc.TButton',
                                   command=self.button_1_callback)
        # Button Off
        self.button_2 = ttk.Button(self, text=BUTTON_2_TEXT,
                                   style='dec.TButton',
                                   command=self.button_2_callback)

        # Button Enable/Disable Toggle # ***
        self.button_3 = ttk.Button(self, text=BUTTON_3_TEXT,
                                   command=self.button_3_callback)
        # Button Disable # ***
        # self.button_4 = ttk.Button(self, text=BUTTON_4_TEXT,
        #                           command=self.button_4_callback)

        # Create more widgets here...

        # ===== Add widgets to grid =====
        self.label_1.grid(row=0, column=1, padx=5, pady=5)
        self.button_1.grid(row=1, column=0, padx=10, pady=10)
        self.button_2.grid(row=1, column=2, padx=10, pady=10)
        self.button_3.grid(row=2, column=0, padx=10, pady=10)
コード例 #6
0
ファイル: tab_fetch_files.py プロジェクト: ethoeng/bfit
    def __init__(self, bfit, lines_list, lines_list_old, fetch_tab_frame,
                 bdfit, row):
        """
            Inputs:
                fetch_tab_frame: parent in which to place line
                bdfit: fitdata object corresponding to the file which is placed here. 
                row: where to grid this object
        """

        # get logger
        self.logger = logging.getLogger(logger_name)
        self.logger.debug('Initializing run %d (%d)', bdfit.run, bdfit.year)

        # variables
        self.bfit = bfit
        self.bin_remove = bdfit.omit
        self.label = bdfit.label
        self.rebin = bdfit.rebin
        self.check_state = bdfit.check_state
        self.mode = bdfit.mode
        self.run = bdfit.run
        self.year = bdfit.year
        self.row = row
        self.lines_list = lines_list
        self.lines_list_old = lines_list_old
        bd = bdfit.bd
        self.bdfit = bdfit
        self.id = bdfit.id

        # build objects
        line_frame = Frame(fetch_tab_frame)
        line_frame.bind('<Enter>', self.on_line_enter)
        line_frame.bind('<Leave>', self.on_line_leave)

        bin_remove_entry = ttk.Entry(line_frame,textvariable=self.bin_remove,\
                width=17)

        label_label = ttk.Label(line_frame, text="Label:", pad=5)
        self.label_entry = ttk.Entry(line_frame,textvariable=self.label,\
                width=18)

        remove_button = ttk.Button(line_frame,text='Remove',\
                command=self.degrid,pad=1)
        draw_button = ttk.Button(line_frame,
                                 text='Draw',
                                 command=lambda: self.draw(figstyle='data'),
                                 pad=1)

        self.check_data = BooleanVar()
        self.check_data.set(True)
        draw_data_checkbox = ttk.Checkbutton(line_frame,
                                             text='Data',
                                             variable=self.check_data,
                                             onvalue=True,
                                             offvalue=False,
                                             pad=5)

        self.check_fit = BooleanVar()
        self.check_fit.set(False)
        self.draw_fit_checkbox = ttk.Checkbutton(line_frame,
                                                 text='Fit',
                                                 variable=self.check_fit,
                                                 onvalue=True,
                                                 offvalue=False,
                                                 pad=5,
                                                 state=DISABLED)

        self.check_res = BooleanVar()
        self.check_res.set(False)
        self.draw_res_checkbox = ttk.Checkbutton(line_frame,
                                                 text='Res',
                                                 variable=self.check_res,
                                                 onvalue=True,
                                                 offvalue=False,
                                                 pad=5,
                                                 state=DISABLED)

        rebin_label = ttk.Label(line_frame, text="Rebin:", pad=5)
        rebin_box = Spinbox(line_frame,from_=1,to=100,width=3,\
                textvariable=self.rebin)
        self.rebin.set(self.bfit.fetch_files.check_rebin.get())

        self.check_state.set(bfit.fetch_files.check_state.get())
        self.check = ttk.Checkbutton(line_frame,variable=self.check_state,\
                onvalue=True,offvalue=False,pad=5)

        self.set_check_text()

        # add grey text to bin removal
        bin_remove_entry.insert(0, self.bin_remove_starter_line)
        entry_fn = partial(on_entry_click,\
                text=self.bin_remove_starter_line,entry=bin_remove_entry)
        on_focusout_fn = partial(on_focusout,\
                text=self.bin_remove_starter_line,entry=bin_remove_entry)
        bin_remove_entry.bind('<FocusIn>', entry_fn)
        bin_remove_entry.bind('<FocusOut>', on_focusout_fn)
        bin_remove_entry.config(foreground=colors.entry_grey)

        # add grey text to label
        self.set_label()

        # grid
        c = 1
        self.check.grid(column=c, row=0, sticky=E)
        c += 1
        if self.mode in ['1f', '1n', '1w']:
            bin_remove_entry.grid(column=c, row=0, sticky=E)
            c += 1
        if self.mode in ['20', '2h']:
            rebin_label.grid(column=c, row=0, sticky=E)
            c += 1
            rebin_box.grid(column=c, row=0, sticky=E)
            c += 1
        label_label.grid(column=c, row=0, sticky=E)
        c += 1
        self.label_entry.grid(column=c, row=0, sticky=E)
        c += 1
        draw_data_checkbox.grid(column=c, row=0, sticky=E)
        c += 1
        self.draw_fit_checkbox.grid(column=c, row=0, sticky=E)
        c += 1
        self.draw_res_checkbox.grid(column=c, row=0, sticky=E)
        c += 1
        draw_button.grid(column=c, row=0, sticky=E)
        c += 1
        remove_button.grid(column=c, row=0, sticky=E)
        c += 1

        # resizing
        fetch_tab_frame.grid_columnconfigure(0, weight=1)  # big frame
        for i in (3, 5, 7):
            line_frame.grid_columnconfigure(i, weight=100)  # input labels
        for i in (4, 6, 8):
            line_frame.grid_columnconfigure(i, weight=1)  # input fields

        # passing
        self.line_frame = line_frame
        self.bin_remove_entry = bin_remove_entry
コード例 #7
0
ファイル: main.py プロジェクト: nfrutz/ironing
    def after_file_open(self):
        # OPTIONS READ FROM FILE
        self.read_settings = ttk.LabelFrame(self.main_container,
                                            text="Read from file")
        self.read_settings.grid(row=1, column=0, padx=5, pady=5, sticky='nwes')

        tk.Label(self.read_settings, text="File Name:").grid(row=0,
                                                             column=0,
                                                             padx=5,
                                                             sticky='nwe')
        tk.Label(self.read_settings,
                 text=self.part.filename).grid(row=0,
                                               column=1,
                                               padx=5,
                                               sticky='nwe')

        tk.Label(self.read_settings,
                 text="Number of Layers:").grid(row=1,
                                                column=0,
                                                padx=5,
                                                sticky='nwe')
        tk.Label(self.read_settings,
                 text=len(self.part.list_of_layers)).grid(row=1,
                                                          column=1,
                                                          padx=5,
                                                          sticky='nwe')

        tk.Label(self.read_settings,
                 text="Ironing Enabled:").grid(row=2,
                                               column=0,
                                               padx=5,
                                               sticky='nwe')
        tk.Label(self.read_settings,
                 text=self.part.settings["ironing_enabled"]).grid(row=2,
                                                                  column=1,
                                                                  padx=5,
                                                                  sticky='nwe')

        tk.Label(self.read_settings, text="Ironing Flow:").grid(row=3,
                                                                column=0,
                                                                padx=5,
                                                                sticky='nwe')
        tk.Label(self.read_settings,
                 text=self.part.settings["ironing_flow"]).grid(row=3,
                                                               column=1,
                                                               padx=5,
                                                               sticky='nwe')

        tk.Label(self.read_settings, text="Ironing Inset:").grid(row=4,
                                                                 column=0,
                                                                 padx=5,
                                                                 sticky='nwe')
        #tk.Label(self.read_settings, text=self.part.settings["ironing_inset"]).grid(row=4, column=1, padx=5, sticky='nwe')
        tk.Label(self.read_settings, text="??").grid(row=4,
                                                     column=1,
                                                     padx=5,
                                                     sticky='nwe')

        tk.Label(self.read_settings, text="Speed Ironing:").grid(row=5,
                                                                 column=0,
                                                                 padx=5,
                                                                 sticky='nwe')
        #tk.Label(self.read_settings, text=self.part.settings["speed_ironing"]).grid(row=5, column=1, padx=5, sticky='nwe')
        tk.Label(self.read_settings, text="??").grid(row=5,
                                                     column=1,
                                                     padx=5,
                                                     sticky='nwe')

        # OPTIONS FOR IRONING
        self.ironing_settings = ttk.LabelFrame(self.main_container,
                                               text="Apply Ironing")
        self.ironing_settings.grid(row=2,
                                   column=0,
                                   padx=5,
                                   pady=5,
                                   sticky='nwe')

        self.radio_var = tk.StringVar()
        self.start_layer = tk.StringVar()
        self.end_layer = tk.StringVar()
        self.interval = tk.StringVar()
        self.list_ironings = tk.StringVar()

        self.radio_var.set("opt1")
        self.list_ironings.set("[1,0,1,...,1,0,1]")

        chk_btn_increment = tk.Radiobutton(self.ironing_settings,
                                           variable=self.radio_var,
                                           text="Use Intervals",
                                           value='opt1')
        chk_btn_increment.grid(row=0, column=0, sticky="nw")

        tk.Label(self.ironing_settings, text="Interval").grid(row=1, column=0)
        tk.Spinbox(self.ironing_settings,
                   textvariable=self.interval,
                   from_=1,
                   to=len(self.part.list_of_layers),
                   wrap=True).grid(row=1, column=1, sticky="nw")

        tk.Label(self.ironing_settings, text="Start at Layer").grid(row=2,
                                                                    column=0)
        tk.Spinbox(self.ironing_settings,
                   textvariable=self.start_layer,
                   from_=1,
                   to=len(self.part.list_of_layers),
                   wrap=True).grid(row=2, column=1)

        self.end_layer.set(str(len(self.part.list_of_layers)))
        tk.Label(self.ironing_settings, text="End at Layer",
                 width=8).grid(row=3, column=0)
        tk.Spinbox(self.ironing_settings,
                   textvariable=self.end_layer,
                   from_=1,
                   to=int(self.end_layer.get()),
                   wrap=True).grid(row=3, column=1)

        chk_btn_list = tk.Radiobutton(self.ironing_settings,
                                      variable=self.radio_var,
                                      text="Use a list",
                                      value='opt2')
        chk_btn_list.grid(row=4, column=0, sticky="nw")

        tk.Label(self.ironing_settings,
                 text="Binary list of layers").grid(row=5, column=0)
        tk.Entry(self.ironing_settings,
                 textvariable=self.list_ironings).grid(row=5, column=1)

        # OPTIONS FOR IRONING
        self.advanced_settings = ttk.LabelFrame(self.main_container,
                                                text="Advanced Settings")
        self.advanced_settings.grid(row=3,
                                    column=0,
                                    padx=5,
                                    pady=5,
                                    sticky='news')

        self.flow_dir = tk.StringVar()
        self.flow_dir.set("opta")

        tk.Label(self.advanced_settings, text="Flow Direction").grid(row=0,
                                                                     column=0)
        #chk_btn_flow_rep = tk.Radiobutton(self.advanced_settings, variable=self.flow_dir, text="Replicate", value='opta')
        #chk_btn_flow_rep.grid(row=0, column=1, sticky="nw")
        chk_btn_flow_par = tk.Radiobutton(self.advanced_settings,
                                          variable=self.flow_dir,
                                          text="Parallel",
                                          value='opta')
        chk_btn_flow_par.grid(row=0, column=1, sticky="nw")
        chk_btn_flow_perp = tk.Radiobutton(self.advanced_settings,
                                           variable=self.flow_dir,
                                           text="Perpendicular",
                                           value='optb')
        chk_btn_flow_perp.grid(row=0, column=2, sticky="nw")

        self.disable_flow = tk.IntVar()
        self.disable_flow.set(0)
        tk.Checkbutton(self.advanced_settings,
                       text="Disable Flow",
                       variable=self.disable_flow).grid(row=1,
                                                        column=0,
                                                        sticky="nw")

        self.set_z_offset = tk.IntVar()
        self.z_offset = tk.StringVar()
        self.z_offset.set("0")
        tk.Checkbutton(self.advanced_settings,
                       text="Set Z offset [mm]",
                       variable=self.set_z_offset).grid(row=2,
                                                        column=0,
                                                        sticky="nw")
        tk.Entry(self.advanced_settings, textvariable=self.z_offset,
                 width=12).grid(row=2, column=1, sticky="nw")

        self.set_fan_speed = tk.IntVar()
        self.fan_speed = tk.StringVar()
        self.fan_speed.set("-1")
        tk.Checkbutton(self.advanced_settings,
                       text="Set Fan speed [%]",
                       variable=self.set_fan_speed).grid(row=3,
                                                         column=0,
                                                         sticky="nw")
        tk.Entry(self.advanced_settings, textvariable=self.fan_speed,
                 width=12).grid(row=3, column=1, sticky="nw")

        #tk.Checkbutton(self.advanced_settings, text="Flow direction").grid(row=4, column=0, sticky="nw")
        #tk.Spinbox(self.advanced_settings, textvariable=self.interval, from_=1, to=self.ironing.number_of_layers, width=10).grid(row=4, column=2, sticky="ne")

        # OPERATIONS
        self.calculate_export = ttk.LabelFrame(self.main_container,
                                               text="Operations")
        self.calculate_export.grid(row=4,
                                   column=0,
                                   padx=5,
                                   pady=15,
                                   sticky='nwe')
        #ttk.Button(self.calculate_export, text="Calculate", command=self.calculate_ironing).grid(row=0, column=0, pady=5, padx=20)
        #ttk.Button(self.calculate_export, text="Export", command=self.export_ironing).grid(row=0, column=1, pady=5, padx=20)
        ttk.Button(self.calculate_export,
                   text="Apply Ironing",
                   command=self.export_ironing).grid(row=0,
                                                     column=1,
                                                     pady=5,
                                                     padx=20)
コード例 #8
0
    def set_tool_bar(self):
        self.tool_bar = ttk.Label(self.root)
        self.tool_bar.pack(side=TOP, fill=X)

        ##font Box
        self.font_tuple = font.families()
        self.font_family = StringVar()
        self.font_box = ttk.Combobox(self.tool_bar,
                                     width=30,
                                     textvariable=self.font_family,
                                     state='readonly')
        self.font_box['values'] = self.font_tuple
        self.font_box.current(self.font_tuple.index('Arial'))
        self.font_box.grid(row=0, column=0, padx=5)

        ##Size box
        self.size_var = IntVar()
        self.font_size = ttk.Combobox(self.tool_bar,
                                      width=14,
                                      textvariable=self.size_var,
                                      state='readonly')
        self.font_size['values'] = tuple(range(8, 81))
        self.font_size.current(4)
        self.font_size.grid(row=0, column=1, padx=5)

        ##Bold button
        self.bold_icon = PhotoImage(file='icons/bold.png')
        self.bold_btn = ttk.Button(self.tool_bar, image=self.bold_icon)
        self.bold_btn.grid(row=0, column=2, padx=5)

        ##Itallic button
        self.italic_icon = PhotoImage(file='icons/italic.png')
        self.italic_btn = ttk.Button(self.tool_bar, image=self.italic_icon)
        self.italic_btn.grid(row=0, column=3, padx=5)

        ##underline button
        self.underline_icon = PhotoImage(file='icons/underline.png')
        self.underline_btn = ttk.Button(self.tool_bar,
                                        image=self.underline_icon)
        self.underline_btn.grid(row=0, column=4, padx=5)

        ##font_color button
        self.font_color_icon = PhotoImage(file='icons/font_color.png')
        self.font_color_btn = ttk.Button(self.tool_bar,
                                         image=self.font_color_icon)
        self.font_color_btn.grid(row=0, column=5, padx=5)

        ##align left
        self.align_left_icon = PhotoImage(file='icons/align_left.png')
        self.align_left_btn = ttk.Button(self.tool_bar,
                                         image=self.align_left_icon)
        self.align_left_btn.grid(row=0, column=6, padx=5)

        ##align center
        self.align_center_icon = PhotoImage(file='icons/align_center.png')
        self.align_center_btn = ttk.Button(self.tool_bar,
                                           image=self.align_center_icon)
        self.align_center_btn.grid(row=0, column=7, padx=5)

        ##align right
        self.align_right_icon = PhotoImage(file='icons/align_right.png')
        self.align_right_btn = ttk.Button(self.tool_bar,
                                          image=self.align_right_icon)
        self.align_right_btn.grid(row=0, column=8, padx=5)

        ##mike button
        self.mike_icon = PhotoImage(file='icons/microphone.png')
        self.mike_btn = ttk.Button(self.tool_bar, image=self.mike_icon)
        self.mike_btn.grid(row=0, column=9, padx=5)
コード例 #9
0
Created on Thu Sep 26 11:34:50 2019

@author: John(Yohannes Assebe)
"""
import tkinter as tk
from tkinter import ttk


def btnClicked():
    btn.configure(text='clicked!', state='disabled')
    lab.configure(text="Hi Welcome  " + name.get(), foreground='blue')


win = tk.Tk()
win.title("First App")
#win.resizable(0,0)

lab = ttk.Label(win, text="Enter Your Name:")
lab.grid(column=1, row=1)
#this code creates text box
name = tk.StringVar()
nameEntered = ttk.Entry(win, width=15, textvariable=name)
nameEntered.grid(column=1, row=2)
#this code creates a button
btn = ttk.Button(win, text="clickMe", command=btnClicked)
btn.grid(column=1, row=3)
'''We can write all of our GUI code in advance and nothing will be displayed on
the user's screen until we call this endless loop'''
nameEntered.focus()
tk.mainloop()
コード例 #10
0
from tkinter import *
from tkinter import ttk
import os

root = Tk()


def run():
    os.system('py VibrantEggRing.py')




icon=PhotoImage(file='VibrantEggRing-icon.png')
lbl_image=Label(root, image=icon)
lbl_image.grid(column=0, row=1)

button=ttk.Button(text='Vibrant Egg Ring', command=run)
button.grid(column=1, row=1)


root.mainloop()
コード例 #11
0
ファイル: tryGrid.py プロジェクト: mpmiszczyk/automat
frame = ttk.Frame( content, borderwidth=5, relief="sunken", width=200, height=100 )
namelbl = ttk.Label( content, text="Name" )
name = ttk.Entry( content )

onevar = BooleanVar( )
twovar = BooleanVar( )
threevar = BooleanVar( )

onevar.set( True )
twovar.set( False )
threevar.set( True )

one = ttk.Checkbutton( content, text="One", variable=onevar, onvalue=True )
two = ttk.Checkbutton( content, text="Two", variable=twovar, onvalue=True )
three = ttk.Checkbutton( content, text="Three", variable=threevar, onvalue=True )
ok = ttk.Button( content, text="Okay" )
cancel = ttk.Button( content, text="Cancel" )

content.grid( column=0, row=0, sticky=(N, S, E, W) )
frame.grid( column=0, row=0, columnspan=3, rowspan=2, sticky=(N, S, E, W) )
namelbl.grid( column=3, row=0, columnspan=2, sticky=(N, W), padx=5 )
name.grid( column=3, row=1, columnspan=2, sticky=(N, E, W), pady=5, padx=5 )
one.grid( column=0, row=3 )
two.grid( column=1, row=3 )
three.grid( column=2, row=3 )
ok.grid( column=3, row=3 )
cancel.grid( column=4, row=3 )

root.columnconfigure( 0, weight=1 )
root.rowconfigure( 0, weight=1 )
content.columnconfigure( 0, weight=3 )
コード例 #12
0
from tkinter import *
from tkinter import ttk

root = Tk()
frame1 = ttk.Frame(root)
frame1.pack()
frame1.config(height=200, width=200, relief=RIDGE, padding=(10, 10))
ttk.Button(frame1, text="Click me frame 1").grid(row=0, column=0)
ttk.Button(frame1, text="Click me frame 1").grid(row=0, column=3)

frame2 = ttk.Frame(root)
frame2.pack()
frame2.config(height=200, width=200, relief=RIDGE, padding=(10, 10))
ttk.Button(frame2, text="Click me frame 2").pack()
ttk.Button(frame2, text="Click me frame 2").pack()

ttk.LabelFrame(height=100, width=100, text="Third Frame").pack()

root.mainloop()
コード例 #13
0
    def __init__(self, parent, controller):
        loginid = StringVar()
        pid = StringVar()

        def loginfunc(lid, password):  #checks password
            lid = lid.upper()
            cur.execute(
                "select s.studentID from student s,ainfo a where s.studentID=a.studentID and s.roomID is null order by a.year DESC,a.cgpa DESC;"
            )
            ord = cur.fetchall()
            if (lid == ord[0]['studentID']):
                chance = 1
            else:
                chance = 0
            if (len(lid) > 9 or len(lid) == 0):
                popup = tk.Toplevel()
                popup.title("Caution")
                popup.geometry("200x200")
                popup.configure(background="#a1dbcd", bg="#aadbcd")
                inv = tk.Label(popup, text="INVALID REGISTRATION NUMBER")
                pic = Image.open('warn.png')
                ren = ImageTk.PhotoImage(pic)
                w = tk.Label(popup, image=ren)
                w.image = ren
                w.pack()
                inv.pack()
            cur.execute("select password from student where studentID='%s'" %
                        (lid))
            psw = cur.fetchall()
            if (psw[0]['password'] == password and chance == 1):
                global hen
                hen.append(lid)
                controller.show_frame(reg)
            elif (psw[0]['password'] != password):
                ppopup = tk.Toplevel()
                ppopup.title("Caution")
                ppopup.geometry("250x250")
                pic = Image.open('ad.png')
                ren = ImageTk.PhotoImage(pic)
                w1 = tk.Label(ppopup, image=ren)
                w1.image = ren
                w1.pack()
                inv = tk.Label(ppopup, text="INVALID PASSWORD", font=F_FONT)
                inv.pack(side=tk.TOP)
            elif (chance == 0):
                hen.append(lid)
                controller.show_frame(reg)

        def aorder():  #function to show the allotment order in a pop up window
            popup1 = tk.Tk()
            popup1.title("allotment order")
            popup1.geometry("300x150")
            sb = tk.Scrollbar(master=popup1)
            sb.pack(side=tk.RIGHT, fill=tk.Y)
            listbox = tk.Listbox(master=popup1)
            listbox.pack(side=tk.TOP)
            cur.execute(
                "select s.studentID,a.cgpa,a.year from student s,ainfo a where s.studentID=a.studentID and s.roomID is null;"
            )
            ord = cur.fetchall()
            listbox.insert(tk.END, ('RegnNo', '|', 'Year', '|', 'CGPA'))
            for i in range(len(ord)):
                listbox.insert(tk.END, (ord[i]['studentID'], '-',
                                        ord[i]['year'], '-', ord[i]['cgpa']))
            listbox.config(yscrollcommand=sb.set)
            sb.config(command=listbox.yview)

        tk.Frame.__init__(self, parent)
        photo = tk.PhotoImage(file="vhm.png")
        w = tk.Label(self, image=photo)
        w.image = photo
        w.pack()
        label = tk.Label(self, text="LOGIN PAGE", font=F_FONT)
        label.pack(pady=10, padx=10)
        login = tk.Label(self, text="Reg No", font=F_FONT)
        lo_entry = tk.Entry(self, textvariable=loginid, width=10)
        pas = tk.Label(self, text="Password", font=F_FONT)
        pas_entry = tk.Entry(self, show='*', textvariable=pid)
        login.pack(side=tk.LEFT)
        lo_entry.pack(side=tk.LEFT)
        pas.pack(side=tk.LEFT)
        pas_entry.pack(side=tk.LEFT)
        logbutton = ttk.Button(
            self,
            text="Login",
            command=lambda: loginfunc(loginid.get(), pid.get()))
        logbutton.pack(pady=20, padx=20, side=tk.LEFT)
        rdbutton = ttk.Button(self,
                              text="Room Details",
                              command=lambda: controller.show_frame(rdetails))
        rdbutton.pack(pady=20, padx=20)
        button = ttk.Checkbutton(self,
                                 text="Allotment Order",
                                 command=lambda: aorder())
        button.pack(pady=20, padx=20)
コード例 #14
0
    def __init__(self, parent, controller):
        rno = IntVar()

        def availa(blo, ty, si):  #func to show the available rooms
            blo = blo.upper()
            ty = ty.upper()
            if ty == 'AC':
                ty = 'A'
            elif ty == 'NON AC':
                ty = 'N'
            cur.execute(
                "select rno from room where block='%s' and Type='%s' and beds=%d and taken=0"
                % (blo, ty, si))
            res = cur.fetchall()
            l = tk.Label(self,
                         text="The Following rooms are available",
                         font=F_FONT)
            l.grid()
            tr = ''
            for i in range(len(res)):
                tr = tr + '\n' + str(res[i]['rno'])
            l1 = tk.Label(self, text=tr, font=F_FONT)
            l1.grid(row=18)
            cf = tk.PhotoImage(file='cb.png')
            cb = tk.Button(self,
                           image=cf,
                           command=lambda:
                           (l.grid_forget(), l1.grid_forget(), rb.grid_forget(
                           ), cb.grid_forget(), rs()))
            cb.image = cf
            cb.grid(row=30, column=0, sticky='N', padx=10, pady=10)
            rf = tk.PhotoImage(file='ref.png')
            rb = tk.Button(self,
                           image=rf,
                           command=lambda:
                           (l.grid_forget(), l1.grid_forget(), rb.grid_forget(
                           ), cb.grid_forget()))
            rb.image = rf
            rb.grid(row=32, column=0, sticky='N', padx=10, pady=10)

        def rs():
            r1 = tk.Label(self,
                          text='enter the selected room number',
                          font=F_FONT)
            r1.grid(row=24)
            r2 = tk.Label(
                self,
                text=
                'Disclaimer:\nRoom number once selected cannot be changed.',
                font=S_FONT)
            r2.grid(row=25)
            r_ent = tk.Entry(self, textvariable=rno)
            r_ent.grid(row=26)
            cf = tk.PhotoImage(file='cb.png')
            cb = tk.Button(self,
                           image=cf,
                           command=lambda:
                           (r1.grid_forget(), r2.grid_forget(),
                            r_ent.grid_forget(), cb.grid_forget(), fin()))
            cb.image = cf
            cb.grid(row=30, sticky='S', padx=10, pady=10)

        def fin():

            entry = tk.Tk()
            entry.title("Enter Roommates")
            entry.geometry('900x300')
            cur.execute(
                "select roomID,beds from room where rno=%d and block='%s'" %
                (rno.get(), blok.get()))
            res = cur.fetchall()

            def com():
                global hen
                for j in range(0, res[0]['beds'] - 1):
                    hen.append(ss[j].get())
                for k in range(0, res[0]['beds']):
                    cur.execute(
                        "update student set roomID=%d where studentID='%s'" %
                        (res[0]['roomID'], hen[k]))
                    conn.commit()
                cur.execute("update room set taken=1 where roomID=%d" %
                            res[0]['roomID'])
                conn.commit()
                controller.show_frame(success)
                entry.destroy()

            if (res[0]['beds'] == 1):
                s = tk.Label(entry,
                             text='This is a One bed Room and no roommates')
                s.pack()
                r = tk.Button(entry, text="Continue", command=lambda: com())
                r.pack()
            else:
                ss = []
                s = tk.Label(entry, text='enter details of roommates')
                s.pack()
                for i in range(0, res[0]['beds'] - 1):
                    e = tk.Entry(entry)
                    e.pack(padx=7, pady=7)
                    ss.append(e)
                r = tk.Button(entry, text="Register", command=lambda: com())
                r.pack()

        t1 = StringVar()
        blok = StringVar()
        capacity = IntVar()
        tk.Frame.__init__(self, parent)
        w = tk.Label(self, text="ROOM ALLOTMENT", font=F_FONT)
        w.grid(row=1, sticky='N', padx=250, pady=10)
        block = tk.Label(self, text="Block:", fg="#383239", bg="#a1dbcd")
        b_ent = tk.Entry(self, textvariable=blok)
        typ = tk.Label(self, text="Type:", fg="#383239", bg="#a1dbcd")
        t_ent = tk.Entry(self, textvariable=t1)
        size = tk.Label(self, text="Beds:", fg="#383239", bg="#a1dbcd")
        s_ent = tk.Entry(self, textvariable=capacity)
        block.grid(row=4, sticky='N', padx=10, pady=10)
        b_ent.grid(row=6, sticky='N', padx=10, pady=10)
        typ.grid(row=8, sticky='N', padx=10, pady=10)
        t_ent.grid(row=10, sticky='N', padx=10, pady=10)
        size.grid(row=12, sticky='N', padx=10, pady=10)
        s_ent.grid(row=14)
        avail = ttk.Button(
            self,
            text="Check Availability",
            command=lambda: availa(blok.get(), t1.get(), capacity.get()))
        avail.grid(row=16, sticky='N', padx=10, pady=10)
コード例 #15
0
        WritetoCSV(data)  #เรียกฟังชั่นการบันทึกข้อมูล

        #reset ตัวแปร
        v_expense.set('')
        v_price.set('')
        #ทำให้ cursor วิ่งไปหาช่องกรอกตัวแรก
        E1.focus()
        update_table()  #อัพเดตตารางทุกครั้งที่มีการเพิ่มรายการใหม่
        CountExpense()
        print('บันทึกรายการ...', dt, exp, "%.2f" % pc)


E2.bind('<Return>', SaveExpense)  #หากใช้ bind ต้องใส่ event=None ในฟังชั่นด้วย

# B1 คือปุ่มสำหรับกดบันทึก
B1 = ttk.Button(T1, text='บันทึก', command=SaveExpense)
B1.pack(padx=5, pady=5)

#########TABLE###########

F2 = Frame(T1)  # F1 คือ เฟรม (white board ติดผนัง)
F2.pack(padx=5, pady=5)

# TAB 2 Treeview Style -----------------------------------------------------------------------------------------
style = ttk.Style()
style.configure("Treeview.Heading",
                font=('Tahoma', 10, 'bold'),
                foreground="blue",
                background='yellow')
style.configure("Treeview", font=('Tahoma', 10), rowheight=20)
style.layout("Treeview", [('mystyle.Treeview.treearea', {
コード例 #16
0
    t = 3
    def countdown(num): #function to provide countdown effect
        start_var.set(num)
        if num >=1:
            num -= 1
            root.after(1000,lambda: countdown(num)) #call itself again until countdown reaches 0
        else:
            time.sleep(random.randint(2,6))
            start_var.set("GO!")
            global start_time
            start_time = time.time()
    countdown(t)

start_var = StringVar()

ttk.Button(content, text="Start", command=start, width=5).grid(column=1, row=1, sticky=W, padx= 30)
ttk.Label(content, text="Click on Go!").grid(column=2, row=1, sticky=S)
ttk.Button(content, text="Go", command=click, width=5).grid(column=2, row=2, sticky=(N,S))
ttk.Label(content, text="Result is: ").grid(column=3, row=2, sticky=S)
ttk.Label(content, textvariable=start_var).grid(column=1, row=2, sticky=(N,S))
ttk.Label(content, textvariable=result).grid(column=3, row=4, sticky=(N,S))

root.columnconfigure(0, weight=3)
root.rowconfigure(0, weight=3)
content.columnconfigure(1, weight=3, minsize=100)
content.columnconfigure(2, weight=0, minsize=100)
content.columnconfigure(3, weight=3, minsize=100)
content.rowconfigure(1, weight=3, minsize=100)
content.rowconfigure(2, weight=3, minsize=100)
content.rowconfigure(3, weight=3, minsize=100)
コード例 #17
0
ファイル: tab_fetch_files.py プロジェクト: ethoeng/bfit
    def __init__(self, fetch_data_tab, bfit):

        # get logger
        self.logger = logging.getLogger(logger_name)
        self.logger.debug('Initializing')

        # initialize
        self.bfit = bfit
        self.data_lines = {}
        self.data_lines_old = {}
        self.fit_input_tabs = {}
        self.check_rebin = IntVar()
        self.check_bin_remove = StringVar()
        self.check_state = BooleanVar()
        self.fetch_data_tab = fetch_data_tab

        # Frame for specifying files -----------------------------------------
        fet_entry_frame = ttk.Labelframe(fetch_data_tab, text='Specify Files')
        self.year = IntVar()
        self.run = StringVar()

        self.year.set(self.bfit.get_latest_year())

        entry_year = Spinbox(fet_entry_frame,
                             textvariable=self.year,
                             width=5,
                             from_=2000,
                             to=datetime.datetime.today().year)
        entry_run = ttk.Entry(fet_entry_frame, textvariable=self.run, width=85)
        entry_run.insert(0, self.run_number_starter_line)
        entry_fn = partial(on_entry_click,text=self.run_number_starter_line,\
                            entry=entry_run)
        on_focusout_fn = partial(on_focusout,text=self.run_number_starter_line,\
                            entry=entry_run)
        entry_run.bind('<FocusIn>', entry_fn)
        entry_run.bind('<FocusOut>', on_focusout_fn)
        entry_run.config(foreground=colors.entry_grey)

        # fetch button
        fetch = ttk.Button(fet_entry_frame,
                           text='Fetch',
                           command=self.get_data)

        # grid and labels
        fet_entry_frame.grid(column=0,
                             row=0,
                             sticky=(N, W, E),
                             columnspan=2,
                             padx=5,
                             pady=5)
        ttk.Label(fet_entry_frame, text="Year:").grid(column=0,
                                                      row=0,
                                                      sticky=W)
        entry_year.grid(column=1, row=0, sticky=(W))
        ttk.Label(fet_entry_frame, text="Run Number:").grid(column=2,
                                                            row=0,
                                                            sticky=W)
        entry_run.grid(column=3, row=0, sticky=W)
        fetch.grid(column=4, row=0, sticky=E)

        # padding
        for child in fet_entry_frame.winfo_children():
            child.grid_configure(padx=5, pady=5)

        # Frame for run mode -------------------------------------------------
        runmode_label_frame = ttk.Labelframe(fetch_data_tab,pad=(10,5,10,5),\
                text='Run Mode',)

        self.runmode_label = ttk.Label(runmode_label_frame,
                                       text="",
                                       justify=CENTER)

        # Scrolling frame to hold datalines
        yscrollbar = ttk.Scrollbar(fetch_data_tab, orient=VERTICAL)
        self.data_canvas = Canvas(
            fetch_data_tab,
            bd=0,  # make a canvas for scrolling
            yscrollcommand=yscrollbar.set,  # scroll command receive
            scrollregion=(0, 0, 5000, 5000),
            confine=True)  # default size
        yscrollbar.config(
            command=self.data_canvas.yview)  # scroll command send
        dataline_frame = ttk.Frame(self.data_canvas, pad=5)  # holds

        self.canvas_frame_id = self.data_canvas.create_window(
            (0, 0),  # make window which can scroll
            window=dataline_frame,
            anchor='nw')
        dataline_frame.bind(
            "<Configure>",
            self.config_canvas)  # bind resize to alter scrollable region
        self.data_canvas.bind(
            "<Configure>", self.config_dataline_frame
        )  # bind resize to change size of contained frame

        # Frame to hold everything on the right ------------------------------
        bigright_frame = ttk.Frame(fetch_data_tab, pad=5)

        # Frame for group set options ----------------------------------------
        right_frame = ttk.Labelframe(bigright_frame,\
                text='Operations on Checked Items',pad=30)

        check_remove = ttk.Button(right_frame,text='Remove',\
                command=self.remove_all,pad=5)
        check_draw = ttk.Button(right_frame,text='Draw',\
                command=lambda:self.draw_all('data'),pad=5)

        check_rebin_label = ttk.Label(right_frame, text="SLR Rebin:", pad=5)
        check_rebin_box = Spinbox(right_frame,from_=1,to=100,width=3,\
                textvariable=self.check_rebin,
                command=self.set_all)
        check_bin_remove_entry = ttk.Entry(right_frame,\
                textvariable=self.check_bin_remove,width=20)

        check_all_box = ttk.Checkbutton(right_frame,
                                        text='Force Check State',
                                        variable=self.check_state,
                                        onvalue=True,
                                        offvalue=False,
                                        pad=5,
                                        command=self.check_all)
        self.check_state.set(True)

        right_checkbox_frame = ttk.Frame(right_frame)

        self.check_state_data = BooleanVar()
        check_data_box = ttk.Checkbutton(right_checkbox_frame,
                                         text='Data',
                                         variable=self.check_state_data,
                                         onvalue=True,
                                         offvalue=False,
                                         pad=5,
                                         command=self.check_all_data)
        self.check_state_data.set(True)

        self.check_state_fit = BooleanVar()
        check_fit_box = ttk.Checkbutton(right_checkbox_frame,
                                        text='Fit',
                                        variable=self.check_state_fit,
                                        onvalue=True,
                                        offvalue=False,
                                        pad=5,
                                        command=self.check_all_fit)

        self.check_state_res = BooleanVar()
        check_res_box = ttk.Checkbutton(right_checkbox_frame,
                                        text='Res',
                                        variable=self.check_state_res,
                                        onvalue=True,
                                        offvalue=False,
                                        pad=5,
                                        command=self.check_all_res)

        check_toggle_button = ttk.Button(right_frame,\
                text='Toggle All Check States',command=self.toggle_all,pad=5)

        # add grey to check_bin_remove_entry
        check_bin_remove_entry.insert(0, self.bin_remove_starter_line)

        check_entry_fn = partial(on_entry_click,\
                text=self.bin_remove_starter_line,\
                entry=check_bin_remove_entry)

        check_on_focusout_fn = partial(on_focusout,\
                text=self.bin_remove_starter_line,\
                entry=check_bin_remove_entry)

        check_bin_remove_entry.bind('<FocusIn>', check_entry_fn)
        check_bin_remove_entry.bind('<FocusOut>', check_on_focusout_fn)
        check_bin_remove_entry.config(foreground=colors.entry_grey)

        # grid
        runmode_label_frame.grid(column=2,
                                 row=0,
                                 sticky=(N, W, E, S),
                                 pady=5,
                                 padx=5)
        self.runmode_label.grid(column=0, row=0, sticky=(N, W, E))

        bigright_frame.grid(column=2, row=1, sticky=(N, E))

        self.data_canvas.grid(column=0,
                              row=1,
                              sticky=(E, W, S, N),
                              padx=5,
                              pady=5)
        yscrollbar.grid(column=1, row=1, sticky=(W, S, N), pady=5)

        check_data_box.grid(column=0, row=0, sticky=(N))
        check_fit_box.grid(column=1, row=0, sticky=(N))
        check_res_box.grid(column=2, row=0, sticky=(N))

        right_frame.grid(column=0, row=0, sticky=(N, E, W))
        r = 0
        check_all_box.grid(column=0, row=r, sticky=(N), columnspan=2)
        r += 1
        right_checkbox_frame.grid(column=0, row=r, sticky=(N), columnspan=2)
        r += 1
        check_toggle_button.grid(column=0,
                                 row=r,
                                 sticky=(N, E, W),
                                 columnspan=2,
                                 pady=1,
                                 padx=5)
        r += 1
        check_draw.grid(column=0, row=r, sticky=(N, W, E), pady=5, padx=5)
        check_remove.grid(column=1, row=r, sticky=(N, E, W), pady=5, padx=5)
        r += 1
        check_rebin_label.grid(column=0, row=r)
        check_rebin_box.grid(column=1, row=r)
        r += 1
        check_bin_remove_entry.grid(column=0, row=r, sticky=(N), columnspan=2)
        r += 1
        bigright_frame.grid(rowspan=2, sticky=(N, E, W))

        check_rebin_box.grid_configure(padx=5, pady=5, sticky=(E, W))
        check_rebin_label.grid_configure(padx=5, pady=5, sticky=(E, W))

        # resizing
        fetch_data_tab.grid_columnconfigure(0, weight=1)  # main area
        fetch_data_tab.grid_rowconfigure(1, weight=1)  # main area

        for i in range(3):
            if i % 2 == 0: fet_entry_frame.grid_columnconfigure(i, weight=2)
        fet_entry_frame.grid_columnconfigure(3, weight=1)

        self.data_canvas.grid_columnconfigure(0, weight=1)  # fetch frame
        self.data_canvas.grid_rowconfigure(0, weight=1)

        # asymmetry calculation
        style_frame = ttk.Labelframe(bigright_frame,text='Asymmetry Calculation',\
                pad=5)
        self.asym_type = StringVar()
        self.asym_type.set('')
        self.entry_asym_type = ttk.Combobox(style_frame,\
                textvariable=self.asym_type,state='readonly',\
                width=20)
        self.entry_asym_type['values'] = ()

        style_frame.grid(column=0, row=1, sticky=(W, N, E))
        style_frame.grid_columnconfigure(0, weight=1)
        self.entry_asym_type.grid(column=0, row=0, sticky=(N, E, W), padx=10)

        # passing
        self.entry_run = entry_run
        self.entry_year = entry_year
        self.check_rebin_box = check_rebin_box
        self.check_bin_remove_entry = check_bin_remove_entry
        self.check_all_box = check_all_box
        self.dataline_frame = dataline_frame

        self.logger.debug('Initialization success.')
コード例 #18
0
root.title(appName)
root.iconbitmap(r'data/img/app.ico')

# Root Window - StatusBar, LeftFrame, RightFrame
# LeftFrame - The listbox (playlist)
# RightFrame - TopFrame,MiddleFrame and the BottomFrame

leftframe = Frame(root)
leftframe.pack(side=LEFT, padx=30, pady=30)
leftframe.configure(background=bgColor)

playlistbox = Listbox(leftframe)
playlistbox.pack()
playlistbox.configure(background='#636363', borderwidth=2)

addBtn = ttk.Button(leftframe, text="+ Add", command=browse_file)
addBtn.pack(side=LEFT)


def del_song():
    selected_song = playlistbox.curselection()
    selected_song = int(selected_song[0])
    playlistbox.delete(selected_song)
    playlist.pop(selected_song)


delBtn = ttk.Button(leftframe, text="- Del", command=del_song)
delBtn.pack(side=LEFT)

rightframe = Frame(root)
rightframe.pack(pady=30)
コード例 #19
0
ファイル: appwindows.py プロジェクト: alkgrove/partlocater
    def __init__(self, parent=None, app_window=None):
        self.lastValue = None
        self.category_option = StringVar("")
        self.column_id = ['ProductDescription', 'ManufacturerName',
                          'ManufacturerPartNumber', 'DigiKeyPartNumber', 'Category']
        Frame.__init__(self, parent)
        self.pack()
        self.parent = parent
        self.app_window = app_window
        self.selectedField = None

        self.parent.title("Partlocater - Advanced Database Search")
        self.parent.iconbitmap(self.FAVICON)
        self.menubar = Frame(self, background='white')
        
        self.menubar.pack(side=TOP, fill=X, expand=YES);
        self.win_frame = Frame(self)
        self.win_frame.pack(side=TOP, fill=BOTH, expand=YES)
        self.editbutton = Menubutton(self.menubar, text='Edit', background='grey98')
        self.editbutton.pack(side=LEFT, fill=X)
        self.editmenu = Menu(self.editbutton, tearoff=0)
        self.editbutton.config(menu=self.editmenu)
        self.copySourcesMenu = Menu(self.editbutton, tearoff=0)
        self.editmenu.add_cascade(label='Copy', menu=self.copySourcesMenu)
        self.copySourcesMenu.add_command(label='Part Number', state=DISABLED, command=self.on_copy_partnumber)
        self.partnumber_index = 0
        self.copySourcesMenu.add_command(label='Selected Parameter', state=DISABLED, command=self.on_copy_parameters)
        self.selectedParameter_index = 1
        self.copySourcesMenu.add_command(label='Selected Part All Parameters', state=DISABLED, command=self.on_copy_all_parameters)
        self.allParameters_index = 2
        self.editmenu.add_command(label='Delete Part', state=DISABLED, command=self.on_delete)
        self.delete_part_index = 1
        
        self.searchLF = LabelFrame(self.win_frame, text="Search")
        self.searchLF.pack(side=LEFT, fill=X, expand=YES, pady=4, padx=6)
        self.searchLeftF = Frame(self.searchLF)
        self.searchLeftF.pack(side=LEFT, anchor=W)
        self.searchRightF = Frame(self.searchLF)
        self.searchRightF.pack(side=LEFT, anchor=N)
        self.searchLabelWidth = 20
        self.catF = Frame(self.searchLeftF)
        self.catF.pack(side=TOP, anchor=W)
        self.catL = Label(self.catF, text='Category', width=self.searchLabelWidth, anchor=W, justify=LEFT)
        self.catL.pack(side=LEFT, fill=X, expand=YES)
        self.cat = StringVar()
        self.catE = Entry(self.catF, textvariable=self.cat, width=50, state=DISABLED)
        self.catE.config(disabledbackground=self.catE.cget("bg"))
        self.catE.config(disabledforeground=self.catE.cget("fg"))
        self.catE.pack(side=LEFT, fill=X, expand=YES, pady=4)
        self.category_option = StringVar()
        self.cat.set("All")
        option_list = ['All', 'All'] + Config().tables
        self.catM = OptionMenu(self.searchRightF, self.category_option, *option_list, command=self.on_category)
        self.catM.pack(side=TOP, anchor=N, fill=X, expand=YES)

        self.manF = Frame(self.searchLeftF)
        self.manF.pack(side=TOP, anchor=W)
        self.manL = Label(self.manF, text='ManufacturerName', width=self.searchLabelWidth, anchor=W, justify=LEFT)
        self.manL.pack(side=LEFT, fill=X, expand=YES, pady=4)
        self.man = StringVar()
        self.manE = Entry(self.manF, width=50, textvariable=self.man)
        self.manE.pack(side=LEFT, fill=X, expand=YES, pady=4)

        self.mpnF = Frame(self.searchLeftF)
        self.mpnF.pack(side=TOP, anchor=W)
        self.mpnL = Label(self.mpnF, text='ManufacturerPartNumber', width=self.searchLabelWidth, anchor=W, justify=LEFT)
        self.mpnL.pack(side=LEFT, fill=X, expand=YES, pady=4)
        self.mpn = StringVar()
        self.mpnE = Entry(self.mpnF, width=50, textvariable=self.mpn)
        self.mpnE.pack(side=LEFT, fill=X, expand=YES, pady=4)

        self.spnF = Frame(self.searchLeftF)
        self.spnF.pack(side=TOP, anchor=W)
        self.spnL = Label(self.spnF, text='DigiKeyPartNumber', width=self.searchLabelWidth, anchor=W, justify=LEFT)
        self.spnL.pack(side=LEFT, fill=X, expand=YES, pady=4)
        self.spn = StringVar()
        self.spnE = Entry(self.spnF, width=50, textvariable=self.spn)
        self.spnE.pack(side=LEFT, fill=X, expand=YES, pady=4)

        self.descF = Frame(self.searchLeftF)
        self.descF.pack(side=TOP, anchor=W)
        self.descL = Label(self.descF, text='ProductDescription', width=self.searchLabelWidth, anchor=W, justify=LEFT)
        self.descL.pack(side=LEFT, fill=X, expand=YES, pady=4)
        self.desc = StringVar()
        self.descE = Entry(self.descF, width=50, textvariable=self.desc)
        self.descE.pack(side=LEFT, fill=X, expand=YES, pady=4)
        self.descE.focus_force()

        self.findF = Frame(self.searchLeftF)
        self.findF.pack(side=TOP, anchor=E)
        self.findB = ttk.Button(self.findF, text="Find", width=12, command=lambda event=None: self.do_find(event))
        self.findB.pack(side=LEFT, pady=4)
        self.clearB = ttk.Button(self.findF, text="Clear", width=6, command=self.on_clear_search)
        self.clearB.pack(side=LEFT, pady=4)

        self.partsLF = LabelFrame(self, text="Found Components")
        self.partsLF.pack(side=TOP, fill=X, expand=YES, pady=4, padx=4)
        self.partsF = Frame(self.partsLF)
        self.partsF.pack(side=TOP, pady=4, padx=4)
        # change treeview for search here
        self.partsTV = Treeview(self.partsF, selectmode=BROWSE, show='tree headings', columns=self.column_id)

        self.partsTV.bind('<Double-Button-1>', self.on_edit_item)
        self.partsTV.bind('<<TreeviewSelect>>', self.fieldChanged)
        self.partsTV.bind('<Escape>', self.clearSelection)
        self.partsTV.bind('<MouseWheel>', self.mousewheel)
        self.partsTV.bind('<Button-4>', self.mousewheel)
        self.partsTV.bind('<Button-5>', self.mousewheel)
        vcmd = (self.register(self.validateEntry), '%P')
        self.editfield = ttk.Entry(self.partsTV, validate='key', validatecommand=vcmd)
        self.editfield.bind('<Return>', self.updateField)
        self.editfield.bind('<Escape>', self.clearSelection)

        
        self.partsTV.bind('<Control-c>', self.on_copy_element)
        self.partsTV.column("#0", minwidth=0, width=18, stretch=NO)
        for t in self.column_id:
            self.partsTV.heading(t, text=Config().parameter[t])
        self.partsTV.column('Category', width=60)
        self.scrollbar = Scrollbar(self.partsF, orient='vertical', command=self.partsTV.yview)
        self.scrollbar.pack(side=RIGHT, fill=Y, expand=YES, anchor=E)
        self.partsTV.configure(yscroll=self.scrollbar.set)
        self.scrollbar.config(command=self.yview)
        
        self.partsTV.pack(side=TOP, anchor=W, fill=X, expand=YES)
        self.partsTV.delete(*self.partsTV.get_children())
    
        self.statusLF = LabelFrame(self, text="Status")
        self.statusLF.pack(side=BOTTOM, fill=X, expand=YES, pady=4, padx=6)
        self.statusF = Frame(self.statusLF)
        self.statusF.pack(side=TOP, fill=X, expand=YES, padx=6)
        self.status = self.StatusBar(self.statusF, self)
コード例 #20
0
    def create_widgets(self):    
        tabControl = ttk.Notebook(self.win)          # Create Tab Control
        
        tab1 = ttk.Frame(tabControl)            # Create a tab 
        tabControl.add(tab1, text='Tab 1')      # Add the tab
        tab2 = ttk.Frame(tabControl)            # Add a second tab
        tabControl.add(tab2, text='Tab 2')      # Make second tab visible
        
        tabControl.pack(expand=1, fill="both")  # Pack to make visible
        
        # LabelFrame using tab1 as the parent
        mighty = ttk.LabelFrame(tab1, text=' Mighty Python ')
        mighty.grid(column=0, row=0, padx=8, pady=4)
        
        # Modify adding a Label using mighty as the parent instead of win
        a_label = ttk.Label(mighty, text="Enter a name:")
        a_label.grid(column=0, row=0, sticky='W')
     
        # Adding a Textbox Entry widget
        self.name = tk.StringVar()
        self.name_entered = ttk.Entry(mighty, width=24, textvariable=self.name)
        self.name_entered.grid(column=0, row=1, sticky='W')               
        
        # Adding a Button
        self.action = ttk.Button(mighty, text="Click Me!", command=self.click_me)   
        self.action.grid(column=2, row=1)                                
        
        ttk.Label(mighty, text="Choose a number:").grid(column=1, row=0)
        number = tk.StringVar()
        self.number_chosen = ttk.Combobox(mighty, width=14, textvariable=number, state='readonly')
        self.number_chosen['values'] = (1, 2, 4, 42, 100)
        self.number_chosen.grid(column=1, row=1)
        self.number_chosen.current(0)
        
        # Adding a Spinbox widget
        self.spin = Spinbox(mighty, values=(1, 2, 4, 42, 100), width=5, bd=9, command=self._spin) # using range
        self.spin.grid(column=0, row=2, sticky='W') # align left
        
        # Using a scrolled Text control    
        scrol_w = 40; scrol_h = 10                  # increase sizes
        self.scrol = scrolledtext.ScrolledText(mighty, width=scrol_w, height=scrol_h, wrap=tk.WORD)
        self.scrol.grid(column=0, row=3, sticky='WE', columnspan=3)                    
        
        for child in mighty.winfo_children():       # add spacing to align widgets within tabs
            child.grid_configure(padx=4, pady=2) 
         
        #=====================================================================================
        # Tab Control 2 ----------------------------------------------------------------------
        self.mighty2 = ttk.LabelFrame(tab2, text=' The Snake ')
        self.mighty2.grid(column=0, row=0, padx=8, pady=4)
        
        # Creating three checkbuttons
        chVarDis = tk.IntVar()
        check1 = tk.Checkbutton(self.mighty2, text="Disabled", variable=chVarDis, state='disabled')
        check1.select()
        check1.grid(column=0, row=0, sticky=tk.W)                   
        
        chVarUn = tk.IntVar()
        check2 = tk.Checkbutton(self.mighty2, text="UnChecked", variable=chVarUn)
        check2.deselect()
        check2.grid(column=1, row=0, sticky=tk.W)                   
        
        chVarEn = tk.IntVar()
        check3 = tk.Checkbutton(self.mighty2, text="Enabled", variable=chVarEn)
        check3.deselect()
        check3.grid(column=2, row=0, sticky=tk.W)                     
        
        # trace the state of the two checkbuttons
        chVarUn.trace('w', lambda unused0, unused1, unused2 : self.checkCallback())    
        chVarEn.trace('w', lambda unused0, unused1, unused2 : self.checkCallback())   
        
        
        # First, we change our Radiobutton global variables into a list
        colors = ["Blue", "Gold", "Red"]   
        
        # create three Radiobuttons using one variable
        self.radVar = tk.IntVar()
        
        # Next we are selecting a non-existing index value for radVar
        self.radVar.set(99)                                 
         
        # Now we are creating all three Radiobutton widgets within one loop
        for col in range(3):                             
            curRad = tk.Radiobutton(self.mighty2, text=colors[col], variable=self.radVar, 
                                    value=col, command=self.radCall)          
            curRad.grid(column=col, row=1, sticky=tk.W)             # row=6
            # And now adding tooltips
            ToolTip(curRad, 'This is a Radiobutton control')
                
        # Add a Progressbar to Tab 2
        self.progress_bar = ttk.Progressbar(tab2, orient='horizontal', length=286, mode='determinate')
        self.progress_bar.grid(column=0, row=3, pady=2)         
             
        # Create a container to hold buttons
        buttons_frame = ttk.LabelFrame(self.mighty2, text=' ProgressBar ')
        buttons_frame.grid(column=0, row=2, sticky='W', columnspan=2)        
        
        # Add Buttons for Progressbar commands
        ttk.Button(buttons_frame, text=" Run Progressbar   ", command=self.run_progressbar).grid(column=0, row=0, sticky='W')  
        ttk.Button(buttons_frame, text=" Start Progressbar  ", command=self.start_progressbar).grid(column=0, row=1, sticky='W')  
        ttk.Button(buttons_frame, text=" Stop immediately ", command=self.stop_progressbar).grid(column=0, row=2, sticky='W')  
        ttk.Button(buttons_frame, text=" Stop after second ", command=self.progressbar_stop_after).grid(column=0, row=3, sticky='W')  
         
        for child in buttons_frame.winfo_children():  
            child.grid_configure(padx=2, pady=2) 
         
        for child in self.mighty2.winfo_children():  
            child.grid_configure(padx=8, pady=2) 
            
        # Creating a Menu Bar
        menu_bar = Menu(self.win)
        self.win.config(menu=menu_bar)
        
        # Add menu items
        file_menu = Menu(menu_bar, tearoff=0)
        file_menu.add_command(label="New")
        file_menu.add_separator()
        file_menu.add_command(label="Exit", command=self._quit)
        menu_bar.add_cascade(label="File", menu=file_menu)
        
        # Display a Message Box
        def _msgBox():
            msg.showinfo('Python Message Info Box', 'A Python GUI created using tkinter:\nThe year is 2019.')  
            
        # Add another Menu to the Menu Bar and an item
        help_menu = Menu(menu_bar, tearoff=0)
        help_menu.add_command(label="About", command=_msgBox)   # display messagebox when clicked
        menu_bar.add_cascade(label="Help", menu=help_menu)
        
        # Change the main windows icon
        self.win.iconbitmap('pyc.ico')
        
        # It is not necessary to create a tk.StringVar() 
        # strData = tk.StringVar()
        strData = self.spin.get()

        # call function
        self.usingGlobal()
        
        self.name_entered.focus()     

        # Add Tooltips -----------------------------------------------------
        # Add a Tooltip to the Spinbox
        ToolTip(self.spin, 'This is a Spinbox control')   
                
        # Add Tooltips to more widgets
        ToolTip(self.name_entered, 'This is an Entry control')  
        ToolTip(self.action, 'This is a Button control')                      
        ToolTip(self.scrol, 'This is a ScrolledText control')
コード例 #21
0
font_box.current(font_tuple.index('Arial'))
font_box.grid(row=0, column=0, padx=5)

##size box
size_var = tk.IntVar()
font_size = ttk.Combobox(tool_bar,
                         width=14,
                         textvariable=size_var,
                         state='readonly')
font_size['values'] = tuple(range(8, 80, 2))
font_size.current(4)
font_size.grid(row=0, column=1, padx=5)

##bold button
bold_icon = tk.PhotoImage(file='icons2/bold.png')
bold_btn = ttk.Button(tool_bar, image=bold_icon)
bold_btn.grid(row=0, column=2, padx=5)

##italic button
italic_icon = tk.PhotoImage(file='icons2/italic.png')
italic_btn = ttk.Button(tool_bar, image=italic_icon)
italic_btn.grid(row=0, column=3, padx=5)

##underline button
underline_icon = tk.PhotoImage(file='icons2/underline.png')
underline_btn = ttk.Button(tool_bar, image=underline_icon)
underline_btn.grid(row=0, column=4, padx=5)

##font color button
font_icon = tk.PhotoImage(file='icons2/font_color.png')
font_color_btn = ttk.Button(tool_bar, image=font_icon)
コード例 #22
0
# Modified Button Click Function
def clickMe():
    action.configure(text='Hello\n ' + name.get())
    action.configure(state='disabled')  # Disable the Button Widget


# Changing our Label
ttk.Label(monty, text="输入文字:").grid(column=0, row=0, sticky='W')

# Adding a Textbox Entry widget
name = tk.StringVar()
nameEntered = ttk.Entry(monty, width=12, textvariable=name)
nameEntered.grid(column=0, row=1, sticky='W')

# Adding a Button
action = ttk.Button(monty, text="点击之后\n按钮失效", width=10, command=clickMe)
action.grid(column=2, row=1, rowspan=2, ipady=7)

ttk.Label(monty, text="请选择一本书:").grid(column=1, row=0, sticky='W')

# Adding a Combobox
book = tk.StringVar()
bookChosen = ttk.Combobox(monty, width=12, textvariable=book)
bookChosen['values'] = ('平凡的世界', '亲爱的安德烈', '看见', '白夜行')
bookChosen.grid(column=1, row=1)
bookChosen.current(0)  #设置初始显示值,值为元组['values']的下标
bookChosen.config(state='readonly')  #设为只读模式


# Spinbox callback
def _spin():
コード例 #23
0
# Set up a variable and option list for the account Combobox
account_names = ["Savings", "Phone", "Holiday"]
chosen_account = StringVar()
chosen_account.set(account_names[0])

# Create a Combobox to select the account
account_box = ttk.Combobox(root, textvariable=chosen_account, state="readonly")
account_box['values'] = account_names
account_box.grid(row=3, column=1, padx=10, pady=3)

# Create a label for the amount field and pack it into the GUI
amount_label = ttk.Label(root, text="Amount:")
amount_label.grid(row=5, column=0, padx=10, pady=3)

# Create a variable to store the amount
amount = DoubleVar()
amount.set("")

# Create an entry to type in amount
amount_entry = ttk.Entry(root, textvariable=amount)
amount_entry.grid(row=5, column=1, padx=10, pady=3)

# Create a submit button
submit_button = ttk.Button(root, text="Submit", command=update_balance)

submit_button.grid(row=6, column=0, columnspan=2, padx=10, pady=10)

# Run the mainloop
root.mainloop()
コード例 #24
0
ファイル: app.py プロジェクト: JHay0112/Draculas-Castle
    def gui(self, parent, height, width):

        #  Hold parent object
        self._parent = parent
        # + height and width
        self._height = height
        self._width = width

        # Add keystroke listeners
        self._parent.bind("w", self.move)
        self._parent.bind("s", self.move)
        self._parent.bind("a", self.move)
        self._parent.bind("d", self.move)

        # Initialise a new frame in the parent
        self._gui = tk.Frame(self._parent)
        self._gui.pack(fill=tk.BOTH)

        # Setup the map frame to show map in
        self._map_frame = tk.Frame(self._gui)
        self._map_frame.grid(row=0, column=0, rowspan=4, columnspan=4)
        # Setup the stat frame for the player
        self._player_stat_frame = tk.Frame(self._gui,
                                           height=Game.COLUMN,
                                           width=2 * Game.ROW)
        self._player_stat_frame.grid(row=0, column=4, rowspan=1, columnspan=2)
        # Setup the stat frame for the enemy
        self._enemy_stat_frame = tk.Frame(self._gui,
                                          height=Game.COLUMN,
                                          width=2 * Game.ROW)
        self._enemy_stat_frame.grid(row=2, column=4, rowspan=1, columnspan=2)
        # Setup the log frame
        self._log_frame = tk.Frame(self._gui,
                                   height=2 * Game.COLUMN,
                                   width=2 * Game.ROW)
        self._log_frame.grid(row=3, column=4, rowspan=4, columnspan=1)
        # Setup text log
        self._log = scrolledtext.ScrolledText(self._log_frame,
                                              state=tk.DISABLED,
                                              width=21,
                                              height=16,
                                              wrap=tk.WORD)
        self._log.pack(fill=tk.X)
        # Setup log control frame
        self._log_controls = tk.Frame(self._log_frame, height=20)
        self._log_controls.pack(fill=tk.X, pady=(2, 5))
        # Setup player inventory frame
        self._player_invent_frame = tk.Frame(self._gui,
                                             height=Game.COLUMN,
                                             width=2 * Game.ROW)
        self._player_invent_frame.grid(row=4, column=0, columnspan=2)
        # Setup room inventory frame
        self._room_invent_frame = tk.Frame(self._gui,
                                           height=Game.COLUMN,
                                           width=2 * Game.ROW)
        self._room_invent_frame.grid(row=4, column=2, columnspan=2)

        # Store current room
        self._current_room = self._player.room()
        # Set room use function to add item to player invent
        self._current_room.inventory().set_use_command(
            self._player.inventory().add_item)

        # Draw map
        self._current_room.gui(self._map_frame)

        # Setup player inventory
        self._player.inventory().gui(self._player_invent_frame)
        # Setup room inventory
        self._current_room.inventory().gui(self._room_invent_frame)

        # Setup player stat frame
        self._player.gui(self._player_stat_frame)

        # Setup control buttons
        self._attack = ttk.Button(self._log_controls,
                                  text="ATTACK",
                                  state=tk.DISABLED)
        self._attack.pack(fill=tk.X, side=tk.LEFT, expand=True)
        self._retreat = ttk.Button(self._log_controls,
                                   text="RETREAT",
                                   state=tk.DISABLED,
                                   command=self.retreat)
        self._retreat.pack(fill=tk.X, side=tk.LEFT, expand=True)

        # Withdraw parent window
        self._parent.withdraw()

        # Get player info
        # Setup window
        self._player_info_window = tk.Toplevel(self._parent, padx=10, pady=10)
        self._player_info_window.title("Character Creation")
        self._player_info_window.geometry("200x150+100+100")
        # Setup widgets
        # Set title
        tk.Label(self._player_info_window,
                 text="Character Creation",
                 anchor=tk.W).pack(fill=tk.X)
        # Name label
        tk.Label(self._player_info_window, text="Name:",
                 anchor=tk.W).pack(fill=tk.X)
        # Name input
        tk.Entry(self._player_info_window,
                 textvariable=self._player_name).pack(fill=tk.X)
        # Age label
        tk.Label(self._player_info_window, text="Age:",
                 anchor=tk.W).pack(fill=tk.X)
        # Age input
        tk.Entry(self._player_info_window,
                 textvariable=self._player_age).pack(fill=tk.X)
        # Set button
        ttk.Button(self._player_info_window,
                   text="Create Character",
                   command=self.update_player).pack(fill=tk.X, pady=(5, 0))
        # Focus
        self._player_info_window.focus_force()

        # Refresh the GUI
        self.gui_refresh()
コード例 #25
0
    return False


search_options = ttk.OptionMenu(root, link_or_name, 'Video Name', 'Video Name',
                                'Video Link')
search_options.grid(row=0, column=0, ipady=5, padx=9, pady=3)
search_options.config(width=11)

search = ttk.Entry(root, width=30, textvariable=user_search)
search.grid(row=0, column=1, ipady=5, padx=1, pady=3)
search.focus()
root.bind('<Return>', show_results)

ttk.Button(root, text='Search', width=16,
           command=lambda: show_results('')).grid(row=0,
                                                  column=2,
                                                  ipady=5,
                                                  padx=9,
                                                  pady=3)

format_options = ttk.OptionMenu(root, user_format_option, 'Select format...',
                                'webm', 'mp4', 'mkv', 'mp3', 'wav')
format_options.grid(row=0, column=3, ipady=5, padx=7, pady=3)
format_options.config(width=13)

ttk.Button(root,
           text='Downloads directory',
           width=19,
           command=browse_directory).grid(row=0,
                                          column=4,
                                          ipady=5,
                                          padx=9,
コード例 #26
0
check1 = IntVar()
check1.set(0)

#=========================Tab 1: Speed Mode=============================#
l_speed = tk.Label(tab1, text="Target speed")
l_cspeed = tk.Label(tab1, text="Current speed")
l_cspeedvalue = Label(tab1, textvariable=feedbackspeed)
l_cspeedunit = tk.Label(tab1, text="m/s")
l_pthrottle = tk.Label(tab1, text="Throttle position")
l_pthrottleunit = tk.Label(tab1, text="deg")
e_speed = tk.Entry(
    tab1,
    bd=5,
    width=40,
)
b_transmit = ttk.Button(tab1, text="transmit", command=ba_transmit1)
b_plus_speed1 = ttk.Button(tab1, text="+", command=ba_plus_speed1)
b_minus_speed1 = ttk.Button(tab1, text="-", command=ba_minus_speed1)
c_connection = ttk.Checkbutton(tab1, text="Connected", variable=check1)
stop1 = ttk.Button(tab1, text="STOP", command=stop1)

stop1.grid(row=6, column=3)
l_speed.grid(row=0, column=0, sticky='w')
e_speed.grid(row=0, column=1)
b_transmit.grid(row=0, column=2)
b_plus_speed1.grid(row=1, column=3)
b_minus_speed1.grid(row=1, column=2)
l_cspeed.grid(row=2, column=0, sticky='w')
l_cspeedvalue.grid(row=2, column=1)
l_cspeedunit.grid(row=2, column=2)
l_pthrottle.grid(row=3, column=0)
コード例 #27
0
ファイル: Archer.py プロジェクト: ZaneColeRiley/ArcherProject
    def __init__(self, parent, controller):
        Frame.__init__(self, parent)
        # Image
        self.image = ImageTk.PhotoImage(Image.open(os.path.join("Images", "Screen_image.jpg")))
        self.screen_image = Label(self, image=self.image)
        self.screen_image.pack()

        # Carriers
        self.carriers = {
            'att': '@mms.att.net',
            'tmobile': "@tmomail.net",
            'verizon': '@vtext.com',
            'sprint': '@page.nextel.com'}

        self.contacts = {
            'person': "number",
            'person': "number",
            'person': "number",
            'person': "number"
        }

        self.contacts_carrier = {
            "person": "carrier",
            "person": "carrier",
            "person": "carrier",
            "person": "carrier"
        }

        # Text Entry
        self.text_box = ttk.Entry(self, font=LARGE_FONT, width=120)
        self.text_box.place(x=0, y=777)

        # Number Entry
        self.number_entry = ttk.Entry(self, font=LARGE_FONT)
        self.number_entry.place(x=505, y=290)
        self.number_label = ttk.Label(self, text="Number: ")
        self.number_label.place(x=410, y=290)

        # Carrier Entry
        self.carrier_entry = ttk.Entry(self, font=LARGE_FONT)
        self.carrier_entry.place(x=505, y=340)
        self.carrier_label = ttk.Label(self, text="Phone Carrier: ")
        self.carrier_label.place(x=410, y=340)

        # Carrier Label
        self.att = ttk.Label(self, text="att " + self.carriers['att'], font=LARGE_FONT)
        self.tmobile = ttk.Label(self, text="tmobile " + self.carriers['tmobile'], font=LARGE_FONT)
        self.verizon = ttk.Label(self, text="verizon " + self.carriers['verizon'], font=LARGE_FONT)
        self.sprint = ttk.Label(self, text="sprint " + self.carriers['sprint'], font=LARGE_FONT)

        # Carrier Label Placements
        self.att.place(x=120, y=150)
        self.tmobile.place(x=120, y=220)
        self.verizon.place(x=120, y=290)
        self.sprint.place(x=120, y=360)

        # Send Button
        self.send_button = ttk.Button(self, text="Send Message", command=self.send_message, width=22)
        self.send_button.place(x=530, y=400)

        # back Button
        self.back = ttk.Button(self, text="Back to Admin", command=lambda: controller.show_frame(Admin), width=22)
        self.back.place(x=530, y=440)

        # Time and Date
        self.t = time.localtime()
        self.systemTime = time.strftime("%I:%M:%S %p", self.t)
        self.date = str(date.today())
コード例 #28
0
ファイル: tkreal.py プロジェクト: CSA-CDP/AdvProgramming2016
root = Tk()
root.title("Feet to Meters")

mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)

feet = StringVar()
meters = StringVar()

feet_entry = ttk.Entry(mainframe, width=50, textvariable=feet)
feet_entry.grid(column=2, row=1, sticky=(W, E))

ttk.Label(mainframe, textvariable=meters).grid(column=2, row=2, sticky=(W, E))
ttk.Button(mainframe, text="Calculate", command=calculate).grid(column=2,
                                                                row=3,
                                                                sticky=W)

ttk.Label(mainframe, text="feet").grid(column=1, row=1, sticky=W)
ttk.Label(mainframe, text="is equivalent to").grid(column=1, row=2, sticky=E)
ttk.Label(mainframe, text="meters").grid(column=3, row=2, sticky=W)

for child in mainframe.winfo_children():
    child.grid_configure(padx=5, pady=5)

feet_entry.focus()
root.bind('<Return>', calculate)

root.mainloop()
コード例 #29
0
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)

        label = tk.Label(self,
                         text="**Simple serial write app**",
                         fg='blue',
                         font=small_FONT)
        label.grid(row=0, column=0)

        # Create button1 for connect to serial
        label = tk.Label(self, text="Connect COM port:", font=small_FONT) \
                                                                 .grid(row=2, column=0)
        ttk.Button(self, text='Connect COM', command=self.button1_callback, width=20) \
                                                                .grid(row=2, column=2)

        # Create buttons for init
        ttk.Button(self, text='Full_reset', command=self.button7_callback, width=12) \
            .grid(row=3, column=3)

        # Create buttons for sending channels
        label = tk.Label(self, text="| WRITE to DAC channels |", font=small_FONT) \
                                                                 .grid(row=5, column=3)
        ttk.Button(self, text='Channel_A', command=self.button2_callback, width=12) \
                                                                .grid(row=6, column=1)
        ttk.Button(self, text='Channel_B', command=self.button3_callback, width=12) \
                                                                .grid(row=6, column=2)
        ttk.Button(self, text='Channel_C', command=self.button4_callback, width=12) \
                                                                .grid(row=6, column=3)
        ttk.Button(self, text='Channel_D', command=self.button5_callback, width=12) \
                                                                .grid(row=6, column=4)
        ttk.Button(self, text='BIAS', command=self.button6_callback, width=12) \
                                                                .grid(row=6, column=7)

        # Buttons for Filter clock and ENABLE
        self.button_fc = ttk.Button(self,
                                    text='Filter_cl_Disable',
                                    command=self.button8_callback,
                                    width=15)
        self.button_fc.grid(row=3, column=4)

        self.button_en = ttk.Button(self,
                                    text='Driver_Disable',
                                    command=self.button9_callback,
                                    width=15)
        self.button_en.grid(row=3, column=5)

        # Create User input box
        self.user_spinbox1 = ttk.Spinbox(self, from_=0, to=65536, width=10)
        self.user_spinbox1.grid(row=7, column=1)
        self.user_spinbox1.delete(0, 'end')
        self.user_spinbox1.insert(0, '1')  #Set default 1#
        # Create User input box
        self.user_spinbox2 = ttk.Spinbox(self, from_=0, to=65536, width=10)
        self.user_spinbox2.grid(row=7, column=2)
        self.user_spinbox2.delete(0, 'end')
        self.user_spinbox2.insert(0, '1')  #Set default 1#
        # Create User input box
        self.user_spinbox3 = ttk.Spinbox(self, from_=0, to=65536, width=10)
        self.user_spinbox3.grid(row=7, column=3)
        self.user_spinbox3.delete(0, 'end')
        self.user_spinbox3.insert(0, '1')  #Set default 1#
        # Create User input box
        self.user_spinbox4 = ttk.Spinbox(self, from_=0, to=65536, width=10)
        self.user_spinbox4.grid(row=7, column=4)
        self.user_spinbox4.delete(0, 'end')
        self.user_spinbox4.insert(0, '1')  #Set default 1#
        # Create User input box
        self.user_spinbox5 = ttk.Spinbox(self, from_=0, to=65536, width=10)
        self.user_spinbox5.grid(row=7, column=7)
        self.user_spinbox5.delete(0, 'end')
        self.user_spinbox5.insert(0, '32000')  #Set default 1#
        #
        # New buttons for X and Y
        ttk.Button(self, text='X_diff mV', command=self.X_callback, width=12) \
            .grid(row=9, column=3)
        ttk.Button(self, text='Y_diff mV', command=self.Y_callback, width=12) \
            .grid(row=9, column=4)
        # Create User input box
        self.user_spinbox6 = ttk.Spinbox(self, from_=0, to=65536, width=10)
        self.user_spinbox6.grid(row=10, column=3)
        self.user_spinbox6.delete(0, 'end')
        self.user_spinbox6.insert(0, '1')  #Set default 1#
        # Create User input box
        self.user_spinbox7 = ttk.Spinbox(self, from_=0, to=65536, width=10)
        self.user_spinbox7.grid(row=10, column=4)
        self.user_spinbox7.delete(0, 'end')
        self.user_spinbox7.insert(0, '1')  #Set default 1#

        # #Create label
        label2 = tk.Label(self, text="Output_window:", font=small_FONT)\
                                                                .grid(row=8, column=0)
        #
        #Create program output label
        self.label3 = tk.Label(self,
                               text="",
                               bg="White",
                               font=small_FONT,
                               width=22)
        self.label3.grid(row=9, column=0)
コード例 #30
0
import tkinter as tk
from tkinter import ttk
from matplotlib import cm, colors
import time
from random import shuffle as sf
"""Creating the screen where the app is going to run"""
screen_width = 600
screen_height = 800
screen = tk.Tk()
screen.geometry("{}x{}".format(screen_width, screen_height))
#screen.configure(background='green')
"""Creating the frame that will select the options"""
frame = tk.Frame(screen, bg="#aeb7f2", width=screen_width, height=50)
generate_button = ttk.Button(frame,
                             text="Generate Random",
                             command=lambda: generate())
frame.grid_propagate(False)
frame.rowconfigure(0, weight=2)
frame.grid(row=0, column=0)
generate_button.grid(sticky="ens")

width = 3
number = int((screen_width - 2) / width)
rect_list = []
height_list = []
button_list = [0 for i in range(3)]
#number =5
"""Creating the pane that will contain all the rectangles with different heights"""
rectangle_pane = tk.Canvas(screen, width=screen_width, height=screen_width)
rectangle_pane.grid(row=1, column=0)
rectangle_pane.config(background='#b5e1f5')