import
tkinter
main_window
=
tkinter.Tk()
main_window.iconbitmap(r
"C:\Users\33943\Pictures\Camera Roll\python.ico"
)
main_window.title(
'Python'
)
main_window.geometry(
'900x500'
)
main_window[
'background'
]
=
'#F0F0F0'
# 背景颜色无变化 因为我用取色器取了主窗口的原始颜色
main_window.config(background
=
'white'
)
text
=
tkinter.Label(main_window,text
=
"Hello World"
,bg
=
"white"
,fg
=
"black"
,font
=
(
'Times'
,
20
,
'bold'
,
'italic'
))
text.pack()
button
=
tkinter.Button(main_window,text
=
'关闭'
,command
=
quit)
button.pack(side
=
'bottom'
)
print
(
'电脑屏幕的大小为%sx%s'
%
(main_window.winfo_screenwidth(),main_window.winfo_screenheight()))
main_window.update()
print
(
'窗口的大小为%sx%s'
%
(main_window.winfo_width(),main_window.winfo_height()))
main_window.attributes(
'-topmost'
,
True
)
main_window.attributes(
'-alpha'
,
0.9
)
main_window.maxsize(
1000
,
600
)
main_window.minsize(
800
,
400
)
main_window.mainloop()