如何在 Tkinter 中显示全屏模式?
Tkinter 默认按应用程序窗口大小显示。但是,我们可以使用 attributes('fullscreen', True) 方法显示一个全屏窗口。该方法通常用于为 tkinter 窗口指定 transparentcolor、 alpha、disabled、fullscreen、toolwindow和 topmost等属性。
示例
#Import the tkinter library
from tkinter import *
#Create an instance of tkinter frame
win = Tk()
#Set the geometry
win.geometry("650x250")
#Add a text label and add the font property to it
label= Label(win, text= "Hello World!", font=('Times New Roman bold',20))
label.pack(padx=10, pady=10)
#Create a fullscreen window
win.attributes('-fullscreen', True)
win.mainloop()输出
运行以上代码将在全屏窗口中显示窗口,通过按 Alt + F4 键可以关闭该窗口。

广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP