简体   繁体   中英

Boxed Text Styling - Python 3.x - Tkinter

I have been looking online for a good few hours on how to achive this 在此处输入图片说明

I remember seeing this somewhere, i'm not sure where if anyone could link it to me or reply with some code that would reproduce this that would be great!

Assuming are referring to the border with the word "Title" in it, that is called a LabelFrame . Both the tkinter and ttk packages define a LabelFrame class.

Example:

# python 2
# import Tkinter as tk
# import ttk

# python 3
import tkinter as tk
from tkinter import ttk


root = tk.Tk()

lf1 = tk.LabelFrame(root, text="Title (tkinter)", width=400, height=100)
lf2 = ttk.LabelFrame(root, text="Title (ttk)", width=400, height=100)
lf1.pack(side="top", fill="both", expand=True, padx=4, pady=4)
lf2.pack(side="top", fill="both", expand=True, padx=4, pady=4)

root.mainloop()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM