Python tkinter.ttk.LabelFrame() Examples

The following are 29 code examples of tkinter.ttk.LabelFrame(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tkinter.ttk , or try the search function .
Example #1
Source File: GUI_DesignPattern.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 14 votes vote down vote up
def createWidgets(self):    
        tabControl = ttk.Notebook(self.win)     
        tab1 = ttk.Frame(tabControl)            
        tabControl.add(tab1, text='Tab 1')    
        tabControl.pack(expand=1, fill="both")  
        self.monty = ttk.LabelFrame(tab1, text=' Monty Python ')
        self.monty.grid(column=0, row=0, padx=8, pady=4)        

        scr = scrolledtext.ScrolledText(self.monty, width=30, height=3, wrap=tk.WORD)
        scr.grid(column=0, row=3, sticky='WE', columnspan=3)

        menuBar = Menu(tab1)
        self.win.config(menu=menuBar)
        fileMenu = Menu(menuBar, tearoff=0)
        menuBar.add_cascade(label="File", menu=fileMenu)
        helpMenu = Menu(menuBar, tearoff=0)
        menuBar.add_cascade(label="Help", menu=helpMenu)
        
        self.createButtons() 
Example #2
Source File: annotation_gui.py    From SEM with MIT License 9 votes vote down vote up
def preferences(self, event=None):
        preferenceTop = tkinter.Toplevel()
        preferenceTop.focus_set()
        
        notebook = ttk.Notebook(preferenceTop)
        
        frame1 = ttk.Frame(notebook)
        notebook.add(frame1, text='general')
        frame2 = ttk.Frame(notebook)
        notebook.add(frame2, text='shortcuts')

        c = ttk.Checkbutton(frame1, text="Match whole word when broadcasting annotation", variable=self._whole_word)
        c.pack()
        
        shortcuts_vars = []
        shortcuts_gui = []
        cur_row = 0
        j = -1
        frame_list = []
        frame_list.append(ttk.LabelFrame(frame2, text="common shortcuts"))
        frame_list[-1].pack(fill="both", expand="yes")
        for i, shortcut in enumerate(self.shortcuts):
            j += 1
            key, cmd, bindings = shortcut
            name, command = cmd
            shortcuts_vars.append(tkinter.StringVar(frame_list[-1], value=key))
            tkinter.Label(frame_list[-1], text=name).grid(row=cur_row, column=0, sticky=tkinter.W)
            entry = tkinter.Entry(frame_list[-1], textvariable=shortcuts_vars[j])
            entry.grid(row=cur_row, column=1)
            cur_row += 1
        notebook.pack()
    
    #
    # ? menu methods
    # 
Example #3
Source File: box.py    From synthesizer with GNU Lesser General Public License v3.0 8 votes vote down vote up
def __init__(self, master):
        super().__init__(master, text="Levels", padding=4)
        self.lowest_level = Player.levelmeter_lowest
        self.pbvar_left = tk.IntVar()
        self.pbvar_right = tk.IntVar()
        pbstyle = ttk.Style()
        # pbstyle.theme_use("classic")  # clam, alt, default, classic
        pbstyle.configure("green.Vertical.TProgressbar", troughcolor="gray", background="light green")
        pbstyle.configure("yellow.Vertical.TProgressbar", troughcolor="gray", background="yellow")
        pbstyle.configure("red.Vertical.TProgressbar", troughcolor="gray", background="orange")

        ttk.Label(self, text="dB").pack(side=tkinter.TOP)
        frame = ttk.LabelFrame(self, text="L.")
        frame.pack(side=tk.LEFT)
        self.pb_left = ttk.Progressbar(frame, orient=tk.VERTICAL, length=200, maximum=-self.lowest_level,
                                       variable=self.pbvar_left, mode='determinate',
                                       style='yellow.Vertical.TProgressbar')
        self.pb_left.pack()

        frame = ttk.LabelFrame(self, text="R.")
        frame.pack(side=tk.LEFT)
        self.pb_right = ttk.Progressbar(frame, orient=tk.VERTICAL, length=200, maximum=-self.lowest_level,
                                        variable=self.pbvar_right, mode='determinate',
                                        style='yellow.Vertical.TProgressbar')
        self.pb_right.pack() 
Example #4
Source File: program9.py    From python-gui-demos with MIT License 6 votes vote down vote up
def __init__(self, master):
        self.frame = ttk.Frame(master, width = 100, height = 100)   # frame height and width are in pixel
        self.frame.pack()
        self.frame.config(relief = tk.RAISED)   # to define frame boarder
        self.button = ttk.Button(self.frame, text = 'Click for Magic')
        self.button.config(command = self.performMagic)
        self.button.grid()  # use grid geometry manager
        self.frame.config(padding = (30,15))
        
        self.lbfrm = ttk.LabelFrame(master, width = 100, height = 100)
        self.lbfrm.config(padding = (30, 15))
        self.lbfrm.config(text = "Magic Below")
        self.lbfrm.pack()
        self.label = ttk.Label(self.lbfrm, text = "Waiting for Magic")
        self.label.grid() 
Example #5
Source File: GUI_Complexity_end_tab3_multiple_notebooks.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 6 votes vote down vote up
def display_tab3():
    monty3 = ttk.LabelFrame(display_area, text=' New Features ')
    monty3.grid(column=0, row=0, padx=8, pady=4)
    
    # Adding more Feature Buttons
    startRow = 4
    for idx in range(24):
        if idx < 2:
            colIdx = idx
            col = colIdx
        else:
            col += 1
        if not idx % 3: 
            startRow += 1
            col = 0
    
        b = ttk.Button(monty3, text="Feature " + str(idx + 1))   
        b.grid(column=col, row=startRow)    
        
    # Add some space around each label
    for child in monty3.winfo_children(): 
        child.grid_configure(padx=8) 
            
#------------------------------------------ 
Example #6
Source File: speech_demo_tk.py    From honk with MIT License 6 votes vote down vote up
def init_ui(self):
        """ setup the GUI for the app """
        self.master.title("Speech Demo")
        self.pack(fill=BOTH, expand=True)

        label_frame = LabelFrame(self, text="Words you can speak")
        label_frame.pack(fill=X, padx=10, pady=10)
        self.labels = []
        rows = 4
        cols = 3
        for j in range(rows):
            for i in range(cols):
                k = i  + j * cols
                label = Label(label_frame, text=labels[k])
                label.config(font=("Courier", 36))
                label.grid(row=j,column=i,padx=10, pady=10)
                self.labels += [ label ]
        self.selected = None
        self.after(100, self.ontick) 
Example #7
Source File: control_helper.py    From faceswap with GNU General Public License v3.0 6 votes vote down vote up
def get_group_frame(self, group):
        """ Return a new group frame """
        group = group.lower()
        if self.group_frames.get(group, None) is None:
            logger.debug("Creating new group frame for: %s", group)
            is_master = group == "_master"
            opts_frame = self.optsframe.subframe
            if is_master:
                group_frame = ttk.Frame(opts_frame, name=group.lower())
            else:
                group_frame = ttk.LabelFrame(opts_frame,
                                             text="" if is_master else group.title(),
                                             name=group.lower())

            group_frame.pack(side=tk.TOP, fill=tk.X, padx=5, pady=5, anchor=tk.NW)

            self.group_frames[group] = dict(frame=group_frame,
                                            chkbtns=self.checkbuttons_frame(group_frame))
        group_frame = self.group_frames[group]
        return group_frame 
Example #8
Source File: GUI_Complexity_end_tab3_multiple_notebooks.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 6 votes vote down vote up
def display_tab3():
    monty3 = ttk.LabelFrame(display_area, text=' New Features ')
    monty3.grid(column=0, row=0, padx=8, pady=4)
    
    # Adding more Feature Buttons
    startRow = 4
    for idx in range(24):
        if idx < 2:
            colIdx = idx
            col = colIdx
        else:
            col += 1
        if not idx % 3: 
            startRow += 1
            col = 0
    
        b = ttk.Button(monty3, text="Feature " + str(idx + 1))   
        b.grid(column=col, row=startRow)    
        
    # Add some space around each label
    for child in monty3.winfo_children(): 
        child.grid_configure(padx=8) 
            
#------------------------------------------ 
Example #9
Source File: simple_user_interface.py    From network_traffic_modeler_py3 with Apache License 2.0 5 votes vote down vote up
def node_dropdown_select(label, node_choices, target_variable, row_, column_):
    """"Creates a labelframe with a node select option menu"""
    #### Frame to choose a node ####
    choose_node_frame = LabelFrame(path_tab)
    choose_node_frame.grid(row=row_, column=column_, padx=10, pady=10)
    # Label for choosing node
    Label(choose_node_frame, text=label).grid(row=0, column=0, sticky='W',
                                              pady=10)

    # Dropdown menu to choose a node
    node_choices_list = node_choices

    # Put the node selection button on the node_tab.
    # This option menu will call examine_selected_node when the choice is made.
    node_dropdown_select = OptionMenu(choose_node_frame, target_variable,
                                      *node_choices,
                                      command=set_active_object_from_option_menu)
    node_dropdown_select.grid(row=0, column=1, sticky='E')

    # Label to confirm selected Node
    Label(choose_node_frame, text="Selected node is:").grid(row=1, column=0, sticky='W')

    # Display the selected Node
    Label(choose_node_frame, text='-----------------------------------').\
        grid(row=1, column=1, sticky='E')
    Label(choose_node_frame, text=target_variable.get()).grid(row=1, column=1, sticky='E')

    return choose_node_frame


# Establish the canvas 
Example #10
Source File: simple_user_interface.py    From network_traffic_modeler_py3 with Apache License 2.0 5 votes vote down vote up
def examine_selected_interface(*args):
    """Allows user to explore interfaces with different characteristics"""

    #### Filter to interfaces above a certain utilization ####
    utilization_frame = LabelFrame(interface_tab)
    utilization_frame.grid(row=0, column=0)
    utilization_pct = [x for x in range(0, 100)]

    # Label for pct util selection
    pct_label = Label(utilization_frame, text="Display interfaces with \
utilization % greater than:")
    pct_label.grid(row=0, column=0, columnspan=2, sticky='W')
    pct_label.config(width=50)

    # Dropdown menu for pct util
    pct_dropdown_select = OptionMenu(utilization_frame, min_pct,
                                     *utilization_pct, command=set_active_object_from_option_menu)
    pct_dropdown_select.grid(row=0, column=4, sticky='W')

    msg = "Interfaces above " + str(min_pct.get()) + "% utilization"

    interface_list = [str(round((interface.utilization), 1)) + '%   '
                      + interface.__repr__() for interface in model.interface_objects if
                      ((interface.utilization) >= min_pct.get())]

    interface_list.sort(key=lambda x: float(x.split('%')[0]))

    int_util = display_interfaces(msg, utilization_frame, interface_list, 2, 1)
    int_util.grid(sticky='W')

    selected_objects_int_tab = LabelFrame(interface_tab)
    selected_objects_int_tab.grid(row=0, column=6, padx=10, sticky='W')

    display_selected_objects(selected_objects_int_tab, 0, 8)

    demands_on_interface = get_demands_on_interface(selected_interface.get())

    intf_demands = display_demands("Demands Egressing Selected Interface", interface_tab,
                                   demands_on_interface, 6, 0) 
Example #11
Source File: simple_user_interface.py    From network_traffic_modeler_py3 with Apache License 2.0 5 votes vote down vote up
def display_lsps(label_info, canvas_object, lsp_list, row_, column_):
    """Displays lsps in single selectable listbox.
    A label with label_info will appear above the listbox."""
    # Display Node's Interfaces Label


    lsp_frame = LabelFrame(canvas_object)
    lsp_frame.grid(row=row_, column=column_, pady=10)

    Label(lsp_frame, text=label_info).grid(row=0, column=0, sticky='W', padx=10)

    # Vertical scrollbar
    vertical_scrollbar = Scrollbar(lsp_frame, orient=VERTICAL)
    vertical_scrollbar.grid(row=row_ + 1, column=column_ + 2, sticky=N + S)

    # Horizontal scrollbar
    horizontal_scrollbar = Scrollbar(lsp_frame, orient=HORIZONTAL)
    horizontal_scrollbar.grid(row=(row_ + 2), column=column_, sticky=E + W,
                              columnspan=2)

    # Create a listbox with the available interfaces for the Node
    lsps_listbox = Listbox(lsp_frame, selectmode='single', height=8, width=40,
                           xscrollcommand=horizontal_scrollbar.set, yscrollcommand=vertical_scrollbar.set)

    lsps_listbox.grid(row=row_ + 1, column=column_, columnspan=2, sticky='W', padx=5)

    horizontal_scrollbar.config(command=lsps_listbox.xview)
    vertical_scrollbar.config(command=lsps_listbox.yview)

    lsp_counter = 1

    for lsp_name in lsp_list:
        lsps_listbox.insert(lsp_counter, lsp_name)
        lsp_counter += 1

    lsps_listbox.bind("<<ListBoxSelect>>", set_active_lsp_from_listbox)
    lsps_listbox.bind("<Double-Button-1>", set_active_lsp_from_listbox)

    return lsps_listbox 
Example #12
Source File: simple_user_interface.py    From network_traffic_modeler_py3 with Apache License 2.0 5 votes vote down vote up
def display_demands(label_info, canvas_object, list_of_demands, row_, column_,):
    """Displays a label for demands and a single-select listbox of the
    demands below the label_info on a given canvas_object.  A horizontal
    scrollbar is included """

    demands_frame = LabelFrame(canvas_object)
    demands_frame.grid(row=row_, column=column_, pady=10)

    Label(demands_frame, text=label_info).grid(row=0, column=0, sticky='W', padx=10)

    # Horizontal scrollbar
    horizontal_scrollbar = Scrollbar(demands_frame, orient=HORIZONTAL)
    horizontal_scrollbar.grid(row=3, column=0, sticky=E + W)

    # Vertical scrollbar
    vertical_scrollbar = Scrollbar(demands_frame, orient=VERTICAL)
    vertical_scrollbar.grid(row=1, column=1, sticky=N + S)

    demand_listbox = Listbox(demands_frame, selectmode='single', height=10,
                             width=40, xscrollcommand=horizontal_scrollbar.set,
                             yscrollcommand=vertical_scrollbar.set)
    demand_listbox.grid(row=1, column=0, sticky='W', padx=10)

    vertical_scrollbar.config(command=demand_listbox.yview)

    horizontal_scrollbar.config(command=demand_listbox.xview)

    demand_counter = 1
    for demand in list_of_demands:
        demand_listbox.insert(demand_counter, demand)
        demand_counter += 1

    demand_listbox.bind("<<ListBoxSelect>>", set_active_demand_from_listbox)
    demand_listbox.bind("<Double-Button-1>", set_active_demand_from_listbox) 
Example #13
Source File: test_widgets.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def create(self, **kwargs):
        return ttk.LabelFrame(self.root, **kwargs) 
Example #14
Source File: control_helper.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def _multi_option_control(self, option_type):
        """ Create a group of buttons for single or multi-select

        Parameters
        ----------
        option_type: {"radio", "multi"}
            The type of boxes that this control should hold. "radio" for single item select,
            "multi" for multi item select.

        """
        logger.debug("Adding %s group: %s", option_type, self.option.name)
        help_intro, help_items = self._get_multi_help_items(self.option.helptext)
        ctl = ttk.LabelFrame(self.frame,
                             text=self.option.title,
                             name="{}_labelframe".format(option_type))
        holder = AutoFillContainer(ctl, self.option_columns, self.option_columns)
        for choice in self.option.choices:
            ctl = ttk.Radiobutton if option_type == "radio" else MultiOption
            ctl = ctl(holder.subframe,
                      text=choice.replace("_", " ").title(),
                      value=choice,
                      variable=self.option.tk_var)
            if choice.lower() in help_items:
                self.helpset = True
                helptext = help_items[choice.lower()].capitalize()
                helptext = "{}\n\n - {}".format(
                    '. '.join(item.capitalize() for item in helptext.split('. ')),
                    help_intro)
                _get_tooltip(ctl, text=helptext, wraplength=600)
            ctl.pack(anchor=tk.W)
            logger.debug("Added %s option %s", option_type, choice)
        return holder.parent 
Example #15
Source File: control_helper.py    From faceswap with GNU General Public License v3.0 5 votes vote down vote up
def checkbuttons_frame(self, frame):
        """ Build and format frame for holding the check buttons
            if is_master then check buttons will be placed in a LabelFrame
            otherwise in a standard frame """
        logger.debug("Add Options CheckButtons Frame")
        chk_frame = ttk.Frame(frame, name="chkbuttons")
        holder = AutoFillContainer(chk_frame, self.option_columns, self.option_columns)
        logger.debug("Added Options CheckButtons Frame")
        return holder 
Example #16
Source File: box.py    From synthesizer with GNU Lesser General Public License v3.0 5 votes vote down vote up
def __init__(self, master, title, backend):
        super().__init__(master)
        self.geometry("+400+400")
        self.title(title)
        f = ttk.LabelFrame(self, text="Stats")
        ttk.Label(f, text="Connected to Database backend at: "+backend._pyroUri.location).pack()
        statstext = "Number of tracks in database: {0} -- Total playing time: {1}"\
            .format(backend.num_tracks, datetime.timedelta(seconds=backend.total_playtime))
        ttk.Label(f, text=statstext).pack()
        f.pack()
        ttk.Label(self, text="Adding tracks etc. is done via the command-line interface for now.\n"
                             "Type 'help' in the console there to see the commands available.").pack()
        ttk.Button(self, text="Ok", command=self.destroy).pack() 
Example #17
Source File: test_widgets.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def create(self, **kwargs):
        return ttk.LabelFrame(self.root, **kwargs) 
Example #18
Source File: GUI_Complexity_end_tab3_multiple_notebooks.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 5 votes vote down vote up
def display_tab2():
    monty2 = ttk.LabelFrame(display_area, text=' Holy Grail ')
    monty2.grid(column=0, row=0, padx=8, pady=4)
    
    # Creating three checkbuttons
    chVarDis = tk.IntVar()
    check1 = tk.Checkbutton(monty2, text="Disabled", variable=chVarDis, state='disabled')
    check1.select()
    check1.grid(column=0, row=0, sticky=tk.W)                 
    
    chVarUn = tk.IntVar()
    check2 = tk.Checkbutton(monty2, text="UnChecked", variable=chVarUn)
    check2.deselect()
    check2.grid(column=1, row=0, sticky=tk.W )                  
     
    chVarEn = tk.IntVar()
    check3 = tk.Checkbutton(monty2, text="Toggle", variable=chVarEn)
    check3.deselect()
    check3.grid(column=2, row=0, sticky=tk.W)                 

    # Create a container to hold labels
    labelsFrame = ttk.LabelFrame(monty2, text=' Labels in a Frame ')
    labelsFrame.grid(column=0, row=7)
     
    # Place labels into the container element - vertically
    ttk.Label(labelsFrame, text="Label1").grid(column=0, row=0)
    ttk.Label(labelsFrame, text="Label2").grid(column=0, row=1)
    
    # Add some space around each label
    for child in labelsFrame.winfo_children(): 
        child.grid_configure(padx=8)
        
#------------------------------------------ 
Example #19
Source File: GUI_Not_OOP.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 5 votes vote down vote up
def createWidgets():    
    tabControl = ttk.Notebook(win)     
    tab1 = ttk.Frame(tabControl)            
    tabControl.add(tab1, text='Tab 1')    
    tabControl.pack(expand=1, fill="both")  
    monty = ttk.LabelFrame(tab1, text=' Mighty Python ')
    monty.grid(column=0, row=0, padx=8, pady=4)        
    
    ttk.Label(monty, text="Enter a name:").grid(column=0, row=0, sticky='W')
    name = tk.StringVar()
    nameEntered = ttk.Entry(monty, width=12, textvariable=name)
    nameEntered.grid(column=0, row=1, sticky='W')
    
    action = ttk.Button(monty, text="Click Me!")   
    action.grid(column=2, row=1)
    
    ttk.Label(monty, text="Choose a number:").grid(column=1, row=0)
    number = tk.StringVar()
    numberChosen = ttk.Combobox(monty, width=12, textvariable=number)
    numberChosen['values'] = (42)
    numberChosen.grid(column=1, row=1)
    numberChosen.current(0)
    
    scrolW = 30; scrolH = 3
    scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH, wrap=tk.WORD)
    scr.grid(column=0, row=3, sticky='WE', columnspan=3)
    
    menuBar = Menu(tab1)
    win.config(menu=menuBar)
    fileMenu = Menu(menuBar, tearoff=0)
    menuBar.add_cascade(label="File", menu=fileMenu)
    helpMenu = Menu(menuBar, tearoff=0)
    menuBar.add_cascade(label="Help", menu=helpMenu)
    
    nameEntered.focus()     
#====================== 
Example #20
Source File: test_widgets.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def create(self, **kwargs):
        return ttk.LabelFrame(self.root, **kwargs) 
Example #21
Source File: weight_frame_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def create_widgets(self):
        ''' Creates all widgets.
        '''
        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)

        validate_btn = Button(self, text='Validate weight restrictions',
                              command=self.on_validate_weights)
        validate_btn.grid(row=0, column=0, padx=10, pady=5, sticky=N+W)

        panel = LabelFrame(self, text='Weight restrictions')
        panel.columnconfigure(0, weight=1)
        panel.rowconfigure(0, weight=1)
        panel.grid(row=1, column=0,
                   padx=5, pady=5, sticky=E+W+S+N)

        weight_tab_main = VerticalScrolledFrame(panel)
        weight_tab_main.grid(row=0, column=0, sticky=E+W+S+N)
        weights_tab = weight_tab_main.interior

        self.abs_weights = TextForWeights(weights_tab, 'absolute',
                                          'Input1 <= 0.02',
                                          self.current_categories, self.params,
                                          'ABS_WEIGHT_RESTRICTIONS')
        self.abs_weights.grid(row=0, column=0, padx=10, pady=5, sticky=N+W)
        self.virtual_weights = TextForWeights(weights_tab, 'virtual',
                                              'Input1 >= 0.34',
                                              self.current_categories,
                                              self.params,
                                              'VIRTUAL_WEIGHT_RESTRICTIONS')
        self.virtual_weights.grid(row=1, column=0, padx=10, pady=5, sticky=N+W)
        self.price_ratio_weights = TextForWeights(weights_tab, 'price ratio',
                                                  'Input1/Input2 <= 5',
                                                  self.current_categories,
                                                  self.params,
                                                  'PRICE_RATIO_RESTRICTIONS',
                                                  True)
        self.price_ratio_weights.grid(row=2, column=0, padx=10, pady=5,
                                      sticky=N+W) 
