def __init__(self, device, title, probe=False): if Gui.need_iqt: import cothread cothread.iqt() cothread.input_hook._qapp.setQuitOnLastWindowClosed(False) Gui.need_iqt = False super(Gui, self).__init__() self.device = device self.probe = probe self.make_model() device.add_listener(self.make_model, "attributes.deviceClientConnected.value") # set delegate self.delegate = Delegate() self.setItemDelegateForColumn(1, self.delegate) self.setStyleSheet(style) self.setAlternatingRowColors(True) self.setEditTriggers(self.AllEditTriggers) # show self title = "{}: {}".format(title, device.name) if title.endswith("Client"): title = title[:-len("Client")] self.setWindowTitle(title) self.setColumnWidth(0, 160) self.setColumnWidth(1, 200) self.resize(QSize(365, 800)) self.show()
def pressed(state): import cothread from cothread import catools cothread.iqt(run_exec = False) global label label = QtGui.QLabel('Hello there', None) label.show() catools.camonitor('SR21C-DI-DCCT-01:SIGNAL', signal)
def pressed(state): import cothread from cothread import catools cothread.iqt(run_exec=False) global label label = QtGui.QLabel('Hello there', None) label.show() catools.camonitor('SR21C-DI-DCCT-01:SIGNAL', signal)
def main(): """""" args = sys.argv # If Qt is to be used (for any GUI) then the cothread library needs to # be informed, before any work is done with Qt. Without this line # below, the GUI window will not show up and freeze the program. cothread.iqt() dialog = make(isModal=False, parentWindow=None) cothread.WaitForQuit() print(dialog.config_model.abstract.channel_ids)
def main(): """""" args = sys.argv # If Qt is to be used (for any GUI) then the cothread library needs to # be informed, before any work is done with Qt. Without this line # below, the GUI window will not show up and freeze the program. cothread.iqt() dialog = make(isModal=False, parentWindow=None) cothread.WaitForQuit() print dialog.config_model.abstract.channel_ids
def main(): qapp = cothread.iqt() key_filter = KeyFilter() qapp.installEventFilter(key_filter) # create and show form ui_viewer = uic.loadUi(os.path.join(os.path.dirname(__file__), 'viewer.ui')) # Bind code to form s = Viewer(ui_viewer, server) cothread.WaitForQuit()
def main(args): """ """ #qapp = Qt.QApplication(args) # Necessary whether modal or non-modal #result = make(modal = True, output_type = TYPE_ELEMENT) #if result.has_key('dialog_result'): # When modal #app = result['app'] #dialog_result = result['dialog_result'] #print dialog_result #print 'Length = ', len(dialog_result) #else: # When non-modal #app = result['app'] #exit_status = qapp.exec_() #sys.exit(exit_status) cothread.iqt() result = make(modal=True, output_type=TYPE_ELEMENT) if result.has_key('dialog_result'): # When modal app = result['app'] dialog_result = result['dialog_result'] print dialog_result print 'Length = ', len(dialog_result) else: # When non-modal app = result['app'] #exit_status = qapp.exec_() #sys.exit(exit_status) cothread.WaitForQuit()
def main(args=None): # If Qt is to be used (for any GUI) then the cothread library needs to be informed, # before any work is done with Qt. Without this line below, the GUI window will not # show up and freeze the program. qtapp = cothread.iqt() ''' app = CurrentMonitorApp() window = app.view window.show() ''' app = make() cothread.WaitForQuit()
def main(args=None): # If Qt is to be used (for any GUI) then the cothread library needs to be informed, # before any work is done with Qt. Without this line below, the GUI window will not # show up and freeze the program. qtapp = cothread.iqt() """ app = CurrentMonitorApp() window = app.view window.show() """ app = make() cothread.WaitForQuit()
def main(args): """ """ # qapp = Qt.QApplication(args) # Necessary whether modal or non-modal # result = make(modal = True, output_type = TYPE_ELEMENT) # if result.has_key('dialog_result'): # When modal # app = result['app'] # dialog_result = result['dialog_result'] # print dialog_result # print 'Length = ', len(dialog_result) # else: # When non-modal # app = result['app'] # exit_status = qapp.exec_() # sys.exit(exit_status) cothread.iqt() result = make(modal=True, output_type=TYPE_ELEMENT) if result.has_key("dialog_result"): # When modal app = result["app"] dialog_result = result["dialog_result"] print dialog_result print "Length = ", len(dialog_result) else: # When non-modal app = result["app"] # exit_status = qapp.exec_() # sys.exit(exit_status) cothread.WaitForQuit()
from PyQt5.QtWidgets import QMainWindow, QLabel, QPushButton, QHBoxLayout, QVBoxLayout from PyQt5.QtWidgets import QApplication, QWidget, QAction, QLineEdit, QMessageBox from pyqtgraph import PlotWidget, plot import pyqtgraph as pg # callback for monitoring changes in PVs def print_update(value, index): print(value.name, index, value) # note value is not quite a 'float', but + converts value to a float print(type(value), type(+value)) # Enable Qt processing, hang onto application instance if needed. qtapp = cothread.iqt() # Not needed if not using Qt # monitor a set of PVs pvs = ["chris:offset", "chris:amplitude"] m = camonitor(pvs, print_update) def on_button_clicked(): def update(pv, textbox): value = textbox.text() try: if not value == "": caput(pv, float(value)) except: print(f"Invalid value for {pv}:{value}")
""" EPICS PV Data Monitor ---------------------- """ # :author: Lingyun Yang <*****@*****.**> import numpy as np import cothread if __name__ == "__main__": app = cothread.iqt() from cothread.catools import camonitor, caget from datetime import datetime import threading, time import random from collections import deque from PyQt4 import QtGui, QtCore class CaDataMonitor(QtCore.QObject): def __init__(self, pvs = [], **kwargs): """ - pvs a list of PV - samples number of data points for std/var/average """ super(CaDataMonitor, self).__init__() self.samples = kwargs.get("samples", 10) #self.simulation = kwargs.get('simulation', False)
from replay.model.fitting_model import MultiFitController from enaml.qt.qt_application import QtApplication import enaml from replay.pipeline.pipeline import SocketListener from datetime import datetime, timedelta import os from calendar import timegm import time # this must appear before the cothread import os.environ["EPICS_BASE"] = "/usr/lib/epics" import cothread import cothread.catools as ca cothread.iqt() # set up mugglers # keys = [('s{}'.format(idx), 'ffill', 0) for idx in range(1, 8)] # keys.append(('p0', 'ffill', 0)) PV_TRIGGER = "XF:23ID-CT{Replay}Val:trigger-I" PVS = ["XF:23ID-CT{{Replay}}Val:{}-I".format(idx) for idx in range(0, 4)] dm_keys = [(pv, "ffill", 0) for pv in PVS] dm_keys.append(("count", "ffill", 0)) dm = DataMuggler(dm_keys) count = 1 dm_map = {}
#!/usr/bin/env python '''minimal Qt example''' if __name__ == '__main__': import require import cothread from cothread.catools import * from PyQt4.QtGui import QLabel cothread.iqt() # make a label widget (None is the parent, this is top-level widget) label = QLabel('Hello World', None) label.resize(200, 50) # must show top-level widgets manually label.show() # animate label def signal(value): label.setText('DCCT %f %s' % (value, value.units)) camonitor('SR21C-DI-DCCT-01:SIGNAL', signal, format=FORMAT_CTRL) if __name__ == '__main__': cothread.WaitForQuit()
return self.codes, self.times = [], [] self.msg('Sending...', 4000) cothread.Spawn(self._setpvs, T, C) def _setpvs(self, T, C): pvs = [self.prefix + "EvtCode-SP", self.prefix + "Timestamp-SP"] try: self.enableAll.emit(False) caput(pvs, [C,T], timeout=2.0, wait=True) self.msg("Sent", 2000) except catools.ca_nothing,E: if E.errorcode==cadef.ECA_TIMEOUT: M='Timeout' else: M=cadef.ca_message(E.errorcode) self.msg("Sent failed: "+M, 4000) return finally: self.enableAll.emit(True) if __name__ == '__main__': app = cothread.iqt(argv = sys.argv) softSeq = evgSoftSeq(sys.argv) softSeq.show() cothread.WaitForQuit()
def make_process(): import argparse import logging import cothread cothread.iqt() cothread.input_hook._qapp.setQuitOnLastWindowClosed(False) parser = argparse.ArgumentParser( description="Interactive shell for malcolm") parser.add_argument( '--client', '-c', help="Add a client to given server, like ws://localhost:8080 or pva") parser.add_argument( '--log', default="INFO", help="Lowest level of logs to see. One of: ERROR, WARNING, INFO, DEBUG " "Default is INFO") parser.add_argument( 'yaml', nargs="?", help="The YAML file containing the assemblies to be loaded") args = parser.parse_args() # assuming loglevel is bound to the string value obtained from the # command line argument. Convert to upper case to allow the user to # specify --log=DEBUG or --log=debug numeric_level = getattr(logging, args.log.upper(), None) if not isinstance(numeric_level, int): raise ValueError('Invalid log level: %s' % args.log) logging.basicConfig(level=numeric_level) from malcolm.core import SyncFactory, Process from malcolm.assemblyutil import make_assembly from malcolm.gui.blockgui import BlockGui proc = Process("Process", SyncFactory("Sync")) guis = {} if args.yaml: with open(args.yaml) as f: assembly = make_assembly(f.read()) assembly(proc, {}) def gui(block): if block in guis: guis[block].show() else: guis[block] = BlockGui(proc, block) return guis[block] if args.client: if args.client.startswith("ws://"): from malcolm.comms.websocket import WebsocketClientComms hostname, port = args.client[5:].split(":") WebsocketClientComms(proc, dict(hostname=hostname, port=int(port))) else: raise ValueError("Don't know how to create client to %s" % args.client) return proc, gui
def main(): app = cothread.iqt() ex = MainWin() ex.show() cothread.WaitForQuit()
#!/usr/bin/env from __future__ import print_function, division, absolute_import import cothread from cothread.catools import caput, caget, camonitor app = cothread.iqt() from PyQt4.QtCore import (PYQT_VERSION_STR, QFile, QFileInfo, QSettings, QObject, QString, QT_VERSION_STR, QTimer, QVariant, Qt, SIGNAL, QSize, QRectF) from PyQt4.QtGui import ( QAction, QActionGroup, QApplication, QWidget, QDockWidget, QFileDialog, QFrame, QIcon, QImage, QImageReader, QImageWriter, QInputDialog, QKeySequence, QLabel, QListWidget, QMainWindow, QMessageBox, QPainter, QPixmap, QPrintDialog, QPrinter, QDoubleSpinBox, QPen, QBrush, QVBoxLayout, QTabWidget, QTableWidget, QTableWidgetItem, QDialog, QHBoxLayout, QDialogButtonBox, QGridLayout, QItemDelegate, QStandardItemModel, QPushButton, QLineEdit, QTableView, QAbstractItemView) class PvTunerDlg(QDialog): COL = 6 COL_ELEMENT = 0 COL_FIELD = 1 COL_PV = 2 COL_STEPSIZE = 3 COL_READBACK = 4 COL_SETPOINT = 5 FMT_READBACK = "%.4e"
def main(): cothread.iqt() the_ui = AccelGui() the_ui.ui.show() cothread.WaitForQuit()