pimped the RelativeScreenPosition enum
authorConstantin Berhard <git.mail.enormator@xoxy.net>
Tue, 7 Jul 2015 12:50:40 +0000 (14:50 +0200)
committerConstantin Berhard <git.mail.enormator@xoxy.net>
Tue, 28 Jul 2015 10:29:30 +0000 (12:29 +0200)
qt_dialogue.py
screen.py

index 96c04a73e74c6e3f9a6e2205d5b1c7a47a8da727..26f6717df32a95b82531fe899c04c6e56cc4ffc6 100644 (file)
@@ -18,15 +18,6 @@ import os
 from screen import RelativeScreenPosition, ScreenSetup
 from PyQt4 import QtCore, QtGui, uic
 
 from screen import RelativeScreenPosition, ScreenSetup
 from PyQt4 import QtCore, QtGui, uic
 
-relPosNames = {
-    RelativeScreenPosition.LEFT: "left of",
-    RelativeScreenPosition.RIGHT: "right of",
-    RelativeScreenPosition.ABOVE: "above",
-    RelativeScreenPosition.BELOW: "below",
-    RelativeScreenPosition.MIRROR: "same as",
-}
-
-
 class PositionSelection(QtGui.QDialog):
     def __init__(self, situation):
         # set up main window
 class PositionSelection(QtGui.QDialog):
     def __init__(self, situation):
         # set up main window
@@ -37,7 +28,7 @@ class PositionSelection(QtGui.QDialog):
         
         # fill relative position box
         for pos in RelativeScreenPosition:
         
         # fill relative position box
         for pos in RelativeScreenPosition:
-            self.relPos.addItem(relPosNames[pos], pos)
+            self.relPos.addItem(pos.text, pos)
         
         # keep resolutions in sync when in mirror mode
         def syncIfMirror(source, target):
         
         # keep resolutions in sync when in mirror mode
         def syncIfMirror(source, target):
index 78eafa16f939c6ef3630f1c3a793dd13f04a9f5d..d567912d6c952691263bf7d1e289b0dd47b09a86 100644 (file)
--- a/screen.py
+++ b/screen.py
@@ -36,11 +36,16 @@ def processOutputIt(*args):
 
 class RelativeScreenPosition(Enum):
     '''Represents the relative position of the external screen to the internal one'''
 
 class RelativeScreenPosition(Enum):
     '''Represents the relative position of the external screen to the internal one'''
-    LEFT      = 0
-    RIGHT     = 1
-    ABOVE     = 2
-    BELOW     = 3
-    MIRROR    = 4
+    LEFT      = ("left of")
+    RIGHT     = ("right of")
+    ABOVE     = ("above")
+    BELOW     = ("below")
+    MIRROR    = ("same as")
+    def __init__(self, text):
+        # auto numbering
+        cls = self.__class__
+        self._value_ = len(cls.__members__)
+        self.text = text
 
 
 class Resolution:
 
 
 class Resolution: