首先,这是我的代码:
class Fillscreen(QtGui.QWidget, Ui_View):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent,)
self.setupUi(self)
def full(self):
self.showMaximized()
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
monitors = selector.getMonitors()
resolutions = selector.getResolution(monitors)
for monitor in monitors:
window = Fillscreen()
window.move(monitor[0],monitor[1])
window.full()
app.exec_()
monitors
看起来像这样:
[(-1280, 0, 0, 1024), (0, 0, 1920, 1080), (1920, 0, 3840, 1080)]
它照原样只创建一个窗口,这是绝对有意义的,因为在每个循环上我都覆盖window
。
为了解决这个问题,我可以手动创建一个window1
,window2
和window3
但是当我不确定监视器数量时该怎么办?
答案 0 :(得分:1)
...
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
ws = []
for i in range(QtGui.QApplication.desktop().screenCount()):
topLeft = QtGui.QApplication.desktop().screenGeometry(i).topLeft()
window = Fillscreen()
window.move(topLeft)
window.full()
ws.append(window)
sys.exit(app.exec_())