<file_sep>from PyQt4.QtGui import QLineEdit, QApplication, QColor, QPalette, QSlider
from PyQt4.QtCore import pyqtSignal, pyqtSlot, pyqtProperty, QState, QStateMachine, QPropertyAnimation
from channel import PyDMChannel

class PyDMSlider(QSlider):
  __pyqtSignals__ = ("send_value_signal(str)",
                     "connected_signal()",
                     "disconnected_signal()", 
                     "no_alarm_signal()", 
                     "minor_alarm_signal()", 
                     "major_alarm_signal()", 
                     "invalid_alarm_signal()")
                     
  #Emitted when the user changes the value.
  send_value_signal = pyqtSignal(str)
  
  def __init__(self, channel=None, parent=None):
    super(PyDMSlider, self).__init__(parent)
    self._channel = channel
    self.valueChanged.connect(self.sendValue)
    self._des_max = None
    self._des_min = None
    self._step = '1'
    self._maxrange = '10'
    self._minrange = '-10'
    self.setupRange(self._step)

  #accounts for the fact that the silider only works with integer numbers
  def mapStepSize(self):
      pass

  def setupRange(self,step_size):
    upper_range_int = int((1/float(step_size))*float(self._maxrange))
    lower_range_int = int((1/float(step_size))*float(self._minrange))
    self.setMaximum(upper_range_int)
    self.setMinimum(lower_range_int)
    
  #step size property
  def getStep(self):
    return str(self._step)

  def setStep(self,value):
    self._step = str(value)

  step = pyqtProperty(str,fget=getStep,fset=setStep)

  #max range property
  def getMaxrange(self):
    return str(self._maxrange)

  def setMaxrange(self,value):
    self._maxrange = str(value)

  maxrange = pyqtProperty(str,fget=getMaxrange,fset=setMaxrange)

  #min range property
  def getMinrange(self):
    return str(self._minrange)

  def setMinrange(self,value):
    self._minrange = str(value)

  minrange = pyqtProperty(str,fget=getMinrange,fset=setMinrange)

  #overwrite wheel event to fire only when slider is in focus
  def wheelEvent(self,event):
    pass
  
  #set slider to new position
  #if the slider is not in focus, dont set slider to new position
  @pyqtSlot(str)
  def receiveValue(self, new_val):
    if not self.hasFocus():
      self.setSliderPosition(int(float(new_val)))

  #send out new value to channel 
  @pyqtSlot()
  def sendValue(self):
    if self.hasFocus():
      val = str(float(self.value())*float(self._step))
      self.send_value_signal.emit(val)

  #false = disconnected, true = connected
  @pyqtSlot(bool)
  def connectionStateChanged(self, connected):
    self.setEnabled(connected)
    if connected:
      self.setupRange(self._step)
    
  def getChannel(self):
    return str(self._channel)
  
  def setChannel(self, value):
    if self._channel != value:
      self._channel = str(value)

  def resetChannel(self):
    if self._channel != None:
      self._channel = None
    
  channel = pyqtProperty(str, getChannel, setChannel, resetChannel)

  def channels(self):
    return [PyDMChannel(address=self.channel, connection_slot=self.connectionStateChanged, value_slot=self.receiveValue, value_signal=self.send_value_signal)]
<file_sep>from qtplugin_base import qtplugin_factory
from checkbox import PyDMCheckbox

PyDMCheckboxPlugin = qtplugin_factory(PyDMCheckbox)

<file_sep># pydm: Python Display Manager
pydm is a PyQt-based framework for building user interfaces for control systems.  The goal is to provide a no-code, drag-and-drop system to make simple screens, as well as a straightforward python framework to build complex applications.

# Prerequisites
* Python 2.7 or 3.5
* Qt 4.8 or higher
* PyQt 4.11 or higher
If you'd like to use Qt Designer (drag-and-drop tool to build interfaces) you'll need to make sure you have the PyQt plugin for Designer installed.  This usually happens automatically when you install PyQt.

# Running the Examples
There are various examples of some of the features of the display manager.
To launch a particular display run 'python pydm.py <filename>'.

There is a 'home' display in the examples directory with buttons to launch all the examples:
run 'python pydm.py examples/home.ui'

