def __init__(self, channel, address, protocol=None, parent=None): super(Connection, self).__init__(channel, address, protocol, parent) self.app = QApplication.instance() # Default Values self.server = None self.ip = '127.0.0.1' self.port = '502' self.slave_id = 0 self.designator = 'HR' self.addr = 0 self.length = 0 self.bit = None self.poll = 0.1 # 100 ms self.parse_address(address) self.add_listener(channel) self.data_thread = DataThread(self.ip, self.port, self.slave_id, self.designator, self.addr, self.length, self.bit, self.poll) self.data_thread.new_data_signal.connect(self.emit_data, Qt.QueuedConnection) self.data_thread.start() self.metadata_timer = QTimer() self.metadata_timer.setInterval(500) self.metadata_timer.timeout.connect(self.emit_metadata) self.metadata_timer.start()
def __init__(self, channel, address, protocol=None, parent=None): super().__init__(channel, address, protocol, parent) self.app = QApplication.instance() self._closed = False self.addr_info = parse_address(address) self.host = self.addr_info['host'] self.port = self.addr_info['port'] self.poll_rate = self.addr_info['poll_rate'] self.parameter = self.addr_info['parameter'] self.client = get_client(self.host, self.port, loop=None) self.add_listener(channel) data_cls = self.addr_info['data_class'] self.poller = data_cls(self, self.client, self.parameter, poll_rate=self.poll_rate) self.poller.new_data_signal.connect(self.emit_data, Qt.QueuedConnection) self.poller.new_severity_signal.connect(self.emit_severity, Qt.QueuedConnection) self.metadata_timer = QTimer() self.metadata_timer.setInterval(1000) self.metadata_timer.timeout.connect(self.emit_metadata) self.metadata_timer.start()
def use_stylesheet(dark=False): """ Use the Typhon stylesheet Parameters ---------- dark: bool, optional Whether or not to use the QDarkStyleSheet theme. By default the light theme is chosen. """ # Dark Style if dark: import qdarkstyle style = qdarkstyle.load_stylesheet_pyqt5() # Light Style else: # Load the path to the file style_path = os.path.join(ui_dir, 'style.qss') if not os.path.exists(style_path): raise EnvironmentError("Unable to find Typhon stylesheet in {}" "".format(style_path)) # Load the stylesheet from the file with open(style_path, 'r') as handle: style = handle.read() # Find application app = QApplication.instance() # Set Fusion style app.setStyle(QStyleFactory.create('Fusion')) # Set Stylesheet app.setStyleSheet(style)
def __init__(self, parent=None, args=[], macros=None): super(AllMotorsDisplay, self).__init__(parent=parent, args=args, macros=None) # Placeholder for data to filter self.data = [] # Reference to the PyDMApplication self.app = QApplication.instance() # Assemble the Widgets self.setup_ui() # Load data from file self.load_data()
def use_stylesheet(): """ Use the Typhon stylesheet """ # Load the path to the file style_path = os.path.join(ui_dir, 'style.qss') if not os.path.exists(style_path): raise EnvironmentError("Unable to find Typhon stylesheet in {}" "".format(style_path)) # Load the stylesheet from the file with open(style_path, 'r') as handle: app = QApplication.instance() app.setStyleSheet(handle.read())
def __init__(self, channel, pv, protocol=None, parent=None): super(Connection, self).__init__(channel, pv, protocol, parent) self.app = QApplication.instance() self.pv = epics.PV(pv, connection_callback=self.send_connection_state, form='ctrl', auto_monitor=True, access_callback=self.send_access_state) self.pv.add_callback(self.send_new_value, with_ctrlvars=True) self.add_listener(channel) self._severity = None self._precision = None self._enum_strs = None self._unit = None self._upper_ctrl_limit = None self._lower_ctrl_limit = None
def add_curve(self, channel, name=None, color=None): """ Add a curve to the plot Parameters ---------- channel : str PyDMChannel address name : str, optional Name of TimePlotCurveItem. If None is given, the ``channel`` is used. color: QColor, optional Color to display line in plot. If None is given, a QColor will be chosen randomly """ name = name or channel # Do not allow duplicate channels if name in self.channel_map: logger.error("%r already has been added to the plot", name) return logger.debug("Adding %s to plot ...", channel) # Create a random color if None is supplied if not color: color = random_color() # Add to plot self.ui.timeplot.addYChannel(y_channel=channel, color=color, name=name, lineStyle=Qt.SolidLine, lineWidth=2, symbol=None) # Add a display to the LiveChannel display ch_display = ChannelDisplay(name, color) self.ui.live_channels.layout().insertWidget(0, ch_display) self.channel_map[name] = ch_display # Connect the removal button to the slot ch_display.remove_button.clicked.connect( partial(self.remove_curve, name)) # Establish connections for new instance pydm_app = QApplication.instance() pydm_app.establish_widget_connections(self) # Select new random color self.ui.color.brush = QBrush(random_color(), Qt.SolidPattern)