python类LabelFrame()的实例源码

GUI_DesignPattern.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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()
box.py 文件源码 项目:synthesizer 作者: irmen 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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()
GUI_Complexity_end_tab3_multiple_notebooks.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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) 

#------------------------------------------
toggledlabelframe.py 文件源码 项目:pkinter 作者: DeflatedPickle 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, parent, on_text="Active", off_text="Inactive", default_state=False, state="enabled", *args):
        ttk.LabelFrame.__init__(self, parent, labelanchor="n", *args)
        self.parent = parent
        self._on_text = on_text
        self._off_text = off_text
        self._default_state = default_state
        self._state = state

        self._fill = tk.Frame(self, height=5)

        self._variable = tk.IntVar()
        self._variable.set(default_state)

        self._button = ttk.Checkbutton(self, width=11, state=self._state, variable=self._variable, command=self._activate, style="TButton")
        self.configure(labelwidget=self._button)

        self.frame = ttk.Frame(self)

        self._activate()
gui.py 文件源码 项目:pyTrack 作者: clamytoe 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def setup_tab2(tab):
    # new frame
    new_frame = ttk.LabelFrame(tab, text='New Project Name')
    new_frame.grid(columnspan=2, row=0, padx=5, pady=5, sticky='ew')

    # New Project
    name = tk.StringVar
    name_entered = ttk.Entry(new_frame, width=19, textvariable=name)
    name_entered.grid(column=0, row=0, padx=6, pady=5)
    name_entered.focus()

    # spacer
    spacer_label = ttk.Label(new_frame, text='')
    spacer_label.grid(columnspan=2, row=1, padx=5, pady=5)

    # add button and commands
    def add_command():
        add_project(name_entered.get())
        spacer_label.configure(text='Project was added!', foreground='green')
        name_entered.delete(0, "end")
        setup_tab1(TAB_1)
        TAB_1.update()

    add_button = ttk.Button(tab, text='Add New Project', command=add_command)
    add_button.grid(columnspan=2, row=3, pady=5)
pmi_menu.py 文件源码 项目:Visualization 作者: nwrush 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        self._window = tk.Toplevel(master=parent.frame)
        self._window.title("PMI Graph Settings")

        self._parent = parent
        self._data = parent.data

        self._color_settings = ttk.LabelFrame(master=self._window, text="Colors")
        self._color_settings.pack()

        self._colors = []
        for index, relation in enumerate(self._data.relation_types):
            label = tk.Label(master=self._color_settings, text="{0} Color".format(relation))
            btn = tk.Button(master=self._color_settings, text="Get Color", command=self._get_color_button(index))
            label.grid(row=index, column=0, sticky="we")
            btn.grid(row=index, column=1)

            parent_color = self._parent._colors[index]
            self._colors.append([label, btn, parent_color]) # Use a better default here

        self._window.protocol("WM_DELETE_WINDOW", self.on_exit)
_ui.py 文件源码 项目:modis 作者: Infraxion 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        """
        Create a new UI for the module

        Args:
            parent: A tk or ttk object
        """

        super(ModuleUIFrame, self).__init__(parent)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)

        # Set default values
        from ....datatools import get_data
        data = get_data()

        # API Frame
        api_frame = ttk.LabelFrame(self, padding=8, text="Google API")
        api_frame.grid(row=0, column=0, sticky="W E N S")
        api_frame.columnconfigure(0, weight=1)
        # Add key fields
        self.google_api_key = tk.StringVar()
        ttk.Label(api_frame, text="Google API Key").grid(column=0, row=0, sticky="W E N S")
        ttk.Entry(api_frame, textvariable=self.google_api_key).grid(
            column=0, row=1, padx=0, pady=4, sticky="W E N S")
        self.soundcloud_client_id = tk.StringVar()
        ttk.Label(api_frame, text="SoundCloud Client ID").grid(column=0, row=2, sticky="W E N S")
        ttk.Entry(api_frame, textvariable=self.soundcloud_client_id).grid(
            column=0, row=3, padx=0, pady=4, sticky="W E N S")
        ttk.Button(api_frame, command=lambda: self.update_keys(), text="Update API Data").grid(
            column=0, row=4, padx=0, pady=4, sticky="W E N S")

        if "google_api_key" in data["discord"]["keys"]:
            self.google_api_key.set(data["discord"]["keys"]["google_api_key"])
        if "soundcloud_client_id" in data["discord"]["keys"]:
            self.soundcloud_client_id.set(data["discord"]["keys"]["soundcloud_client_id"])
gui.py 文件源码 项目:modis 作者: Infraxion 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def __init__(self, parent, module_name, module_ui):
        """
        Create a new base for a module UI

        Args:
            parent: A tk or ttk object
            module_name (str): The name of the module
            module_ui: The _ui.py file to add for the module
        """

        super(ModuleUIBaseFrame, self).__init__(parent, padding=8)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)

        if module_ui is not None:
            # Module UI frame
            module_ui.ModuleUIFrame(self).grid(row=0, column=0, sticky="W E N S")
        else:
            logger.debug("No _ui.py found for '{}'".format(module_name))

        # Help frame
        help_frame = ttk.LabelFrame(self, padding=8, text="Help")
        help_frame.grid(row=1, column=0, sticky="W E N S")
        help_frame.columnconfigure(0, weight=1)
        help_frame.rowconfigure(0, weight=1)
        # Find the help path
        _dir = os.path.realpath(
            os.path.join(os.getcwd(), os.path.dirname(__file__)))
        help_path = "{}/modules/{}/{}".format(_dir, module_name, "_help.json")
        if os.path.isfile(help_path):
            # Load the text
            helptools.add_help_text(help_frame, help_path)
        else:
            # Default message
            tk.Label(help_frame, text="No _help.json file found for '{}'".format(module_name)).grid(row=0, column=0,
                                                                                                    sticky="W E N S")
GUI_Complexity_end_tab3_multiple_notebooks.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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)

#------------------------------------------
test_widgets.py 文件源码 项目:Craft-Clash 作者: Derpyface-Development-Co 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def create(self, **kwargs):
        return ttk.LabelFrame(self.root, **kwargs)
test_widgets.py 文件源码 项目:Craft-Clash 作者: Derpyface-Development-Co 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def create(self, **kwargs):
        return ttk.LabelFrame(self.root, **kwargs)
toggledlabelframe.py 文件源码 项目:pkinter 作者: DeflatedPickle 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def toggle(self):
        """Switches the LabelFrame to the opposite state."""
        self._variable.set(not self._variable.get())
        self._activate()

##################################################
window.py 文件源码 项目:Colony 作者: DeflatedPickle 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, parent, *args, **kwargs):
        BaseWindow.__init__(self, parent, *args, **kwargs)
        self.title("Information")

        self.frame_basic = ttk.LabelFrame(self.frame_widget, text="Basics")
        self.frame_basic.grid(row=0, column=0, padx=3, pady=3, sticky="nesw")
test_widgets.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def create(self, **kwargs):
        return ttk.LabelFrame(self.root, **kwargs)
window.py 文件源码 项目:quill 作者: DeflatedPickle 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def insert_tk_labelframe(self, index: int or str="end", *args, **kwargs):
        """Insert a tk.LabelFrame into the game."""
        widget = tk.LabelFrame(self.text, **kwargs)
        self.text.window_create(index, window=widget)

        return widget
window.py 文件源码 项目:quill 作者: DeflatedPickle 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def insert_ttk_labelframe(self, labelanchor: str="nw", text: str="", underline: int=None, padding: list=[], labelwidget: tk.Widget=None, width: int=None, height: int=None, index: int or str="end", *args, **kwargs):
        """Insert a ttk.LabelFrame into the game."""
        widget = ttk.LabelFrame(self.text, labelanchor=labelanchor, text=text, underline=underline, padding=padding, labelwidget=labelwidget, width=width, height=height, **kwargs)
        self.text.window_create(index, window=widget)

        return widget
test_widgets.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def create(self, **kwargs):
        return ttk.LabelFrame(self.root, **kwargs)
