Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Raspbery Pi 4上的两个全屏tkinter窗口位于单独的监视器上_Python_Tkinter_Raspberry Pi_Tk_Raspberry Pi4 - Fatal编程技术网

Python Raspbery Pi 4上的两个全屏tkinter窗口位于单独的监视器上

Python Raspbery Pi 4上的两个全屏tkinter窗口位于单独的监视器上,python,tkinter,raspberry-pi,tk,raspberry-pi4,Python,Tkinter,Raspberry Pi,Tk,Raspberry Pi4,我有一个简单的TK应用程序,可以在一个显示器上运行全屏,但现在我想运行两个全屏窗口,一个在Raspberry Pi 4上的每个显示器上。这两个显示器有不同的分辨率,各自工作正常,但我无法让两个全屏窗口工作,两个窗口都只在第一个显示器上全屏显示 我正在尝试使用tkinter.Tk().geometry(),是这样做的,还是有更简单的方法 import tkinter root = tkinter.Tk() # specify resolutions of both windows w0, h0

我有一个简单的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
允许您确保它们不重叠,然后
全屏
按预期工作

geometry
字符串的格式为:
x+xoffset+yoffset

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}+0+0")
win0.attributes("-fullscreen", True)

# set up window for display on HDMI 1 
win1 = tkinter.Toplevel()
win1.geometry(f"{w1}x{h1}+{w0}+0") # <- the key is shifting right by w0 here 
win1.attributes("-fullscreen", True)

root.withdraw()  # hide the empty root window
root=tkinter.Tk()
#指定两个窗口的分辨率
w0,h0=38402160
w1,h1=19201080
#设置HDMI 0上的显示窗口
win0=tkinter.Toplevel()
几何体(f“{w0}x{h0}+0+0”)
win0.attributes(“-fullscreen”,True)
#设置HDMI 1上的显示窗口
win1=tkinter.Toplevel()
win1.geometry(f“{w1}x{h1}+{w0}+0”)#