Skip to content

Commit

Permalink
Merged in monashkrb/labscript_devices/feature (pull request labscript…
Browse files Browse the repository at this point in the history
…-suite#14)

Updates to camera interface to add icons

Approved-by: Chris Billington <chrisjbillington@gmail.com>
  • Loading branch information
chrisjbillington committed Jun 20, 2017
2 parents a3c67a5 + a8403d6 commit e9bcf03
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 100 deletions.
34 changes: 24 additions & 10 deletions Camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,22 @@ def generate_code(self, hdf5_file):


import os
import sys

if 'PySide' in sys.modules.copy():
from PySide.QtCore import *
from PySide.QtGui import *
else:
from PyQt4.QtCore import *
from PyQt4.QtGui import *

from blacs.tab_base_classes import Worker, define_state
from blacs.tab_base_classes import MODE_MANUAL, MODE_TRANSITION_TO_BUFFERED, MODE_TRANSITION_TO_MANUAL, MODE_BUFFERED

from blacs.device_base_class import DeviceTab

from qtutils import UiLoader
import qtutils.icons

@BLACS_tab
class CameraTab(DeviceTab):
Expand All @@ -144,8 +154,7 @@ def initialise_GUI(self):
port = int(self.settings['connection_table'].find_by_name(self.settings["device_name"]).BLACS_connection)
self.ui.port_label.setText(str(port))

self.ui.is_responding.setVisible(False)
self.ui.is_not_responding.setVisible(False)
self.ui.check_connectivity_pushButton.setIcon(QIcon(':/qtutils/fugue/arrow-circle'))

self.ui.host_lineEdit.returnPressed.connect(self.update_settings_and_check_connectivity)
self.ui.use_zmq_checkBox.toggled.connect(self.update_settings_and_check_connectivity)
Expand Down Expand Up @@ -178,21 +187,26 @@ def initialise_workers(self):

@define_state(MODE_MANUAL, queue_state_indefinitely=True, delete_stale_states=True)
def update_settings_and_check_connectivity(self, *args):
self.ui.saying_hello.setVisible(True)
self.ui.is_responding.setVisible(False)
self.ui.is_not_responding.setVisible(False)
icon = QIcon(':/qtutils/fugue/hourglass')
pixmap = icon.pixmap(QSize(16, 16))
status_text = 'Checking...'
self.ui.status_icon.setPixmap(pixmap)
self.ui.server_status.setText(status_text)
kwargs = self.get_save_data()
responding = yield(self.queue_work(self.primary_worker, 'update_settings_and_check_connectivity', **kwargs))
self.update_responding_indicator(responding)

def update_responding_indicator(self, responding):
self.ui.saying_hello.setVisible(False)
if responding:
self.ui.is_responding.setVisible(True)
self.ui.is_not_responding.setVisible(False)
icon = QIcon(':/qtutils/fugue/tick')
pixmap = icon.pixmap(QSize(16, 16))
status_text = 'Server is responding'
else:
self.ui.is_responding.setVisible(False)
self.ui.is_not_responding.setVisible(True)
icon = QIcon(':/qtutils/fugue/exclamation')
pixmap = icon.pixmap(QSize(16, 16))
status_text = 'Server not responding'
self.ui.status_icon.setPixmap(pixmap)
self.ui.server_status.setText(status_text)

@BLACS_worker
class CameraWorker(Worker):
Expand Down
118 changes: 28 additions & 90 deletions camera.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>909</width>
<width>462</width>
<height>667</height>
</rect>
</property>
Expand All @@ -29,19 +29,6 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>138</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="formGroupBox">
<property name="sizePolicy">
Expand All @@ -50,18 +37,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>300</width>
<height>300</height>
</size>
</property>
<property name="title">
<string>Imaging system server</string>
</property>
Expand Down Expand Up @@ -106,7 +81,7 @@
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_5">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -119,14 +94,21 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="check_connectivity_pushButton">
<widget class="QLabel" name="status_icon">
<property name="text">
<string>Check connectivity</string>
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<widget class="QLabel" name="server_status">
<property name="text">
<string>Server Status</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -138,77 +120,33 @@
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="is_responding" native="true">
<layout class="QHBoxLayout" name="is_responding_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>✓</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Server is responding</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="is_not_responding" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="is_not_responding_2">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>✗</string>
<widget class="QPushButton" name="check_connectivity_pushButton">
<property name="toolTip">
<string>Check connectivity</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Server is not responding</string>
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="saying_hello" native="true">
<layout class="QHBoxLayout" name="saying_hello_2">
<item>
<widget class="QLabel" name="label_8">
<property name="text">
<string>...</string>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Saying hello to server</string>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</widget>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
Expand Down

0 comments on commit e9bcf03

Please sign in to comment.