Example #22
Source File: data_tab_frame_gui.py    From pyDEA with MIT License 5 votes vote down vote up
def _create_label_frame(self):
        ''' Creates label frame.
        '''
        self.panel = panel = LabelFrame(self, text=TEXT_FOR_PANEL)
        panel.columnconfigure(0, weight=1)
        panel.rowconfigure(0, weight=1)
        panel.grid(row=1, column=0,
                   padx=5, pady=5, sticky=E+W+S+N) 
Example #23
Source File: GUI_Complexity_end_tab3_multiple_notebooks.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def display_tab2():
    monty2 = ttk.LabelFrame(display_area, text=' Holy Grail ')
    monty2.grid(column=0, row=0, padx=8, pady=4)
    
    # Creating three checkbuttons
    chVarDis = tk.IntVar()
    check1 = tk.Checkbutton(monty2, text="Disabled", variable=chVarDis, state='disabled')
    check1.select()
    check1.grid(column=0, row=0, sticky=tk.W)                 
    
    chVarUn = tk.IntVar()
    check2 = tk.Checkbutton(monty2, text="UnChecked", variable=chVarUn)
    check2.deselect()
    check2.grid(column=1, row=0, sticky=tk.W )                  
     
    chVarEn = tk.IntVar()
    check3 = tk.Checkbutton(monty2, text="Toggle", variable=chVarEn)
    check3.deselect()
    check3.grid(column=2, row=0, sticky=tk.W)                 

    # Create a container to hold labels
    labelsFrame = ttk.LabelFrame(monty2, text=' Labels in a Frame ')
    labelsFrame.grid(column=0, row=7)
     
    # Place labels into the container element - vertically
    ttk.Label(labelsFrame, text="Label1").grid(column=0, row=0)
    ttk.Label(labelsFrame, text="Label2").grid(column=0, row=1)
    
    # Add some space around each label
    for child in labelsFrame.winfo_children(): 
        child.grid_configure(padx=8)
        
