簡體   English   中英

Python:有沒有辦法改變 tkinter 窗口形狀?

[英]Python: Is there a way to change the tkinter window shape?

我使用 tkinter 創建了一個無邊框窗口,我想知道是否有辦法將形狀更改為圓角矩形? 以及使按鈕也圓潤? 這是我當前的代碼:

from tkinter import *
import tkinter as tk


root = tk.Tk()
root.overrideredirect(1)
window_width = root.winfo_reqwidth()
window_height = root.winfo_reqheight()
print("Width", window_width, "Height", window_height)
# Change the position of the window on screen
position_right = int(root.winfo_screenwidth() / 2 - window_width / 2)
position_down = int(root.winfo_screenheight() / 2 - window_height / 2)
root.geometry("+{}+{}".format(position_right, position_down))
# Change how it looks look into changing the shape and any animations we could add
frame = Frame(root, width=500, height=150,
                           borderwidth=2, relief=RAISED, bg="#0D0E50")
frame.pack_propagate(False)
frame.pack()
b_minimize = Button(frame, text="<", height=10, bg="light blue", fg="white", borderwidth=1, command=root.quit())
b_minimize.place(x=0, y=0)


root.mainloop()

嗨,我認為這可以幫助您:

tkinter 中不同形狀的窗口

Tkinter 的非標准窗口?

更改按鈕樣式的一個簡單方法是使用圖片!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM