當前位置: 首頁>>代碼示例>>Python>>正文


Python ttk.Frame方法代碼示例

本文整理匯總了Python中tkinter.ttk.Frame方法的典型用法代碼示例。如果您正苦於以下問題:Python ttk.Frame方法的具體用法?Python ttk.Frame怎麽用?Python ttk.Frame使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tkinter.ttk的用法示例。


在下文中一共展示了ttk.Frame方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: show_friends

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def show_friends(self):
        self.configure(menu=self.menu)
        self.login_frame.pack_forget()

        self.canvas = tk.Canvas(self, bg="white")
        self.canvas_frame = tk.Frame(self.canvas)

        self.scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.canvas.yview)
        self.canvas.configure(yscrollcommand=self.scrollbar.set)

        self.scrollbar.pack(side=tk.LEFT, fill=tk.Y)
        self.canvas.pack(side=tk.LEFT, expand=1, fill=tk.BOTH)

        self.friends_area = self.canvas.create_window((0, 0), window=self.canvas_frame, anchor="nw")

        self.bind_events()

        self.load_friends() 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:20,代碼來源:friendslist.py

示例2: load_friends

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def load_friends(self):
        all_users = self.requester.get_all_users()

        for user in all_users:
            if user['username'] != self.username:
                friend_frame = ttk.Frame(self.canvas_frame)

                profile_photo = tk.PhotoImage(file="images/avatar.png")
                profile_photo_label = ttk.Label(friend_frame, image=profile_photo)
                profile_photo_label.image = profile_photo

                friend_name = ttk.Label(friend_frame, text=user['real_name'], anchor=tk.W)

                message_this_friend = partial(self.open_chat_window, username=user["username"], real_name=user["real_name"])

                message_button = ttk.Button(friend_frame, text="Chat", command=message_this_friend)

                profile_photo_label.pack(side=tk.LEFT)
                friend_name.pack(side=tk.LEFT)
                message_button.pack(side=tk.RIGHT)

                friend_frame.pack(fill=tk.X, expand=1) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:24,代碼來源:friendslist.py

示例3: load_friends

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def load_friends(self):
        friend_frame = ttk.Frame(self.canvas_frame)

        profile_photo = tk.PhotoImage(file="images/avatar.png")
        profile_photo_label = ttk.Label(friend_frame, image=profile_photo)
        profile_photo_label.image = profile_photo

        friend_name = ttk.Label(friend_frame, text="Jaden Corebyn", anchor=tk.W)

        message_button = ttk.Button(friend_frame, text="Chat", command=self.open_chat_window)

        profile_photo_label.pack(side=tk.LEFT)
        friend_name.pack(side=tk.LEFT)
        message_button.pack(side=tk.RIGHT)

        friend_frame.pack(fill=tk.X, expand=1) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:18,代碼來源:friendslist.py

示例4: __init__

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def __init__(self, master):
        self.master = master
        self.notebk = ttk.Notebook(self.master)
        self.notebk.pack()
        self.frame1 = ttk.Frame(self.notebk, width = 400, height = 400, relief = tk.SUNKEN)
        self.frame2 = ttk.Frame(self.notebk, width = 400, height = 400, relief = tk.SUNKEN)
        self.notebk.add(self.frame1, text = 'One')
        self.notebk.add(self.frame2, text = 'Two')
        
        self.btn = ttk.Button(self.frame1, text='Add/Insert Tab at Position 1', command = self.AddTab)
        self.btn.pack()
        
        self.btn2 = ttk.Button(self.frame1, text='Disable Tab at Position 1', command = self.disableTab)
        self.btn2.pack()

        strdisplay = r'Tab ID:{}'.format(self.notebk.select())
        ttk.Label(self.frame1, text = strdisplay).pack()
        
        strdisplay2 = 'Tab index:{}'.format(self.notebk.index(self.notebk.select()))
        ttk.Label(self.frame1, text = strdisplay2).pack() 
開發者ID:adipandas,項目名稱:python-gui-demos,代碼行數:22,代碼來源:program12.py

示例5: create_parameters_frame

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def create_parameters_frame(self, parent):
        parameters = ttk.Frame(master=parent, padding=STANDARD_MARGIN)
        parameters.grid(sticky='nsew')

        heading = ttk.Label(parameters, text='Analysis parameters')
        heading.grid(column=0, row=0, sticky='n')

        for i, param in enumerate(self.parameters, start=1):
            param_label = ttk.Label(parameters, text=param._name)
            param_label.grid(row=i, column=0, sticky='nsew')
            if type(param) == tk.BooleanVar:
                param_entry = ttk.Checkbutton(parameters, variable=param)
            elif hasattr(param, '_choices'):
                param_entry = ttk.OptionMenu(parameters, param, param.get(),
                                             *param._choices.keys())
            else:
                param_entry = ttk.Entry(parameters, textvariable=param)
            param_entry.grid(row=i, column=1, sticky='nsew') 
開發者ID:jni,項目名稱:skan,代碼行數:20,代碼來源:gui.py

示例6: __init__

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def __init__(self, root, resource_dir, lang="fr"):
        ttk.Frame.__init__(self, root)
        
        self.resource_dir = resource_dir
        self._lang = None
        langs = os.listdir(os.path.join(self.resource_dir, "master"))
        if langs:
            self._lang = (lang if lang in langs else langs[0])
        
        self.items = (os.listdir(os.path.join(self.resource_dir, "master", self._lang)) if self._lang else [])
        self.items.sort(key=lambda x: x.lower())
        max_length = max([len(item) for item in self.items])
        
        self.select_workflow_label = ttk.Label(root, text=u"select workflow:")
        #strVar = tkinter.StringVar()
        self.masters = tkinter.Listbox(root, width=max_length+1, height=len(self.items))#, textvariable=strVar)

        for item in self.items:
            self.masters.insert(tkinter.END, item) 
開發者ID:YoannDupont,項目名稱:SEM,代碼行數:21,代碼來源:components.py

示例7: create_widgets

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def create_widgets(self, master):
        self.frame = ttk.Frame(master)
        self.restoreFrame = ttk.Labelframe(self.frame, text="Restore")
        self.restoreWindowCheckbutton = TkUtil.Checkbutton(
                self.restoreFrame, text="Window Position and Size",
                underline=0, variable=self.restoreWindow)
        TkUtil.Tooltip.Tooltip(self.restoreWindowCheckbutton,
                "Restore Toolbars and Window Position and Size at Startup")
        self.restoreFontCheckbutton = TkUtil.Checkbutton(self.restoreFrame,
                text="Font Settings", underline=0,
                variable=self.restoreFont)
        TkUtil.Tooltip.Tooltip(self.restoreFontCheckbutton,
                "Restore the Last Used Font Settings at Startup")
        self.restoreSessionCheckbutton = TkUtil.Checkbutton(
                self.restoreFrame, text="Session", underline=0,
                variable=self.restoreSession)
        TkUtil.Tooltip.Tooltip(self.restoreSessionCheckbutton,
                "Open the Last Edited File at Startup")
        self.otherFrame = ttk.Labelframe(self.frame, text="Other")
        self.blinkCheckbutton = TkUtil.Checkbutton(self.otherFrame,
                text="Blinking Cursor", underline=0, variable=self.blink)
        TkUtil.Tooltip.Tooltip(self.blinkCheckbutton,
                "Switch Cursor Blink On or Off") 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:25,代碼來源:Preferences.py

示例8: create_statusbar

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def create_statusbar(self):
        statusBar = ttk.Frame(self.master)
        statusLabel = ttk.Label(statusBar, textvariable=self.statusText)
        statusLabel.grid(column=0, row=0, sticky=(tk.W, tk.E))
        self.modifiedLabel = ttk.Label(statusBar, relief=tk.SUNKEN,
                anchor=tk.CENTER)
        self.modifiedLabel.grid(column=1, row=0, pady=2, padx=1)
        TkUtil.Tooltip.Tooltip(self.modifiedLabel,
                text="MOD if the text has unsaved changes")
        self.positionLabel = ttk.Label(statusBar, relief=tk.SUNKEN,
                anchor=tk.CENTER)
        self.positionLabel.grid(column=2, row=0, sticky=(tk.W, tk.E),
                pady=2, padx=1)
        TkUtil.Tooltip.Tooltip(self.positionLabel,
                text="Current line and column position")
        ttk.Sizegrip(statusBar).grid(row=0, column=4, sticky=(tk.S, tk.E))
        statusBar.columnconfigure(0, weight=1)
        statusBar.grid(row=2, column=0, columnspan=3, sticky=(tk.W, tk.E))
        self.set_status_text("Start typing to create a new document or "
                "click File→Open") 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:22,代碼來源:Main.py

示例9: create_toolbar

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def create_toolbar(self):
        self.toolbar = ttk.Frame(self.master)
        newButton = ttk.Button(self.toolbar, text=NEW, takefocus=False,
                image=self.images[NEW], command=self.board.new_game)
        TkUtil.Tooltip.Tooltip(newButton, text="New Game")
        zoomLabel = ttk.Label(self.toolbar, text="Zoom:")
        self.zoomSpinbox = Spinbox(self.toolbar,
                textvariable=self.zoom, from_=Board.MIN_ZOOM,
                to=Board.MAX_ZOOM, increment=Board.ZOOM_INC, width=3,
                justify=tk.RIGHT, validate="all")
        self.zoomSpinbox.config(validatecommand=(
                self.zoomSpinbox.register(self.validate_int), "%P"))
        TkUtil.Tooltip.Tooltip(self.zoomSpinbox, text="Zoom level (%)")
        self.shapeCombobox = ttk.Combobox(self.toolbar, width=8,
                textvariable=self.shapeName, state="readonly",
                values=sorted(Shapes.ShapeForName.keys()))
        TkUtil.Tooltip.Tooltip(self.shapeCombobox, text="Tile Shape")
        TkUtil.add_toolbar_buttons(self.toolbar, (newButton, None,
                zoomLabel, self.zoomSpinbox, self.shapeCombobox))
        self.toolbar.pack(side=tk.TOP, fill=tk.X, before=self.board) 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:22,代碼來源:Main.py

示例10: button_box

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def button_box(self, master):
        """Override to create the dialog's buttons; you must return the
        containing widget"""
        frame = ttk.Frame(master)
        if self.buttons & OK_BUTTON:
            self.acceptButton = self.add_button(frame, "OK", 0, self.__ok,
                    self.default == OK_BUTTON, "<Alt-o>")
        if self.buttons & CANCEL_BUTTON:
            self.add_button(frame, "Cancel", 0, self.__cancel,
                    self.default == CANCEL_BUTTON, "<Alt-c>")
        if self.buttons & YES_BUTTON:
            self.acceptButton = self.add_button(frame, "Yes", 0, self.__ok,
                    self.default == YES_BUTTON, "<Alt-y>")
        if self.buttons & NO_BUTTON:
            self.add_button(frame, "No", 0, self.__cancel,
                    self.default == NO_BUTTON, "<Alt-n>")
        self.bind("<Return>", self.__ok, "+")
        self.bind("<Escape>", self.__cancel, "+")
        return frame 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:21,代碼來源:Dialog.py

示例11: __create_widgets

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def __create_widgets(self):
        self.dockFrame = ttk.Frame(self, relief=tk.RAISED, padding=PAD)
        self.dockLeftButton = ttk.Button(self.dockFrame,
                image=self.images[DOCKLEFT], style="Toolbutton",
                command=self.dock_left)
        TkUtil.Tooltip.Tooltip(self.dockLeftButton, text="Dock Left")
        self.dockRightButton = ttk.Button(self.dockFrame,
                image=self.images[DOCKRIGHT], style="Toolbutton",
                command=self.dock_right)
        TkUtil.Tooltip.Tooltip(self.dockRightButton, text="Dock Right")
        self.dockLabel = ttk.Label(self.dockFrame, text=self.title,
                anchor=tk.CENTER)
        TkUtil.Tooltip.Tooltip(self.dockLabel, text="Drag and drop to "
                "dock elsewhere or to undock")
        self.undockButton = ttk.Button(self.dockFrame,
                image=self.images[UNDOCK], style="Toolbutton",
                command=self.undock)
        TkUtil.Tooltip.Tooltip(self.undockButton, text="Undock")
        self.hideButton = ttk.Button(self.dockFrame,
                image=self.images[HIDE], style="Toolbutton",
                command=lambda *args: self.visible.set(False))
        TkUtil.Tooltip.Tooltip(self.hideButton, text="Hide")
        self.create_widgets() 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:25,代碼來源:Dock.py

示例12: _apply_style

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def _apply_style(self):
        """Apply the scale style to the frame and labels."""
        ttk.Frame.configure(self, style=self._style_name + ".TFrame")
        self.label.configure(style=self._style_name + ".TLabel")
        bg = self.style.lookup('TFrame', 'background', default='light grey')
        for label in self.ticklabels:
            label.configure(style=self._style_name + ".TLabel")
        self.style.configure(self._style_name + ".TFrame",
                             background=self.style.lookup(self._style_name,
                                                          'background',
                                                          default=bg))
        self.style.map(self._style_name + ".TFrame",
                       background=self.style.map(self._style_name, 'background'))
        self.style.configure(self._style_name + ".TLabel",
                             font=self.style.lookup(self._style_name, 'font', default='TkDefaultFont'),
                             background=self.style.lookup(self._style_name, 'background', default=bg),
                             foreground=self.style.lookup(self._style_name, 'foreground', default='black'))
        self.style.map(self._style_name + ".TLabel",
                       font=self.style.map(self._style_name, 'font'),
                       background=self.style.map(self._style_name, 'background'),
                       foreground=self.style.map(self._style_name, 'foreground')) 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:23,代碼來源:tickscale.py

示例13: __init__

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def __init__(self, master=None, callback=None, **kwargs):
        """
        :param master: master widget
        :type master: widget
        :param callback: callback passed argument
                         (`str` family, `int` size, `bool` bold, `bool` italic, `bool` underline)
        :type callback: function
        :param kwargs: keyword arguments passed on to the :class:`ttk.Frame` initializer
        """
        ttk.Frame.__init__(self, master, **kwargs)
        self.__callback = callback
        self._family = None
        self._size = 11
        self._bold = False
        self._italic = False
        self._underline = False
        self._overstrike = False
        self._family_dropdown = FontFamilyDropdown(self, callback=self._on_family)
        self._size_dropdown = FontSizeDropdown(self, callback=self._on_size, width=4)
        self._properties_frame = FontPropertiesFrame(self, callback=self._on_properties, label=False)
        self._grid_widgets() 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:23,代碼來源:selectframe.py

示例14: __init__

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def __init__(self, master=None, text="", width=20, compound=tk.LEFT, **kwargs):
        """
        Create a ToggledFrame.

        :param master: master widget
        :type master: widget
        :param text: text to display next to the toggle arrow
        :type text: str
        :param width: width of the closed ToggledFrame (in characters)
        :type width: int
        :param compound: "center", "none", "top", "bottom", "right" or "left":
                         position of the toggle arrow compared to the text
        :type compound: str
        :param kwargs: keyword arguments passed on to the :class:`ttk.Frame` initializer
        """
        ttk.Frame.__init__(self, master, **kwargs)
        self._open = False
        self.__checkbutton_var = tk.BooleanVar()
        self._open_image = ImageTk.PhotoImage(Image.open(os.path.join(get_assets_directory(), "open.png")))
        self._closed_image = ImageTk.PhotoImage(Image.open(os.path.join(get_assets_directory(), "closed.png")))
        self._checkbutton = ttk.Checkbutton(self, style="Toolbutton", command=self.toggle,
                                            variable=self.__checkbutton_var, text=text, compound=compound,
                                            image=self._closed_image, width=width)
        self.interior = ttk.Frame(self, relief=tk.SUNKEN)
        self._grid_widgets() 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:27,代碼來源:toggledframe.py

示例15: show_login_screen

# 需要導入模塊: from tkinter import ttk [as 別名]
# 或者: from tkinter.ttk import Frame [as 別名]
def show_login_screen(self):
        self.login_frame = ttk.Frame(self)

        username_label = ttk.Label(self.login_frame, text="Username")
        self.username_entry = ttk.Entry(self.login_frame)

        real_name_label = ttk.Label(self.login_frame, text="Real Name")
        self.real_name_entry = ttk.Entry(self.login_frame)

        login_button = ttk.Button(self.login_frame, text="Login", command=self.login)
        create_account_button = ttk.Button(self.login_frame, text="Create Account", command=self.create_account)

        username_label.grid(row=0, column=0, sticky='e')
        self.username_entry.grid(row=0, column=1)

        real_name_label.grid(row=1, column=0, sticky='e')
        self.real_name_entry.grid(row=1, column=1)

        login_button.grid(row=2, column=0, sticky='e')
        create_account_button.grid(row=2, column=1)

        for i in range(3):
            tk.Grid.rowconfigure(self.login_frame, i, weight=1)
            tk.Grid.columnconfigure(self.login_frame, i, weight=1)

        self.login_frame.pack(fill=tk.BOTH, expand=1) 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Programming-by-Example,代碼行數:28,代碼來源:friendslist.py


注:本文中的tkinter.ttk.Frame方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。