#------------------------------------------ 
Example #24
Source File: GUI_Not_OOP.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def createWidgets():    
    tabControl = ttk.Notebook(win)     
    tab1 = ttk.Frame(tabControl)            
    tabControl.add(tab1, text='Tab 1')    
    tabControl.pack(expand=1, fill="both")  
    monty = ttk.LabelFrame(tab1, text=' Mighty Python ')
    monty.grid(column=0, row=0, padx=8, pady=4)        
    
    ttk.Label(monty, text="Enter a name:").grid(column=0, row=0, sticky='W')
    name = tk.StringVar()
    nameEntered = ttk.Entry(monty, width=12, textvariable=name)
    nameEntered.grid(column=0, row=1, sticky='W')
    
    action = ttk.Button(monty, text="Click Me!")   
    action.grid(column=2, row=1)
    
    ttk.Label(monty, text="Choose a number:").grid(column=1, row=0)
    number = tk.StringVar()
    numberChosen = ttk.Combobox(monty, width=12, textvariable=number)
    numberChosen['values'] = (42)
    numberChosen.grid(column=1, row=1)
    numberChosen.current(0)
    
    scrolW = 30; scrolH = 3
    scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH, wrap=tk.WORD)
    scr.grid(column=0, row=3, sticky='WE', columnspan=3)
    
    menuBar = Menu(tab1)
    win.config(menu=menuBar)
    fileMenu = Menu(menuBar, tearoff=0)
    menuBar.add_cascade(label="File", menu=fileMenu)
    helpMenu = Menu(menuBar, tearoff=0)
    menuBar.add_cascade(label="Help", menu=helpMenu)
    
    nameEntered.focus()     
