官术网_书友最值得收藏!

How to do it...

This snippet creates a main window with a custom title and icon. It has 400px of width by 200px of height, with a separation of 10px in each axis to the upper-left corner of the screen:

import tkinter as tk 
 
class App(tk.Tk): 
    def __init__(self): 
        super().__init__() 
        self.title("My Tkinter app") 
        self.iconbitmap("python.ico") 
        self.geometry("400x200+10+10") 
 
if __name__ == "__main__": 
    app = App() 
    app.mainloop()

This program assumes that you have a valid ICO file called python.ico in the same directory where the script is placed and executed.

主站蜘蛛池模板: 邯郸县| 抚松县| 宁德市| 通江县| 易门县| 景东| 万全县| 辽阳市| 伊春市| 盘锦市| 江孜县| 靖远县| 阜新| 六盘水市| 盐亭县| 宁化县| 宝清县| 长海县| 伊金霍洛旗| 沂南县| 沧州市| 临澧县| 安达市| 卫辉市| 恭城| 洪洞县| 攀枝花市| 苏州市| 金川县| 巴马| 桑日县| 青铜峡市| 集贤县| 扶余县| 庆安县| 海伦市| 繁峙县| 鱼台县| 江油市| 石渠县| 贵州省|