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

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.

主站蜘蛛池模板: 久治县| 乌鲁木齐市| 建昌县| 额尔古纳市| 南澳县| 岢岚县| 贵定县| 洮南市| 乳山市| 通山县| 文化| 辽阳市| 新昌县| 岱山县| 高淳县| 开封县| 开江县| 恩施市| 隆尧县| 绥阳县| 贵南县| 朝阳市| 灵武市| 榆林市| 南漳县| 曲阜市| 阿巴嘎旗| 大城县| 普兰县| 遂平县| 眉山市| 同江市| 同德县| 本溪市| 昌黎县| 淮滨县| 鄂伦春自治旗| 和顺县| 永修县| 永嘉县| 来凤县|