#====================== 
Example #25
Source File: GUI_DesignPattern.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 5 votes vote down vote up
def createWidgets(self):    
        tabControl = ttk.Notebook(self.win)     
        tab1 = ttk.Frame(tabControl)            
        tabControl.add(tab1, text='Tab 1')    
        tabControl.pack(expand=1, fill="both")  
        self.monty = ttk.LabelFrame(tab1, text=' Monty Python ')
        self.monty.grid(column=0, row=0, padx=8, pady=4)        

        scr = scrolledtext.ScrolledText(self.monty, width=30, height=3, wrap=tk.WORD)
        scr.grid(column=0, row=3, sticky='WE', columnspan=3)

        menuBar = Menu(tab1)
        self.win.config(menu=menuBar)
        fileMenu = Menu(menuBar, tearoff=0)
        menuBar.add_cascade(label="File", menu=fileMenu)
        helpMenu = Menu(menuBar, tearoff=0)
        menuBar.add_cascade(label="Help", menu=helpMenu)
        
        self.createButtons() 
Example #26
Source File: GUI_Complexity_end_tab3_multiple_notebooks.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 4 votes vote down vote up
def display_tab1():
    # Container frame to hold all other widgets
    monty = ttk.LabelFrame(display_area, text=' Mighty Python ')
    monty.grid(column=0, row=0, padx=8, pady=4)
    
    # Adding a Label
    ttk.Label(monty, text="Enter a name:").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')
    
    ttk.Label(monty, text="Choose a number:").grid(column=1, row=0)
    number = tk.StringVar()
    numberChosen = ttk.Combobox(monty, width=12, textvariable=number)
    numberChosen['values'] = (1, 2, 4, 42, 100)
    numberChosen.grid(column=1, row=1)
    numberChosen.current(0)

    # Adding a Button
    action = ttk.Button(monty, text="Click Me!", command= lambda: clickMe(action, name, number))   
    action.grid(column=2, row=1)
    
    # Using a scrolled Text control    
    scrolW  = 30; scrolH  =  3
    scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH, wrap=tk.WORD)
    scr.grid(column=0, row=3, sticky='WE', columnspan=3)  
             
    # Adding a Spinbox widget using a set of values
    spin = Spinbox(monty, values=(1, 2, 4, 42, 100), width=5, bd=8, command= lambda: _spin(spin, scr)) 
    spin.grid(column=0, row=2, sticky='W')  
  
    # Adding another Button
    clear = ttk.Button(monty, text="Clear Text", command= lambda: clearScrol(scr))   
    clear.grid(column=2, row=2)

    # Adding more Feature Buttons
    startRow = 4
    for idx in range(12):
        if idx < 2:
            col = idx
        else:
            col += 1
        if not idx % 3: 
            startRow += 1
            col = 0

        b = ttk.Button(monty, text="Feature " + str(idx+1))   
        b.grid(column=col, row=startRow)   
            
