2 from PyQt4 import QtGui
4 class PositionSelection(QtGui.QDialog):
9 def __init__(self, resolutions):
10 super(PositionSelection, self).__init__()
12 mainBox = QtGui.QVBoxLayout()
13 posBox = QtGui.QHBoxLayout()
14 resBox = QtGui.QHBoxLayout()
16 # First row: Resolution selection
17 mainBox.addLayout(resBox)
18 resBox.addWidget(QtGui.QLabel('Select the resolution of the external screen:'))
19 self.resolutions = QtGui.QComboBox(self)
20 for res in resolutions:
21 self.resolutions.addItem(res)
22 self.resolutions.setCurrentIndex(0) # select first resolution
23 resBox.addWidget(self.resolutions)
25 # Next two rows: Position selection
26 mainBox.addWidget(QtGui.QLabel('Select the position of the external screen relative to the internal one:'))
27 mainBox.addLayout(posBox)
29 btn = QtGui.QPushButton('Left', self)
30 btn.clicked.connect(self.left)
33 btn = QtGui.QPushButton('Right', self)
34 btn.clicked.connect(self.right)
38 btn = QtGui.QPushButton('External only', self)
39 btn.clicked.connect(self.externalOnly)
43 self.setLayout(mainBox)
44 self.setWindowTitle('External screen setup')
47 self.resolution = str(self.resolutions.currentText())
48 super(PositionSelection, self).accept()
51 self.position = PositionSelection.LEFT
55 self.position = PositionSelection.RIGHT
58 def externalOnly(self):
59 self.position = PositionSelection.EXTERNAL_ONLY