![](/img/trans.png)
[英]Python 3 - Is there a way to keep the mouse inside the tkinter window
[英]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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.