Commit 703b32d7 authored by Martin Drechsler's avatar Martin Drechsler

now warnings appear in windows, and some other very minor changes

parent 670e11b2
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 22 11:46:00 2018
@author: martindrech
"""
from PyQt5.QtWidgets import QMessageBox
def show_warning(text, details_text = ''):
msg = QMessageBox()
msg.setIcon(QMessageBox.Warning)
msg.setText(text)
msg.setWindowTitle("Oh dear")
if details_text:
msg.setDetailedText(details_text)
msg.setStandardButtons(QMessageBox.Ok)
msg.buttonClicked.connect(msgbtn)
retval = msg.exec_()
#print("value of pressed message box button:", retval)
def msgbtn(i):
print("Button pressed is:",i.text())
\ No newline at end of file
......@@ -12,7 +12,7 @@ from PyQt5.QtCore import QTimer
from PyQt5.QtWidgets import (QPushButton, QWidget, QVBoxLayout, QLCDNumber, QProgressBar, QLabel)
import telnetlib
import os
from messages import show_warning
#An example of a class
class anal_control_signal(QWidget):
......@@ -38,7 +38,7 @@ class anal_control_signal(QWidget):
try:
self.AO = daq_AO(self.ch)
except:
print('Analog output %i not found. Daq might not be connected' % self.ch)
show_warning('Analog output %i not found. Daq might not be connected' % self.ch)
......@@ -109,7 +109,8 @@ class anal_control_signal(QWidget):
self.scanLabelValue.setText("%.2f" % self.scan_step + ' V')
except ZeroDivisionError:
self.doScanAction()
print('Oh dear, you might be trying to scan from 0 to 0. Plase never do that again. ')
#print('Oh dear, you might be trying to scan from 0 to 0. Plase never do that again. ')
show_warning('Oh dear, you might be trying to scan from 0 to 0. Plase never do that again.')
def doScanAction(self):
......@@ -142,9 +143,10 @@ class anal_control_signal(QWidget):
if self.scan_step > b or self.scan_step < a:
print('scan can not start outside scan range and scan start should be lower than scan stop')
details = 'Remember remember the fifth of November.' + '\n' + 'Also remember that scan starts from the value of the corresponding spin box'
show_warning('Scan can not start outside scan range and scan start should be lower than scan stop', details_text= details)
elif n < 5:
print('%i steps are too few, you need at least 5 steps' % (n) )
show_warning('%i steps are too few, you need at least 5 steps' % (n) )
pass
else:
self.sb.setEnabled(False)
......@@ -171,7 +173,7 @@ class digital_control_signal(QWidget):
try:
self.DO = daq_DO(self.ch)
except:
print('Digital output %i not found. Daq might not be connected' % self.ch)
show_warning('Digital output %i not found. Daq might not be connected' % self.ch)
self.cb = QtGui.QCheckBox()
self.cb.stateChanged.connect(self.whenChangeDigital)
......@@ -210,9 +212,15 @@ class burleighWM(QWidget):
wavemeter_ok = False
try:
tn = telnetlib.Telnet(host = "wannanosaurus", port = 1234, timeout = 1)
wavemeter_ok = True
except:
print('wannanosaurus not connected')
show_warning('Wannanosaurus not connected')
if tn.sock_avail():
wavemeter_ok = True
else:
show_warning('Wannanosaurus seems connected but WM might be off.')
if wavemeter_ok:
tn.write(b'++eos 1\n')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment