我有一个简单的TK应用程序,可以在一个显示器上运行全屏,但现在我想运行两个全屏窗口,一个在Raspberry Pi 4上的每个显示器上。这两个显示器有不同的分辨率,各自工作正常,但我无法让两个全屏窗口工作,两个窗口都只在第一个显示器上全屏显示
我正试图用tkinter.Tk().geometry()
来做这件事,是这样做的还是有更直接的方法
import tkinter
root = tkinter.Tk()
# specify resolutions of both windows
w0, h0 = 3840, 2160
w1, h1 = 1920, 1080
# set up window for display on HDMI 0
win0 = tkinter.Toplevel()
win0.geometry(f"{w0}x{h0}")
win0.attributes("-fullscreen", True)
win0.config(cursor="none") # remove cursor
win0.wm_attributes("-topmost", 1) # make sure this window is on top
# set up window for display on HDMI 1
win1 = tkinter.Toplevel()
win1.geometry(f"{w1}x{h1}")
win1.attributes("-fullscreen", True)
win1.config(cursor="none")
win1.wm_attributes("-topmost", 1)
您必须将第二个窗口向右偏移第一个显示器的宽度(X系统首先将显示器放置在
HDMI0
端口上,然后将显示器从HDMI1
放置到右侧)。geometry
允许您确保它们不重叠,然后fullscreen
按预期工作geometry
字符串的格式为:<width>x<height>+xoffset+yoffset
相关问题 更多 >
编程相关推荐