There isn't any documentation yet, hopefully looking at the examples can get you started.

#Widget Designer Plugins
pydm widgets are written in Python, and are loaded into Qt Designer via the PyQt Designer Plugin.
If you want to use the pydm widgets in Qt Designer, add the pydm/widgets/ directory to your PYQTDESIGNERPATH environment variable.  Eventually, this will happen automatically in some kind of setup script.<file_sep>from qtplugin_base import qtplugin_factory
from timeplot import PyDMTimePlot

PyDMTimePlotPlugin = qtplugin_factory(PyDMTimePlot)

<file_sep>from qtplugin_base import qtplugin_factory
from shell_command import PyDMShellCommand

PyDMShellCommandPlugin = qtplugin_factory(PyDMShellCommand)

<file_sep>from qtplugin_base import qtplugin_factory
from line_edit import PyDMLineEdit

PyDMLineEditPlugin = qtplugin_factory(PyDMLineEdit)

<file_sep>from qtplugin_base import qtplugin_factory
from related_display_button import PyDMRelatedDisplayButton

PyDMRelatedDisplayButtonPlugin = qtplugin_factory(PyDMRelatedDisplayButton)

<file_sep>from qtplugin_base import qtplugin_factory
from label import PyDMLabel

PyDMLabelPlugin = qtplugin_factory(PyDMLabel)

<file_sep>pyqtgraph>=0.9.10
numpy>=1.11.0
scipy>=0.12.0
pyepics>=3.2.4
requests>=1.1.0
<file_sep>from .label import PyDMLabel
from .pushbutton import PyDMPushButton
from .image import PyDMImageView<file_sep>from qtplugin_base import qtplugin_factory
from embedded_display import PyDMEmbeddedDisplay

PyDMEmbeddedDisplayPlugin = qtplugin_factory(PyDMEmbeddedDisplay)

<file_sep>from qtplugin_base import qtplugin_factory
from waveformtable import PyDMWaveformTable

PyDMWaveformTablePlugin = qtplugin_factory(PyDMWaveformTable)

<file_sep>from qtplugin_base import qtplugin_factory
from image import PyDMImageView

PyDMImageViewPlugin = qtplugin_factory(PyDMImageView)

<file_sep>from qtplugin_base import qtplugin_factory
from slider import PyDMSlider

PyDMSliderPlugin = qtplugin_factory(PyDMSlider)

<file_sep>from PyQt4.QtGui import QPushButton
from PyQt4.QtCore import pyqtSlot, pyqtProperty, QString
import shlex, subprocess

class PyDMShellCommand(QPushButton):
  def __init__(self, command=None, parent=None):
    super(PyDMShellCommand, self).__init__(parent)
    self._command = command
    self.process = None

  def getCommand(self):
    return QString.fromAscii(self._command)

  def setCommand(self, value):
    if self._command != value:
      self._command = str(value)

  def resetCommand(self):
    if self._command is not None:
      self._command = None

  def mouseReleaseEvent(self, mouse_event):
    self.execute_command()
    super(PyDMShellCommand, self).mouseReleaseEvent(mouse_event)

  @pyqtSlot()
  def execute_command(self):
    if self.process is None or self.process.poll() is not None:
      args = shlex.split(self._command)
      self.process = subprocess.Popen(args)
    else:
      print "Command already active."

  command = pyqtProperty("QString", getCommand, setCommand, resetCommand)
<file_sep>from qtplugin_base import qtplugin_factory
from indicator import PyDMIndicator

PyDMIndicatorPlugin = qtplugin_factory(PyDMIndicator)

<file_sep>#!/usr/bin/env python
import sys
from pydm import PyDMApplication

if __name__ == "__main__":
  app = PyDMApplication(sys.argv)
  sys.exit(app.exec_())<file_sep>from qtplugin_base import qtplugin_factory
from waveformplot import PyDMWaveformPlot

PyDMWaveformPlotPlugin = qtplugin_factory(PyDMWaveformPlot)

<file_sep>from qtplugin_base import qtplugin_factory
from pushbutton import PyDMPushButton

PyDMPushButtonPlugin = qtplugin_factory(PyDMPushButton)