#------------------------------------------ 
Example #27
Source File: gui.py    From stochopy with MIT License 4 votes vote down vote up
def frame1(self):
        self.frame1 = ttk.LabelFrame(self.master, text = "Parameters", borderwidth = 2, relief = "groove")
        self.frame1.place(bordermode = "outside", relwidth = 0.99, relheight = 0.21, relx = 0, x = 5, y = 5, anchor = "nw")
        self.frame1.first_run = True
        
        # function
        function_label = ttk.Label(self.frame1, text = "Function")
        function_option_menu = ttk.OptionMenu(self.frame1, self.function, self.function.get(),
                                              *sorted(self.FUNCOPT))
        
        # max_iter
        max_iter_label = ttk.Label(self.frame1, text = "Maximum number of iterations")
        max_iter_spinbox = Spinbox(self.frame1, from_ = 2, to_ = 9999,
                                   increment = 1, textvariable = self.max_iter,
                                   width = 6, justify = "right", takefocus = True)
        
        # fps
        fps_label = ttk.Label(self.frame1, text = "Delay between frames (ms)")
        fps_spinbox = Spinbox(self.frame1, from_ = 1, to_ = 1000,
                              increment = 1, textvariable = self.interval,
                              width = 6, justify = "right", takefocus = True)
        
        # seed
        seed_button = ttk.Checkbutton(self.frame1, text = "Fix seed",
                                      variable = self.fix_seed, takefocus = False)
        seed_spinbox = Spinbox(self.frame1, from_ = 0, to_ = self.MAX_SEED,
                               increment = 1, textvariable = self.seed,
                               width = 6, justify = "right", takefocus = True)
        
        # solver
        solver_label = ttk.Label(self.frame1, text = "Solver")
        
        solver_option_menu = ttk.OptionMenu(self.frame1, self.solver_name, self.solver_name.get(),
                                            *(self.EAOPT + self.MCOPT), command = self.select_widget)
        
        # constrain
        constrain_button = ttk.Checkbutton(self.frame1, text = "Constrain",
                                      variable = self.constrain, takefocus = False)
        
        # Layout
        function_label.place(relx = 0., x = 5, y = 5, anchor = "nw")
        function_option_menu.place(relx = 0., x = 75, y = 3, anchor = "nw")
        max_iter_label.place(relx = 0., x = 5, y = 30, anchor = "nw")
        max_iter_spinbox.place(width = 80, relx = 0., x = 220, y = 30, anchor = "nw")
        fps_label.place(relx = 0., x = 5, y = 55, anchor = "nw")
        fps_spinbox.place(width = 80, relx = 0., x = 220, y = 55, anchor = "nw")
        seed_button.place(relx = 0., x = 5, y = 80, anchor = "nw")
        seed_spinbox.place(width = 80, relx = 0., x = 220, y = 80, anchor = "nw")
        solver_label.place(relx = 0.35, x = 0, y = 5, anchor = "nw")
        solver_option_menu.place(relx = 0.35, x = 50, y = 3, anchor = "nw")
        constrain_button.place(relx = 0.35, x = 0, y = 80, anchor = "nw") 