gui.py 文件源码 项目:pyTrack 作者: clamytoe 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def setup_tab3(tab):
    # remove frame
    remove_frame = ttk.LabelFrame(tab, text='Remove Project')
    remove_frame.grid(columnspan=2, row=0, padx=5, pady=5, sticky='ew')

    # Remove Project
    project_to_axe = tk.StringVar()

    walking_dead = ttk.Combobox(remove_frame, width=18, textvariable=project_to_axe, state='readonly')
    walking_dead['values'] = PROJECT_NAMES
    walking_dead.grid(columnspan=2, row=0, padx=5, pady=5)
    walking_dead.current(INDEX)
    walking_dead.configure(state='enabled') if PROJECTS else walking_dead.configure(state='disabled')

    # spacer
    spacer_label = ttk.Label(remove_frame, text='')
    spacer_label.grid(columnspan=2, row=1, padx=5, pady=5)

    # add button and commands
    def remove_command():
        choice = PROJECTS[PROJECT_NAMES.index(walking_dead.get())].id
        remove_project(choice, safe=False)
        spacer_label.configure(text='Project was removed!', foreground='green')
        walking_dead.set('')
        init_globals()
        setup_tab1(TAB_1)
        if not PROJECTS:
            walking_dead.configure(state='disabled')
            remove_button.configure(state='disabled')

    remove_button = ttk.Button(tab, text='Remove Project', command=remove_command)
    remove_button.grid(columnspan=2, row=3, pady=5)
    remove_button.configure(state='enabled') if PROJECTS else remove_button.configure(state='disabled')
gui.py 文件源码 项目:pyTrack 作者: clamytoe 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def setup_tab4(tab):
    # about frame
    about_app = 'Python Time Tracker (pytt)\nVer: {}\n\n{}'.format(__version__, __author__)
    about_frame = ttk.LabelFrame(tab, text='About')
    about_frame.grid(columnspan=2, row=0, padx=5, pady=5, sticky='ew')
    about = ttk.Label(about_frame, text=about_app, justify='center')
    about.grid(columnspan=2, row=1, padx=5, pady=5)
    # about.grid(columnspan=2, rowspan=3, padx=5, pady=5)
box.py 文件源码 项目:synthesizer 作者: irmen 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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()
_ui.py 文件源码 项目:modis 作者: Infraxion 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        """
        Create a new UI for the module

        Args:
            parent: A tk or ttk object
        """

        super(ModuleUIFrame, self).__init__(parent)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        # API Frame
        api_frame = ttk.LabelFrame(self, padding=8, text="Google API")
        api_frame.grid(row=0, column=0, sticky="W E N S")
        api_frame.columnconfigure(0, weight=1)
        # Add key field
        self.reddit_api_user_agent = tk.StringVar()
        ttk.Label(api_frame, text="Reddit API User Agent").grid(column=0, row=0, sticky="W E N S")
        ttk.Entry(api_frame, textvariable=self.reddit_api_user_agent).grid(
            column=0, row=1, padx=0, pady=4, sticky="W E N S")
        self.reddit_api_client_id = tk.StringVar()
        ttk.Label(api_frame, text="Reddit API Client ID").grid(column=0, row=2, sticky="W E N S")
        ttk.Entry(api_frame, textvariable=self.reddit_api_client_id).grid(
            column=0, row=3, padx=0, pady=4, sticky="W E N S")
        self.reddit_api_client_secret = tk.StringVar()
        ttk.Label(api_frame, text="Reddit API Client Secret").grid(column=0, row=4, sticky="W E N S")
        ttk.Entry(api_frame, textvariable=self.reddit_api_client_secret).grid(
            column=0, row=5, padx=0, pady=4, sticky="W E N S")
        # Update keys button
        ttk.Button(api_frame, command=lambda: self.update_keys(), text="Update API Data").grid(
            column=0, row=6, padx=0, pady=4, sticky="W E N S")

        # Set default values
        from ....datatools import get_data
        data = get_data()

        if "reddit_api_user_agent" in data["discord"]["keys"]:
            self.reddit_api_user_agent.set(data["discord"]["keys"]["reddit_api_user_agent"])
        if "reddit_api_client_id" in data["discord"]["keys"]:
            self.reddit_api_client_id.set(data["discord"]["keys"]["reddit_api_client_id"])
        if "reddit_api_client_secret" in data["discord"]["keys"]:
            self.reddit_api_client_secret.set(data["discord"]["keys"]["reddit_api_client_secret"])
GUI_Not_OOP.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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()     
#======================
GUI_Complexity_end_tab3_multiple_notebooks.py 文件源码 项目:Python-GUI-Programming-Cookbook-Second-Edition 作者: PacktPublishing 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)   

#------------------------------------------
gui.py 文件源码 项目:StochOPy 作者: keurfonluu 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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")
cfgWindow.py 文件源码 项目:serialplot 作者: crxguy52 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        ttk.Frame.__init__(self, parent)
        self.parent = parent
        self['padding'] = '4'

        self.TKvariables = {}

        #Read in the defaults
        for key in defaults:

            if key[0:5] == 'graph' or key.find('ylims') >= 0:
                self.TKvariables.update({key:[]})

                for val in range(len(defaults[key])):
                    self.TKvariables[key].append(tk.StringVar(value=defaults[key][val]))

            else:
                self.TKvariables.update({key:tk.StringVar(value=defaults[key])})      

        num_vars = int(self.TKvariables['datalength'].get())
        self.datalist = list(range(1,num_vars+1))

        #Create a combobox containing the available COM ports        
        comlst = self.get_comlst()
        self.COMbox = ttk.Labelframe(self, text='COM port to source data from')
        self.COMcombo = ttk.Combobox(self.COMbox,  width=60, values=comlst, \
            state='readonly', textvariable=self.TKvariables['COMport'],\
            postcommand=self.updateCOMbox )
        self.COMbox.grid(row = 0, column = 0, columnspan = 5)
        self.COMcombo.grid()

        #Create an "about" text box
        ABOUTframe = ttk.LabelFrame(self, text = 'What it does')
        ABOUTlabel = ttk.Label(ABOUTframe, text= \
            'Graphs data coming in over the serial port in a comma '
            'seperated variable string. Hover over each option to get ' 
            'a description of what the setting does', wraplength = 140)
        ABOUTframe.grid(row=1, column = 0, rowspan = 2, columnspan = 2, \
            sticky = 'nw, se', padx= 3, pady = 5)
        CreateToolTip(ABOUTlabel,\
        "The default values can be changed by opening defaults.py with a text "
        "editor and changing the values")
        ABOUTlabel.pack()        

        #Create a Graph! and About buttons
        GObut = ttk.Button(self, text='Go!', command=self.goButton)
        GObut.grid(row=6, column = 0, sticky = 'we')
        ABOUTbut = ttk.Button(self, text='About', command=self.aboutButton) 
        ABOUTbut.grid(row = 6, column = 1, sticky = 'we')

        #Create an instance of the class for the config panel
        notebook = ConfigNotebook(self, self)

        #Update the state of the graphs based on the defaults and grid
        notebook.updateGraphs()     
        notebook.grid(row=1, column=3, columnspan=2, rowspan=6, sticky = 'nsew', \
                padx = 5, pady = 5)

        #Bind the enter key to start the program
        self.parent.bind("<Return>", lambda event:self.goButton())
cfgWindow.py 文件源码 项目:serialplot 作者: crxguy52 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, parent):
        ttk.Frame.__init__(self, parent)
        self.parent = parent
        self['padding'] = '4'

        self.TKvariables = {}

        #Read in the defaults
        for key in defaults:

            if key[0:5] == 'graph' or key.find('ylims') >= 0:
                self.TKvariables.update({key:[]})

                for val in range(len(defaults[key])):
                    self.TKvariables[key].append(tk.StringVar(value=defaults[key][val]))

            else:
                self.TKvariables.update({key:tk.StringVar(value=defaults[key])})      

        num_vars = int(self.TKvariables['datalength'].get())
        self.datalist = list(range(1,num_vars+1))

        #Create a combobox containing the available COM ports        
        comlst = self.get_comlst()
        self.COMbox = ttk.Labelframe(self, text='COM port to source data from')
        self.COMcombo = ttk.Combobox(self.COMbox,  width=60, values=comlst, \
            state='readonly', textvariable=self.TKvariables['COMport'],\
            postcommand=self.updateCOMbox )
        self.COMbox.grid(row = 0, column = 0, columnspan = 5)
        self.COMcombo.grid()

        #Create an "about" text box
        ABOUTframe = ttk.LabelFrame(self, text = 'What it does')
        ABOUTlabel = ttk.Label(ABOUTframe, text= \
            'Graphs data coming in over the serial port in a comma '
            'seperated variable string. Hover over each option to get ' 
            'a description of what the setting does', wraplength = 140)
        ABOUTframe.grid(row=1, column = 0, rowspan = 2, columnspan = 2, \
            sticky = 'nw, se', padx= 3, pady = 5)
        CreateToolTip(ABOUTlabel,\
        "The default values can be changed by opening defaults.py with a text "
        "editor and changing the values")
        ABOUTlabel.pack()        

        #Create a Graph! and About buttons
        GObut = ttk.Button(self, text='Go!', command=self.goButton)
        GObut.grid(row=6, column = 0, sticky = 'we')
        ABOUTbut = ttk.Button(self, text='About', command=self.aboutButton) 
        ABOUTbut.grid(row = 6, column = 1, sticky = 'we')

        #Create an instance of the class for the config panel
        notebook = ConfigNotebook(self, self)

        #Update the state of the graphs based on the defaults and grid
        notebook.updateGraphs()     
        notebook.grid(row=1, column=3, columnspan=2, rowspan=6, sticky = 'nsew', \
                padx = 5, pady = 5)

        #Bind the enter key to start the program
        self.parent.bind("<Return>", lambda event:self.goButton())
extended_pyGISS.py 文件源码 项目:pyGISS 作者: afourmy 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def __init__(self, path_app):
        super().__init__()
        self.title('Extended PyGISS')
        path_icon = abspath(join(path_app, pardir, 'images'))

        # generate the PSF tk images
        img_psf = ImageTk.Image.open(join(
                                          path_icon, 
                                          'node.png'
                                          )
                                    )

        selected_img_psf = ImageTk.Image.open(join(
                                          path_icon, 
                                          'selected_node.png'
                                          )
                                    )
        self.psf_button_image = ImageTk.PhotoImage(img_psf.resize((100, 100)))
        self.node_image = ImageTk.PhotoImage(img_psf.resize((40, 40)))
        self.selected_node_image = ImageTk.PhotoImage(selected_img_psf.resize((40, 40)))

        for widget in (
                       'Button',
                       'Label', 
                       'Labelframe', 
                       'Labelframe.Label', 
                       ):
            ttk.Style().configure('T' + widget, background='#A1DBCD')

        self.map = Map(self)
        self.map.pack(side='right', fill='both', expand=1)

        self.menu = Menu(self)
        self.menu.pack(side='right', fill='both', expand=1)

        menu = tk.Menu(self)
        menu.add_command(label="Import shapefile", command=self.map.import_map)
        self.config(menu=menu)

        # if motion is called, the left-click button was released and we 
        # can stop the drag and drop process
        self.bind_all('<Motion>', self.stop_drag_and_drop)
        self.drag_and_drop = False

        self.image = None
        self.bind_all('<B1-Motion>', lambda _:_)
extended_pyGISS.py 文件源码 项目:pyGISS 作者: afourmy 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, controller):            
        super().__init__(controller)
        self.configure(background='#A1DBCD')   

        lf_creation = ttk.Labelframe(
                                     self, 
                                     text = 'Object management', 
                                     padding = (6, 6, 12, 12)
                                     )
        lf_creation.grid(row=0, column=0, padx=5, pady=5)

        psf_object_label = tk.Label(
                               self, 
                               image = controller.psf_button_image, 
                               relief = 'flat', 
                               bg = '#A1DBCD'
                               )
        psf_object_label.bind('<Button-1>', controller.start_drag_and_drop)
        psf_object_label.grid(row=0, column=0, pady=10, padx=55, in_=lf_creation)

        import_nodes_button = ttk.Button(self, text='Import nodes',
                            command=controller.map.import_nodes, width=20)
        import_nodes_button.grid(row=2, column=0, pady=5, in_=lf_creation)

        lf_projection = ttk.Labelframe(
                                       self, 
                                       text = 'Projection management', 
                                       padding = (6, 6, 12, 12)
                                       )
        lf_projection.grid(row=1, column=0, padx=5, pady=5)

        self.projection_list = ttk.Combobox(self, width=18)
        self.projection_list['values'] = tuple(controller.map.projections)
        self.projection_list.current(0)
        self.projection_list.grid(row=0, column=0, in_=lf_projection)

        change_projection_button = ttk.Button(self, text='Change projection',
                            command=controller.map.change_projection, width=20)
        change_projection_button.grid(row=1, column=0, pady=5, in_=lf_projection)

        lf_map_management = ttk.Labelframe(
                                        self, 
                                        text = 'Map management', 
                                        padding = (6, 6, 12, 12)
                                        )
        lf_map_management.grid(row=2, column=0, padx=5, pady=5)

        delete_map = ttk.Button(self, text='Delete map',
                            command=controller.map.delete_map, width=20)
        delete_map.grid(row=0, column=0, pady=5, in_=lf_map_management)

        delete_selection = ttk.Button(self, text='Delete selected nodes',
                            command=controller.map.delete_selected_nodes, width=20)
        delete_selection.grid(row=1, column=0, pady=5, in_=lf_map_management)


问题


面经


文章

微信
公众号

扫码关注公众号