Skip to content

Commit

Permalink
BUG: DROWidget - fix Q_ENUMS so axis and reference type are set
Browse files Browse the repository at this point in the history
  • Loading branch information
KurtJacobson committed Feb 23, 2019
1 parent feb776e commit 39c33e1
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions qtpyvcp/widgets/display_widgets/dro_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ def toString(self, ref_type):

class DROWidget(QLabel, VCPWidget, Axis, RefType, Units):

if IN_DESIGNER:
from PyQt5.QtCore import Q_ENUMS
Q_ENUMS(Axis)
Q_ENUMS(RefType)
Q_ENUMS(Units)
from PyQt5.QtCore import Q_ENUMS
Q_ENUMS(Axis)
Q_ENUMS(RefType)
Q_ENUMS(Units)

def __init__(self, parent=None):
super(DROWidget, self).__init__(parent)
Expand All @@ -68,8 +67,6 @@ def __init__(self, parent=None):
self._format = self._imperial_format

self.update(POSITIONS.abs.getValue())
POSITIONS.abs.notify(self.update)

STATUS.program_units.notify(self.onUnitsChanged, 'string')

def update(self, pos):
Expand All @@ -83,22 +80,21 @@ def onUnitsChanged(self, units):
self.update(
getattr(POSITIONS, RefType.toString(self._ref_typ)).getValue())

#==========================================================================
def initialize(self):
getattr(POSITIONS, RefType.toString(self._ref_typ)).notify(self.update)

# ==========================================================================
# Designer property Getters/Setters
#==========================================================================
# ==========================================================================

@Property(RefType)
def referenceType(self):
return self._ref_typ

@referenceType.setter
def referenceType(self, ref_typ):
old_ref_typ = RefType.toString(self._ref_typ)
new_ref_typ = RefType.toString(ref_typ)
self._ref_typ = ref_typ

getattr(POSITIONS, old_ref_typ).signal.disconnect(self.update)
getattr(POSITIONS, new_ref_typ).signal.connect(self.update)
self.update(getattr(POSITIONS, new_ref_typ).getValue())

@Property(Axis)
Expand Down

0 comments on commit 39c33e1

Please # to comment.