tkinter - ttk.Frame

ttk.Frame

ttk.Frame erzeugen

frame = ttk.Frame(parent, Optionen)

ttk.Frame kennt die Rahmenoptionen borderwidth und relief

ttk.Frame kennt die Standardoptionen: class_, cursor, padding, style und takefocus

Das folgende Programm stellt Frames mit verschiedenen relief-Optionen vor:

Bild der Anwendung
import tkinter as tk
from tkinter import ttk

class A(tk.Tk):
    def __init__(self):
        super().__init__()
        self.geometry("200x300")
        self._createWidgets()

    def _createWidgets(self):
        f = ttk.Frame(self, relief=tk.FLAT, borderwidth=4)
        ttk.Label(f, text='Flat').pack(expand=tk.YES, fill=tk.BOTH, padx=2, pady=2)
        f.pack(expand=tk.YES, fill=tk.BOTH, padx=2, pady=2)

        f = ttk.Frame(self, relief=tk.GROOVE, borderwidth=4)
        ttk.Label(f, text='Groove').pack(expand=tk.YES, fill=tk.BOTH, padx=2, pady=2)
        f.pack(expand=tk.YES, fill=tk.BOTH, padx=2, pady=2)

        f = ttk.Frame(self, relief=tk.RAISED, borderwidth=4)
        ttk.Label(f, text='Raised').pack(expand=tk.YES, fill=tk.BOTH, padx=2, pady=2)
        f.pack(expand=tk.YES, fill=tk.BOTH, padx=2, pady=2)

        f = ttk.Frame(self, relief=tk.RIDGE, borderwidth=4)
        ttk.Label(f, text='Ridge').pack(expand=tk.YES, fill=tk.BOTH, padx=2, pady=2)
        f.pack(expand=tk.YES, fill=tk.BOTH, padx=2, pady=2)

        f = ttk.Frame(self, relief=tk.SOLID, borderwidth=4)
        ttk.Label(f, text='Solid').pack(expand=tk.YES, fill=tk.BOTH, padx=2, pady=2)
        f.pack(expand=tk.YES, fill=tk.BOTH, padx=2, pady=2)

        f = ttk.Frame(self, relief=tk.SUNKEN, borderwidth=4)
        ttk.Label(f, text='Sunken').pack(expand=tk.YES, fill=tk.BOTH, padx=2, pady=2)
        f.pack(expand=tk.YES, fill=tk.BOTH, padx=2, pady=2)

if __name__ == '__main__':
    window = A()
    window.mainloop()

Frame-Methoden

Referenzen

Siehe Auch

https://tcl.tk/man/tcl8.7/TkCmd/ttk_frame.html