Example #28
Source File: backend_config_page.py    From thonny with MIT License 4 votes vote down vote up
def __init__(self, master):
        ConfigurationPage.__init__(self, master)

        self._backend_specs_by_desc = {
            spec.description: spec for spec in get_workbench().get_backends().values()
        }
        self._conf_pages = {}
        self._current_page = None

        current_backend_name = get_workbench().get_option("run.backend_name")
        try:
            current_backend_desc = get_workbench().get_backends()[current_backend_name].description
        except KeyError:
            current_backend_desc = ""

        self._combo_variable = create_string_var(current_backend_desc)

        label = ttk.Label(
            self, text=_("Which interpreter or device should Thonny use for running your code?")
        )
        label.grid(row=0, column=0, columnspan=2, sticky=tk.W)

        sorted_backend_specs = sorted(
            self._backend_specs_by_desc.values(), key=lambda x: x.sort_key
        )

        self._combo = ttk.Combobox(
            self,
            exportselection=False,
            textvariable=self._combo_variable,
            values=[spec.description for spec in sorted_backend_specs],
            height=25,
        )

        self._combo.grid(row=1, column=0, columnspan=2, sticky=tk.NSEW, pady=(0, 10))
        self._combo.state(["!disabled", "readonly"])

        self.labelframe = ttk.LabelFrame(self, text=" " + _("Details") + " ")
        self.labelframe.grid(row=2, column=0, sticky="nsew")
        self.labelframe.columnconfigure(0, weight=1)
        self.labelframe.rowconfigure(0, weight=1)

        self.columnconfigure(0, weight=1)
        self.rowconfigure(2, weight=1)

        self._combo_variable.trace("w", self._backend_changed)
        self._backend_changed() 
