From: Constantin Berhard Date: Tue, 7 Jul 2015 12:50:40 +0000 (+0200) Subject: pimped the RelativeScreenPosition enum X-Git-Url: https://git.ralfj.de/lilass.git/commitdiff_plain/b098177b57f9e0ed811bbaaad0d8a09486101cd1?hp=21144381bdc37f521916c138522b3cfac3eb3e46 pimped the RelativeScreenPosition enum --- diff --git a/qt_dialogue.py b/qt_dialogue.py index 96c04a7..26f6717 100644 --- a/qt_dialogue.py +++ b/qt_dialogue.py @@ -18,15 +18,6 @@ import os 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 @@ -37,7 +28,7 @@ class PositionSelection(QtGui.QDialog): # 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): diff --git a/screen.py b/screen.py index 78eafa1..d567912 100644 --- 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''' - 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: