Initial commit
[lilass.git] / selector_window.py
1 #!/usr/bin/python
2 from PyQt4 import QtGui
3
4 class PositionSelection(QtGui.QDialog):
5         LEFT = 10
6         RIGHT = 20
7         EXTERNAL_ONLY = 30
8         
9         def __init__(self, resolutions):
10                 super(PositionSelection, self).__init__()   
11                 
12                 mainBox = QtGui.QVBoxLayout()
13                 posBox = QtGui.QHBoxLayout()
14                 resBox = QtGui.QHBoxLayout()
15                 
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)
24                 
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)
28
29                 btn = QtGui.QPushButton('Left', self)
30                 btn.clicked.connect(self.left)
31                 posBox.addWidget(btn)
32
33                 btn = QtGui.QPushButton('Right', self)
34                 btn.clicked.connect(self.right)
35                 btn.setFocus()
36                 posBox.addWidget(btn)
37
38                 btn = QtGui.QPushButton('External only', self)
39                 btn.clicked.connect(self.externalOnly)
40                 posBox.addWidget(btn)
41
42                 # Finalization
43                 self.setLayout(mainBox)
44                 self.setWindowTitle('External screen setup')
45         
46         def accept(self):
47                 self.resolution = str(self.resolutions.currentText())
48                 super(PositionSelection, self).accept()  
49         
50         def left(self):
51                 self.position = PositionSelection.LEFT
52                 self.accept()
53         
54         def right(self):
55                 self.position = PositionSelection.RIGHT
56                 self.accept()
57         
58         def externalOnly(self):
59                 self.position = PositionSelection.EXTERNAL_ONLY
60                 self.accept()