Example #29
Source File: GUI_Complexity_end_tab3_multiple_notebooks.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 4 votes vote down vote up
def display_tab1():
    # Container frame to hold all other widgets
    monty = ttk.LabelFrame(display_area, text=' Mighty Python ')
    monty.grid(column=0, row=0, padx=8, pady=4)
    
    # Adding a Label
    ttk.Label(monty, text="Enter a name:").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')
    
    ttk.Label(monty, text="Choose a number:").grid(column=1, row=0)
    number = tk.StringVar()
    numberChosen = ttk.Combobox(monty, width=12, textvariable=number)
    numberChosen['values'] = (1, 2, 4, 42, 100)
    numberChosen.grid(column=1, row=1)
    numberChosen.current(0)

    # Adding a Button
    action = ttk.Button(monty, text="Click Me!", command= lambda: clickMe(action, name, number))   
    action.grid(column=2, row=1)
    
    # Using a scrolled Text control    
    scrolW  = 30; scrolH  =  3
    scr = scrolledtext.ScrolledText(monty, width=scrolW, height=scrolH, wrap=tk.WORD)
    scr.grid(column=0, row=3, sticky='WE', columnspan=3)  
             
    # Adding a Spinbox widget using a set of values
    spin = Spinbox(monty, values=(1, 2, 4, 42, 100), width=5, bd=8, command= lambda: _spin(spin, scr)) 
    spin.grid(column=0, row=2, sticky='W')  
  
    # Adding another Button
    clear = ttk.Button(monty, text="Clear Text", command= lambda: clearScrol(scr))   
    clear.grid(column=2, row=2)

    # Adding more Feature Buttons
    startRow = 4
    for idx in range(12):
        if idx < 2:
            colIdx = idx
            col = colIdx
        else:
            col += 1
        if not idx % 3: 
            startRow += 1
            col = 0

        b = ttk.Button(monty, text="Feature " + str(idx+1))   
        b.grid(column=col, row=startRow)   
            
#------------------------------------------