Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to set the window shape in Python

Shulou Source: shulou.com Published: 2022-06-02 06:25:04 09月30日 Update

Python how to set the shape of the window, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

1. Set the value of transparency # Transparency: 0x1 can also be a decimal point, 0: fully transparent; 1: fully opaque root.attributes ("- alpha", 0.6) 2. Set toolbar style # True has an exit button and no icon; False's normal form style root.attributes ("- toolwindow", True) 3. Set full screen

# True full screen; False normally displays root.attributes ("- fullscreen", True) 4. Window Top # True all windows are at the top level; False normally shows that two windows that are topped at the same time are of the same level (can cover each other), but they can both cover windows that are not set to the top at the same time. Root.attributes ("- topmost", True) 5. Set to detach from the toolbar # True has no toolbar buttons False normally displays root.overrideredirect (True) complete code # Import module, alias import tkinter as tk # instantiate a form object root = tk.Tk () # set the size, length and width of the window to the upper left corner of the window + 150mm 150 root.geometry ("300x300+150+150") # set the window title root.title ("title") # set the icon, take the OneDrive icon as an example, it must be an icon file with the suffix .ico Put it in the same directory. Root.iconbitmap ("OneDrive.ico") # sets the background color, either in English or hexadecimal. Root ["background"] = "# 00ffff" # True full screen; False normally displays root.attributes ("- fullscreen", True) # True is at the top of all windows; False normally shows that two windows that are roofed at the same time are at the same level (can cover each other), but they can both cover windows that are not set to the top at the same time. Root.attributes ("- topmost", True) # True does not have a toolbar button; False normally displays root.overrideredirect (True) # to enter the message loop and display window root.mainloop () after reading the above, have you mastered the method of how to set the shape of the window in Python? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: At the same time icons tools toolbars buttons shapes two content siblings methods more styles forms transparency problems top-level helpless for this code location Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MariaDB Huawei NVidia OPPO Reno