diff --git a/python/tdstatv3.py b/python/tdstatv3.py index 2d44c35..e442415 100644 --- a/python/tdstatv3.py +++ b/python/tdstatv3.py @@ -9,7 +9,7 @@ # License: GPL import pyqtgraph -from pyqtgraph.Qt import QtCore, QtGui +from pyqtgraph.Qt import QtCore, QtGui, QtWidgets import sys, platform import time, datetime, timeit import usb.core, usb.util @@ -46,7 +46,7 @@ if platform.system() != "Windows": # On Linux/OSX, use the Qt timer busyloop_interval = 0 - qt_timer_period = 1e3*adcread_interval # convert to ms + qt_timer_period = int(1e3*adcread_interval) # convert to ms else: # On MS Windows, system timing is inaccurate, so use a busy loop instead busyloop_interval = adcread_interval @@ -189,10 +189,10 @@ def charge_from_cv(time_arr, current_arr): def make_groupbox_indicator(title_name, default_text): """Make a GUI box (used for the potential, current, and status indicators).""" - label = QtGui.QLabel(text=default_text, alignment=QtCore.Qt.AlignCenter) - box = QtGui.QGroupBox(title=title_name, flat=False) + label = QtWidgets.QLabel(text=default_text, alignment=QtCore.Qt.AlignCenter) + box = QtWidgets.QGroupBox(title=title_name, flat=False) format_box_for_display(box) - layout = QtGui.QVBoxLayout() + layout = QtWidgets.QVBoxLayout() layout.addWidget(label, 0, alignment=QtCore.Qt.AlignCenter) layout.setSpacing(0) layout.setContentsMargins(30,3,30,0) @@ -201,7 +201,7 @@ def make_groupbox_indicator(title_name, default_text): def add_my_tab(tab_frame, tab_name): """Add a tab to the tab view.""" - widget = QtGui.QWidget() + widget = QtWidgets.QWidget() tab_frame.addTab(widget, tab_name) return widget @@ -219,9 +219,9 @@ def format_box_for_parameter(box): def make_label_entry(parent, labelname): """Make a labelled input field for parameter input.""" - hbox = QtGui.QHBoxLayout() - label = QtGui.QLabel(text=labelname) - entry = QtGui.QLineEdit() + hbox = QtWidgets.QHBoxLayout() + label = QtWidgets.QLabel(text=labelname) + entry = QtWidgets.QLineEdit() hbox.addWidget(label) hbox.addWidget(entry) parent.addLayout(hbox) @@ -253,7 +253,7 @@ def connect_disconnect_usb(): usb_pid_string = str(hardware_usb_pid.text()) dev = usb.core.find(idVendor=int(usb_vid_string, 0), idProduct=int(usb_pid_string, 0)) if dev is None: - QtGui.QMessageBox.critical(mainwidget, "USB Device Not Found", "No USB device was found with VID %s and PID %s. Verify the vendor/product ID and check the USB connection."%(usb_vid_string,usb_pid_string)) + QtWidgets.QMessageBox.critical(mainwidget, "USB Device Not Found", "No USB device was found with VID %s and PID %s. Verify the vendor/product ID and check the USB connection."%(usb_vid_string,usb_pid_string)) else: hardware_usb_connectButton.setText("Disconnect") log_message("USB Interface connected.") @@ -269,7 +269,7 @@ def connect_disconnect_usb(): def not_connected_errormessage(): """Generate an error message stating that the device is not connected.""" - QtGui.QMessageBox.critical(mainwidget, "Not connected", "This command cannot be executed because the USB device is not connected. Press the \"Connect\" button and try again.") + QtWidgets.QMessageBox.critical(mainwidget, "Not connected", "This command cannot be executed because the USB device is not connected. Press the \"Connect\" button and try again.") def check_state(desired_states): """Check if the current state is in a given list. If so, return True; otherwise, show an error message and return False.""" @@ -277,7 +277,7 @@ def check_state(desired_states): if state == 0: not_connected_errormessage() else: - QtGui.QMessageBox.critical(mainwidget, "Error", "This command cannot be executed in the current state.") + QtWidgets.QMessageBox.critical(mainwidget, "Error", "This command cannot be executed in the current state.") return False else: return True @@ -288,7 +288,7 @@ def send_command(command_string, expected_response, log_msg=None): dev.write(0x01,command_string) # 0x01 = write address of EP1 response = bytes(dev.read(0x81,64)) # 0x81 = read address of EP1 if response != expected_response: - QtGui.QMessageBox.critical(mainwidget, "Unexpected Response", "The command \"%s\" resulted in an unexpected response. The expected response was \"%s\"; the actual response was \"%s\""%(command_string,expected_response.decode("ascii"),response.decode("ascii"))) + QtWidgets.QMessageBox.critical(mainwidget, "Unexpected Response", "The command \"%s\" resulted in an unexpected response. The expected response was \"%s\"; the actual response was \"%s\""%(command_string,expected_response.decode("ascii"),response.decode("ascii"))) else: if log_msg != None: log_message(log_msg) @@ -528,19 +528,19 @@ def set_output_from_gui(): try: value = float(hardware_manual_control_output_entry.text()) except ValueError: - QtGui.QMessageBox.critical(mainwidget, "Not a number", "The value you have entered is not a floating-point number.") + QtWidgets.QMessageBox.critical(mainwidget, "Not a number", "The value you have entered is not a floating-point number.") return elif value_units_index == 1: # Current (mA) try: value = float(hardware_manual_control_output_entry.text()) except ValueError: - QtGui.QMessageBox.critical(mainwidget, "Not a number", "The value you have entered is not a floating-point number.") + QtWidgets.QMessageBox.critical(mainwidget, "Not a number", "The value you have entered is not a floating-point number.") return elif value_units_index == 2: # DAC Code try: value = int(hardware_manual_control_output_entry.text()) except ValueError: - QtGui.QMessageBox.critical(mainwidget, "Not a number", "The value you have entered is not an integer number.") + QtWidgets.QMessageBox.critical(mainwidget, "Not a number", "The value you have entered is not an integer number.") return else: return @@ -574,7 +574,7 @@ def read_potential_current(): try: print("%.2f\t%e\t%e"%(time_of_last_adcread,potential,current*1e-3),file=open(hardware_log_filename.text(),'a',1)) # Output tab-separated data containing time (in s), potential (in V), and current (in A) except: - QtGui.QMessageBox.critical(mainwidget, "Logging error!", "Logging error!") + QtWidgets.QMessageBox.critical(mainwidget, "Logging error!", "Logging error!") hardware_log_checkbox.setChecked(False) # Disable logging in case of file errors def idle_init(): @@ -630,39 +630,39 @@ def cv_getparams(): cv_parameters['filename'] = str(cv_file_entry.text()) return True except ValueError: - QtGui.QMessageBox.critical(mainwidget, "Not a number", "One or more parameters could not be interpreted as a number.") + QtWidgets.QMessageBox.critical(mainwidget, "Not a number", "One or more parameters could not be interpreted as a number.") return False def cv_validate_parameters(): """Check if the chosen CV parameters make sense. If so, return True.""" if cv_parameters['ubound'] < cv_parameters['lbound']: - QtGui.QMessageBox.critical(mainwidget, "CV error", "The upper bound cannot be lower than the lower bound.") + QtWidgets.QMessageBox.critical(mainwidget, "CV error", "The upper bound cannot be lower than the lower bound.") return False if cv_parameters['scanrate'] == 0: - QtGui.QMessageBox.critical(mainwidget, "CV error", "The scan rate cannot be zero.") + QtWidgets.QMessageBox.critical(mainwidget, "CV error", "The scan rate cannot be zero.") return False if (cv_parameters['scanrate'] > 0) and (cv_parameters['ubound'] < cv_parameters['startpot']): - QtGui.QMessageBox.critical(mainwidget, "CV error", "For a positive scan rate, the start potential must be lower than the upper bound.") + QtWidgets.QMessageBox.critical(mainwidget, "CV error", "For a positive scan rate, the start potential must be lower than the upper bound.") return False if (cv_parameters['scanrate'] < 0) and (cv_parameters['lbound'] > cv_parameters['startpot']): - QtGui.QMessageBox.critical(mainwidget, "CV error", "For a negative scan rate, the start potential must be higher than the lower bound.") + QtWidgets.QMessageBox.critical(mainwidget, "CV error", "For a negative scan rate, the start potential must be higher than the lower bound.") return False if cv_parameters['numsamples'] < 1: - QtGui.QMessageBox.critical(mainwidget, "CV error", "The number of samples to average must be at least 1.") + QtWidgets.QMessageBox.critical(mainwidget, "CV error", "The number of samples to average must be at least 1.") return False return True def validate_file(filename): """Check if a filename can be written to. If so, return True.""" if os.path.isfile(filename): - if QtGui.QMessageBox.question(mainwidget, "File exists", "The specified output file already exists. Do you want to overwrite it?", QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No) != QtGui.QMessageBox.Yes: + if QtWidgets.QMessageBox.question(mainwidget, "File exists", "The specified output file already exists. Do you want to overwrite it?", QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No) != QtWidgets.QMessageBox.Yes: return False try: tryfile = open(filename, 'w', 1) tryfile.close() return True except IOError: - QtGui.QMessageBox.critical(mainwidget, "File error", "The specified output file path is not valid.") + QtWidgets.QMessageBox.critical(mainwidget, "File error", "The specified output file path is not valid.") return False def cv_scanrate_changed_callback(): @@ -800,28 +800,28 @@ def cd_getparams(): cd_parameters['filename'] = str(cd_file_entry.text()) return True except ValueError: - QtGui.QMessageBox.critical(mainwidget, "Not a number", "One or more parameters could not be interpreted as a number.") + QtWidgets.QMessageBox.critical(mainwidget, "Not a number", "One or more parameters could not be interpreted as a number.") return False def cd_validate_parameters(): """Check if the chosen charge/discharge parameters make sense. If so, return True.""" if cd_parameters['ubound'] < cd_parameters['lbound']: - QtGui.QMessageBox.critical(mainwidget, "Charge/discharge error", "The upper bound cannot be lower than the lower bound.") + QtWidgets.QMessageBox.critical(mainwidget, "Charge/discharge error", "The upper bound cannot be lower than the lower bound.") return False if cd_parameters['chargecurrent'] == 0.: - QtGui.QMessageBox.critical(mainwidget, "Charge/discharge error", "The charge current cannot be zero.") + QtWidgets.QMessageBox.critical(mainwidget, "Charge/discharge error", "The charge current cannot be zero.") return False if cd_parameters['dischargecurrent'] == 0.: - QtGui.QMessageBox.critical(mainwidget, "Charge/discharge error", "The discharge current cannot be zero.") + QtWidgets.QMessageBox.critical(mainwidget, "Charge/discharge error", "The discharge current cannot be zero.") return False if cd_parameters['chargecurrent']*cd_parameters['dischargecurrent'] > 0: - QtGui.QMessageBox.critical(mainwidget, "Charge/discharge error", "Charge and discharge current must have opposite sign.") + QtWidgets.QMessageBox.critical(mainwidget, "Charge/discharge error", "Charge and discharge current must have opposite sign.") return False if cd_parameters['numcycles'] <= 0: - QtGui.QMessageBox.critical(mainwidget, "Charge/discharge error", "The number of half cycles must be positive and non-zero.") + QtWidgets.QMessageBox.critical(mainwidget, "Charge/discharge error", "The number of half cycles must be positive and non-zero.") return False if cd_parameters['numsamples'] < 1: - QtGui.QMessageBox.critical(mainwidget, "Charge/discharge error", "The number of samples to average must be at least 1.") + QtWidgets.QMessageBox.critical(mainwidget, "Charge/discharge error", "The number of samples to average must be at least 1.") return False return True @@ -923,19 +923,19 @@ def rate_getparams(): rate_parameters['filename'] = str(rate_file_entry.text()) return True except ValueError: - QtGui.QMessageBox.critical(mainwidget, "Not a number", "One or more parameters could not be interpreted as a number.") + QtWidgets.QMessageBox.critical(mainwidget, "Not a number", "One or more parameters could not be interpreted as a number.") return False def rate_validate_parameters(): """Check if the chosen charge/discharge parameters make sense. If so, return True.""" if rate_parameters['ubound'] < rate_parameters['lbound']: - QtGui.QMessageBox.critical(mainwidget, "Rate testing error", "The upper bound cannot be lower than the lower bound.") + QtWidgets.QMessageBox.critical(mainwidget, "Rate testing error", "The upper bound cannot be lower than the lower bound.") return False if 0. in rate_parameters['currents']: - QtGui.QMessageBox.critical(mainwidget, "Rate testing error", "The charge/discharge current cannot be zero.") + QtWidgets.QMessageBox.critical(mainwidget, "Rate testing error", "The charge/discharge current cannot be zero.") return False if rate_parameters['numcycles'] <= 0: - QtGui.QMessageBox.critical(mainwidget, "Charge/discharge error", "The number of half cycles must be positive and non-zero.") + QtWidgets.QMessageBox.critical(mainwidget, "Charge/discharge error", "The number of half cycles must be positive and non-zero.") return False return True @@ -1036,8 +1036,8 @@ def rate_stop(interrupted=True): preview_cancel_button.show() # Set up the GUI - Main Window -app = QtGui.QApplication([]) -win = QtGui.QMainWindow() +app = QtWidgets.QApplication([]) +win = QtWidgets.QMainWindow() win.setGeometry(300,300,1024,700) win.setWindowTitle('USB potentiostat/galvanostat') win.setWindowIcon(QtGui.QIcon('icon/icon.png')) @@ -1046,13 +1046,13 @@ def rate_stop(interrupted=True): potential_monitor.setFont(QtGui.QFont("monospace", 32)) current_monitor, current_monitor_box = make_groupbox_indicator("Measured current","+#.### mA") current_monitor.setFont(QtGui.QFont("monospace", 32)) -potential_current_display_frame = QtGui.QHBoxLayout() +potential_current_display_frame = QtWidgets.QHBoxLayout() potential_current_display_frame.setSpacing(1) potential_current_display_frame.setContentsMargins(0,0,0,0) potential_current_display_frame.addWidget(potential_monitor_box) potential_current_display_frame.addWidget(current_monitor_box) -mode_display_frame = QtGui.QHBoxLayout() +mode_display_frame = QtWidgets.QHBoxLayout() mode_display_frame.setSpacing(1) mode_display_frame.setContentsMargins(0,0,0,5) cell_status_monitor, cell_status_monitor_box = make_groupbox_indicator("Cell status"," ") @@ -1067,78 +1067,78 @@ def rate_stop(interrupted=True): pyqtgraph.setConfigOptions(foreground="#e5e5e5",background="#00304f") plot_frame = pyqtgraph.PlotWidget() -display_plot_frame = QtGui.QVBoxLayout() +display_plot_frame = QtWidgets.QVBoxLayout() display_plot_frame.setSpacing(0) display_plot_frame.setContentsMargins(0,0,0,0) display_plot_frame.addLayout(potential_current_display_frame) display_plot_frame.addLayout(mode_display_frame) display_plot_frame.addWidget(plot_frame) -preview_cancel_vlayout = QtGui.QVBoxLayout(plot_frame) -preview_cancel_hlayout = QtGui.QHBoxLayout() +preview_cancel_vlayout = QtWidgets.QVBoxLayout(plot_frame) +preview_cancel_hlayout = QtWidgets.QHBoxLayout() preview_cancel_vlayout.setAlignment(QtCore.Qt.AlignTop) preview_cancel_vlayout.addLayout(preview_cancel_hlayout) preview_cancel_hlayout.setAlignment(QtCore.Qt.AlignRight) -preview_cancel_button = QtGui.QPushButton("Back to live graph") +preview_cancel_button = QtWidgets.QPushButton("Back to live graph") preview_cancel_button.clicked.connect(preview_cancel) preview_cancel_hlayout.addWidget(preview_cancel_button) preview_cancel_button.hide() -tab_frame = QtGui.QTabWidget() +tab_frame = QtWidgets.QTabWidget() tab_frame.setFixedWidth(305) tab_names = ["Hardware","CV","Charge/disch.","Rate testing"] tabs = [add_my_tab(tab_frame, tab_name) for tab_name in tab_names] # Set up the GUI - Hardware tab -hardware_vbox = QtGui.QVBoxLayout() +hardware_vbox = QtWidgets.QVBoxLayout() hardware_vbox.setAlignment(QtCore.Qt.AlignTop) -hardware_usb_box = QtGui.QGroupBox(title="USB Interface", flat=False) +hardware_usb_box = QtWidgets.QGroupBox(title="USB Interface", flat=False) format_box_for_parameter(hardware_usb_box) -hardware_usb_box_layout = QtGui.QVBoxLayout() +hardware_usb_box_layout = QtWidgets.QVBoxLayout() hardware_usb_box.setLayout(hardware_usb_box_layout) -hardware_usb_vid_pid_layout = QtGui.QHBoxLayout() +hardware_usb_vid_pid_layout = QtWidgets.QHBoxLayout() hardware_usb_box_layout.addLayout(hardware_usb_vid_pid_layout) hardware_usb_vid = make_label_entry(hardware_usb_vid_pid_layout, "VID") hardware_usb_vid.setText(usb_vid) hardware_usb_pid = make_label_entry(hardware_usb_vid_pid_layout, "PID") hardware_usb_pid.setText(usb_pid) -hardware_usb_connectButton = QtGui.QPushButton("Connect") +hardware_usb_connectButton = QtWidgets.QPushButton("Connect") hardware_usb_connectButton.clicked.connect(connect_disconnect_usb) hardware_usb_box_layout.addWidget(hardware_usb_connectButton) hardware_usb_box_layout.setSpacing(5) hardware_usb_box_layout.setContentsMargins(3,9,3,3) hardware_vbox.addWidget(hardware_usb_box) -hardware_device_info_box = QtGui.QGroupBox(title="Device Information", flat=False) +hardware_device_info_box = QtWidgets.QGroupBox(title="Device Information", flat=False) format_box_for_parameter(hardware_device_info_box) -hardware_device_info_box_layout = QtGui.QVBoxLayout() +hardware_device_info_box_layout = QtWidgets.QVBoxLayout() hardware_device_info_box.setLayout(hardware_device_info_box_layout) -hardware_device_info_text = QtGui.QLabel("Manufacturer: \nProduct: \nSerial #: ") +hardware_device_info_text = QtWidgets.QLabel("Manufacturer: \nProduct: \nSerial #: ") hardware_device_info_box_layout.addWidget(hardware_device_info_text) hardware_device_info_box_layout.setSpacing(5) hardware_device_info_box_layout.setContentsMargins(3,9,3,3) hardware_vbox.addWidget(hardware_device_info_box) -hardware_calibration_box = QtGui.QGroupBox(title="Calibration", flat=False) +hardware_calibration_box = QtWidgets.QGroupBox(title="Calibration", flat=False) format_box_for_parameter(hardware_calibration_box) -hardware_calibration_box_layout = QtGui.QVBoxLayout() +hardware_calibration_box_layout = QtWidgets.QVBoxLayout() hardware_calibration_box.setLayout(hardware_calibration_box_layout) -hardware_calibration_dac_hlayout = QtGui.QHBoxLayout() +hardware_calibration_dac_hlayout = QtWidgets.QHBoxLayout() hardware_calibration_box_layout.addLayout(hardware_calibration_dac_hlayout) -hardware_calibration_dac_vlayout = QtGui.QVBoxLayout() +hardware_calibration_dac_vlayout = QtWidgets.QVBoxLayout() hardware_calibration_dac_hlayout.addLayout(hardware_calibration_dac_vlayout) hardware_calibration_dac_offset = make_label_entry(hardware_calibration_dac_vlayout, "DAC Offset") hardware_calibration_dac_gain = make_label_entry(hardware_calibration_dac_vlayout, "DAC Gain") -hardware_calibration_dac_calibrate_button = QtGui.QPushButton("Auto\nCalibrate") +hardware_calibration_dac_calibrate_button = QtWidgets.QPushButton("Auto\nCalibrate") hardware_calibration_dac_calibrate_button.setMaximumHeight(100) hardware_calibration_dac_calibrate_button.clicked.connect(dac_calibrate) hardware_calibration_dac_hlayout.addWidget(hardware_calibration_dac_calibrate_button) -hardware_calibration_offset_hlayout = QtGui.QHBoxLayout() +hardware_calibration_offset_hlayout = QtWidgets.QHBoxLayout() hardware_calibration_box_layout.addLayout(hardware_calibration_offset_hlayout) -hardware_calibration_offset_vlayout = QtGui.QVBoxLayout() +hardware_calibration_offset_vlayout = QtWidgets.QVBoxLayout() hardware_calibration_offset_hlayout.addLayout(hardware_calibration_offset_vlayout) hardware_calibration_potential_offset = make_label_entry(hardware_calibration_offset_vlayout, "Pot. Offset") hardware_calibration_potential_offset.editingFinished.connect(offset_changed_callback) @@ -1146,23 +1146,23 @@ def rate_stop(interrupted=True): hardware_calibration_current_offset = make_label_entry(hardware_calibration_offset_vlayout, "Curr. Offset") hardware_calibration_current_offset.editingFinished.connect(offset_changed_callback) hardware_calibration_current_offset.setText("0") -hardware_calibration_adc_measure_button = QtGui.QPushButton("Auto\nZero") +hardware_calibration_adc_measure_button = QtWidgets.QPushButton("Auto\nZero") hardware_calibration_adc_measure_button.setMaximumHeight(100) hardware_calibration_adc_measure_button.clicked.connect(zero_offset) hardware_calibration_offset_hlayout.addWidget(hardware_calibration_adc_measure_button) -hardware_calibration_shunt_resistor_layout = QtGui.QHBoxLayout() +hardware_calibration_shunt_resistor_layout = QtWidgets.QHBoxLayout() hardware_calibration_box_layout.addLayout(hardware_calibration_shunt_resistor_layout) hardware_calibration_shuntvalues = [make_label_entry(hardware_calibration_shunt_resistor_layout, "R%d"%i) for i in range(1,4)] for i in range(0,3): hardware_calibration_shuntvalues[i].editingFinished.connect(shunt_calibration_changed_callback) hardware_calibration_shuntvalues[i].setText("%.4f"%shunt_calibration[i]) -hardware_calibration_button_layout = QtGui.QHBoxLayout() -hardware_calibration_get_button = QtGui.QPushButton("Load from device") +hardware_calibration_button_layout = QtWidgets.QHBoxLayout() +hardware_calibration_get_button = QtWidgets.QPushButton("Load from device") hardware_calibration_get_button.clicked.connect(get_calibration) hardware_calibration_button_layout.addWidget(hardware_calibration_get_button) -hardware_calibration_set_button = QtGui.QPushButton("Save to device") +hardware_calibration_set_button = QtWidgets.QPushButton("Save to device") hardware_calibration_set_button.clicked.connect(set_calibration) hardware_calibration_button_layout.addWidget(hardware_calibration_set_button) @@ -1171,49 +1171,49 @@ def rate_stop(interrupted=True): hardware_calibration_box_layout.setContentsMargins(3,7,3,3) hardware_vbox.addWidget(hardware_calibration_box) -hardware_manual_control_box = QtGui.QGroupBox(title="Manual Control", flat=False) +hardware_manual_control_box = QtWidgets.QGroupBox(title="Manual Control", flat=False) format_box_for_parameter(hardware_manual_control_box) -hardware_manual_control_box_layout = QtGui.QVBoxLayout() +hardware_manual_control_box_layout = QtWidgets.QVBoxLayout() hardware_manual_control_box.setLayout(hardware_manual_control_box_layout) -hardware_manual_control_cell_layout = QtGui.QHBoxLayout() -hardware_manual_control_cell_layout.addWidget(QtGui.QLabel("Cell connection")) -hardware_manual_control_cell_on_button = QtGui.QPushButton("On") +hardware_manual_control_cell_layout = QtWidgets.QHBoxLayout() +hardware_manual_control_cell_layout.addWidget(QtWidgets.QLabel("Cell connection")) +hardware_manual_control_cell_on_button = QtWidgets.QPushButton("On") hardware_manual_control_cell_on_button.clicked.connect(lambda: set_cell_status(True)) hardware_manual_control_cell_layout.addWidget(hardware_manual_control_cell_on_button) -hardware_manual_control_cell_off_button = QtGui.QPushButton("Off") +hardware_manual_control_cell_off_button = QtWidgets.QPushButton("Off") hardware_manual_control_cell_off_button.clicked.connect(lambda: set_cell_status(False)) hardware_manual_control_cell_layout.addWidget(hardware_manual_control_cell_off_button) hardware_manual_control_box_layout.addLayout(hardware_manual_control_cell_layout) -hardware_manual_control_mode_layout = QtGui.QHBoxLayout() -hardware_manual_control_mode_layout.addWidget(QtGui.QLabel("Mode")) -hardware_manual_control_mode_potentiostat_button = QtGui.QPushButton("Potentiostatic") +hardware_manual_control_mode_layout = QtWidgets.QHBoxLayout() +hardware_manual_control_mode_layout.addWidget(QtWidgets.QLabel("Mode")) +hardware_manual_control_mode_potentiostat_button = QtWidgets.QPushButton("Potentiostatic") hardware_manual_control_mode_potentiostat_button.clicked.connect(lambda: set_control_mode(False)) hardware_manual_control_mode_layout.addWidget(hardware_manual_control_mode_potentiostat_button) -hardware_manual_control_mode_galvanostat_button = QtGui.QPushButton("Galvanostatic") +hardware_manual_control_mode_galvanostat_button = QtWidgets.QPushButton("Galvanostatic") hardware_manual_control_mode_galvanostat_button.clicked.connect(lambda: set_control_mode(True)) hardware_manual_control_mode_layout.addWidget(hardware_manual_control_mode_galvanostat_button) hardware_manual_control_box_layout.addLayout(hardware_manual_control_mode_layout) -hardware_manual_control_range_layout = QtGui.QHBoxLayout() -hardware_manual_control_range_layout.addWidget(QtGui.QLabel("Current range")) -hardware_manual_control_range_dropdown = QtGui.QComboBox() +hardware_manual_control_range_layout = QtWidgets.QHBoxLayout() +hardware_manual_control_range_layout.addWidget(QtWidgets.QLabel("Current range")) +hardware_manual_control_range_dropdown = QtWidgets.QComboBox() hardware_manual_control_range_dropdown.addItems(current_range_list) hardware_manual_control_range_layout.addWidget(hardware_manual_control_range_dropdown) -hardware_manual_control_range_set_button = QtGui.QPushButton("Set") +hardware_manual_control_range_set_button = QtWidgets.QPushButton("Set") hardware_manual_control_range_set_button.clicked.connect(set_current_range) hardware_manual_control_range_layout.addWidget(hardware_manual_control_range_set_button) hardware_manual_control_box_layout.addLayout(hardware_manual_control_range_layout) -hardware_manual_control_output_layout = QtGui.QHBoxLayout() -hardware_manual_control_output_dropdown = QtGui.QComboBox() +hardware_manual_control_output_layout = QtWidgets.QHBoxLayout() +hardware_manual_control_output_dropdown = QtWidgets.QComboBox() hardware_manual_control_output_dropdown.addItems(units_list) hardware_manual_control_output_layout.addWidget(hardware_manual_control_output_dropdown) -hardware_manual_control_output_entry = QtGui.QLineEdit() +hardware_manual_control_output_entry = QtWidgets.QLineEdit() hardware_manual_control_output_entry.returnPressed.connect(set_output_from_gui) hardware_manual_control_output_layout.addWidget(hardware_manual_control_output_entry) -hardware_manual_control_output_set_button = QtGui.QPushButton("Set") +hardware_manual_control_output_set_button = QtWidgets.QPushButton("Set") hardware_manual_control_output_set_button.clicked.connect(set_output_from_gui) hardware_manual_control_output_layout.addWidget(hardware_manual_control_output_set_button) hardware_manual_control_box_layout.addLayout(hardware_manual_control_output_layout) @@ -1223,16 +1223,16 @@ def rate_stop(interrupted=True): hardware_vbox.addWidget(hardware_manual_control_box) -hardware_log_box = QtGui.QGroupBox(title="Log to file", flat=False) +hardware_log_box = QtWidgets.QGroupBox(title="Log to file", flat=False) format_box_for_parameter(hardware_log_box) -hardware_log_box_layout = QtGui.QHBoxLayout() +hardware_log_box_layout = QtWidgets.QHBoxLayout() hardware_log_box.setLayout(hardware_log_box_layout) -hardware_log_checkbox = QtGui.QCheckBox("Log") +hardware_log_checkbox = QtWidgets.QCheckBox("Log") hardware_log_checkbox.stateChanged.connect(toggle_logging) hardware_log_box_layout.addWidget(hardware_log_checkbox) -hardware_log_filename = QtGui.QLineEdit() +hardware_log_filename = QtWidgets.QLineEdit() hardware_log_box_layout.addWidget(hardware_log_filename) -hardware_log_choose_button = QtGui.QPushButton("...") +hardware_log_choose_button = QtWidgets.QPushButton("...") hardware_log_choose_button.setFixedWidth(32) hardware_log_choose_button.clicked.connect(lambda: choose_file(hardware_log_filename,"Choose where to save the log data")) hardware_log_box_layout.addWidget(hardware_log_choose_button) @@ -1248,20 +1248,20 @@ def rate_stop(interrupted=True): tabs[0].setLayout(hardware_vbox) # Set up the GUI - CV tab -cv_vbox = QtGui.QVBoxLayout() +cv_vbox = QtWidgets.QVBoxLayout() cv_vbox.setAlignment(QtCore.Qt.AlignTop) -cv_params_box = QtGui.QGroupBox(title="Cyclic voltammetry parameters", flat=False) +cv_params_box = QtWidgets.QGroupBox(title="Cyclic voltammetry parameters", flat=False) format_box_for_parameter(cv_params_box) -cv_params_layout = QtGui.QVBoxLayout() +cv_params_layout = QtWidgets.QVBoxLayout() cv_params_box.setLayout(cv_params_layout) cv_lbound_entry = make_label_entry(cv_params_layout, "Lower bound (V)") cv_ubound_entry = make_label_entry(cv_params_layout, "Upper bound (V)") -cv_hbox = QtGui.QHBoxLayout() -cv_label = QtGui.QLabel(text="Start potential (V)") -cv_startpot_entry = QtGui.QLineEdit() -cv_get_button = QtGui.QPushButton("OCP") +cv_hbox = QtWidgets.QHBoxLayout() +cv_label = QtWidgets.QLabel(text="Start potential (V)") +cv_startpot_entry = QtWidgets.QLineEdit() +cv_get_button = QtWidgets.QPushButton("OCP") cv_get_button.setFont(custom_size_font(8)) cv_get_button.setFixedWidth(32) cv_get_button.clicked.connect(cv_get_ocp) @@ -1282,13 +1282,13 @@ def rate_stop(interrupted=True): cv_params_layout.setContentsMargins(3,10,3,3) cv_vbox.addWidget(cv_params_box) -cv_range_box = QtGui.QGroupBox(title="Autoranging", flat=False) +cv_range_box = QtWidgets.QGroupBox(title="Autoranging", flat=False) format_box_for_parameter(cv_range_box) -cv_range_layout = QtGui.QVBoxLayout() +cv_range_layout = QtWidgets.QVBoxLayout() cv_range_box.setLayout(cv_range_layout) cv_range_checkboxes = [] for current in current_range_list: - checkbox = QtGui.QCheckBox(current) + checkbox = QtWidgets.QCheckBox(current) cv_range_checkboxes.append(checkbox) cv_range_layout.addWidget(checkbox) checkbox.setChecked(True) @@ -1297,14 +1297,14 @@ def rate_stop(interrupted=True): cv_range_layout.setContentsMargins(3,10,3,3) cv_vbox.addWidget(cv_range_box) -cv_file_box = QtGui.QGroupBox(title="Output data filename", flat=False) +cv_file_box = QtWidgets.QGroupBox(title="Output data filename", flat=False) format_box_for_parameter(cv_file_box) -cv_file_layout = QtGui.QVBoxLayout() +cv_file_layout = QtWidgets.QVBoxLayout() cv_file_box.setLayout(cv_file_layout) -cv_file_choose_layout = QtGui.QHBoxLayout() -cv_file_entry = QtGui.QLineEdit() +cv_file_choose_layout = QtWidgets.QHBoxLayout() +cv_file_entry = QtWidgets.QLineEdit() cv_file_choose_layout.addWidget(cv_file_entry) -cv_file_choose_button = QtGui.QPushButton("...") +cv_file_choose_button = QtWidgets.QPushButton("...") cv_file_choose_button.setFixedWidth(32) cv_file_choose_layout.addWidget(cv_file_choose_button) cv_file_choose_button.clicked.connect(lambda: choose_file(cv_file_entry,"Choose where to save the CV measurement data")) @@ -1313,13 +1313,13 @@ def rate_stop(interrupted=True): cv_file_layout.setContentsMargins(3,10,3,3) cv_vbox.addWidget(cv_file_box) -cv_preview_button = QtGui.QPushButton("Preview sweep") +cv_preview_button = QtWidgets.QPushButton("Preview sweep") cv_preview_button.clicked.connect(cv_preview) cv_vbox.addWidget(cv_preview_button) -cv_start_button = QtGui.QPushButton("Start cyclic voltammetry") +cv_start_button = QtWidgets.QPushButton("Start cyclic voltammetry") cv_start_button.clicked.connect(cv_start) cv_vbox.addWidget(cv_start_button) -cv_stop_button = QtGui.QPushButton("Stop cyclic voltammetry") +cv_stop_button = QtWidgets.QPushButton("Stop cyclic voltammetry") cv_stop_button.clicked.connect(lambda: cv_stop(interrupted=True)) cv_vbox.addWidget(cv_stop_button) @@ -1329,12 +1329,12 @@ def rate_stop(interrupted=True): tabs[1].setLayout(cv_vbox) # Set up the GUI - charge/discharge tab -cd_vbox = QtGui.QVBoxLayout() +cd_vbox = QtWidgets.QVBoxLayout() cd_vbox.setAlignment(QtCore.Qt.AlignTop) -cd_params_box = QtGui.QGroupBox(title="Charge/discharge parameters", flat=False) +cd_params_box = QtWidgets.QGroupBox(title="Charge/discharge parameters", flat=False) format_box_for_parameter(cd_params_box) -cd_params_layout = QtGui.QVBoxLayout() +cd_params_layout = QtWidgets.QVBoxLayout() cd_params_box.setLayout(cd_params_layout) cd_lbound_entry = make_label_entry(cd_params_layout, "Lower bound (V)") cd_ubound_entry = make_label_entry(cd_params_layout, "Upper bound (V)") @@ -1348,14 +1348,14 @@ def rate_stop(interrupted=True): cd_params_layout.setContentsMargins(3,10,3,3) cd_vbox.addWidget(cd_params_box) -cd_file_box = QtGui.QGroupBox(title="Output data filename", flat=False) +cd_file_box = QtWidgets.QGroupBox(title="Output data filename", flat=False) format_box_for_parameter(cd_file_box) -cd_file_layout = QtGui.QVBoxLayout() +cd_file_layout = QtWidgets.QVBoxLayout() cd_file_box.setLayout(cd_file_layout) -cd_file_choose_layout = QtGui.QHBoxLayout() -cd_file_entry = QtGui.QLineEdit() +cd_file_choose_layout = QtWidgets.QHBoxLayout() +cd_file_entry = QtWidgets.QLineEdit() cd_file_choose_layout.addWidget(cd_file_entry) -cd_file_choose_button = QtGui.QPushButton("...") +cd_file_choose_button = QtWidgets.QPushButton("...") cd_file_choose_button.setFixedWidth(32) cd_file_choose_layout.addWidget(cd_file_choose_button) cd_file_choose_button.clicked.connect(lambda: choose_file(cd_file_entry,"Choose where to save the charge/discharge measurement data")) @@ -1364,19 +1364,19 @@ def rate_stop(interrupted=True): cd_file_layout.setContentsMargins(3,10,3,3) cd_vbox.addWidget(cd_file_box) -cd_start_button = QtGui.QPushButton("Start charge/discharge") +cd_start_button = QtWidgets.QPushButton("Start charge/discharge") cd_start_button.clicked.connect(cd_start) cd_vbox.addWidget(cd_start_button) -cd_stop_button = QtGui.QPushButton("Stop charge/discharge") +cd_stop_button = QtWidgets.QPushButton("Stop charge/discharge") cd_stop_button.clicked.connect(lambda: cd_stop(interrupted=True)) cd_vbox.addWidget(cd_stop_button) cd_vbox.setSpacing(6) cd_vbox.setContentsMargins(3,3,3,3) -cd_info_box = QtGui.QGroupBox(title="Information", flat=False) +cd_info_box = QtWidgets.QGroupBox(title="Information", flat=False) format_box_for_parameter(cd_info_box) -cd_info_layout = QtGui.QVBoxLayout() +cd_info_layout = QtWidgets.QVBoxLayout() cd_info_box.setLayout(cd_info_layout) cd_current_cycle_entry = make_label_entry(cd_info_layout, "Current half cycle") cd_current_cycle_entry.setReadOnly(True) @@ -1388,12 +1388,12 @@ def rate_stop(interrupted=True): tabs[2].setLayout(cd_vbox) # Set up the GUI - Rate testing tab -rate_vbox = QtGui.QVBoxLayout() +rate_vbox = QtWidgets.QVBoxLayout() rate_vbox.setAlignment(QtCore.Qt.AlignTop) -rate_params_box = QtGui.QGroupBox(title="Rate testing parameters", flat=False) +rate_params_box = QtWidgets.QGroupBox(title="Rate testing parameters", flat=False) format_box_for_parameter(rate_params_box) -rate_params_layout = QtGui.QVBoxLayout() +rate_params_layout = QtWidgets.QVBoxLayout() rate_params_box.setLayout(rate_params_layout) rate_lbound_entry = make_label_entry(rate_params_layout, "Lower bound (V)") rate_ubound_entry = make_label_entry(rate_params_layout, "Upper bound (V)") @@ -1406,14 +1406,14 @@ def rate_stop(interrupted=True): rate_params_layout.setContentsMargins(3,10,3,3) rate_vbox.addWidget(rate_params_box) -rate_file_box = QtGui.QGroupBox(title="Output data filename", flat=False) +rate_file_box = QtWidgets.QGroupBox(title="Output data filename", flat=False) format_box_for_parameter(rate_file_box) -rate_file_layout = QtGui.QVBoxLayout() +rate_file_layout = QtWidgets.QVBoxLayout() rate_file_box.setLayout(rate_file_layout) -rate_file_choose_layout = QtGui.QHBoxLayout() -rate_file_entry = QtGui.QLineEdit() +rate_file_choose_layout = QtWidgets.QHBoxLayout() +rate_file_entry = QtWidgets.QLineEdit() rate_file_choose_layout.addWidget(rate_file_entry) -rate_file_choose_button = QtGui.QPushButton("...") +rate_file_choose_button = QtWidgets.QPushButton("...") rate_file_choose_button.setFixedWidth(32) rate_file_choose_button.clicked.connect(lambda: choose_file(rate_file_entry,"Choose where to save the rate testing measurement data")) rate_file_choose_layout.addWidget(rate_file_choose_button) @@ -1423,19 +1423,19 @@ def rate_stop(interrupted=True): rate_file_layout.setContentsMargins(3,10,3,3) rate_vbox.addWidget(rate_file_box) -rate_start_button = QtGui.QPushButton("Start Rate Test") +rate_start_button = QtWidgets.QPushButton("Start Rate Test") rate_start_button.clicked.connect(rate_start) rate_vbox.addWidget(rate_start_button) -rate_stop_button = QtGui.QPushButton("Stop Rate Test") +rate_stop_button = QtWidgets.QPushButton("Stop Rate Test") rate_stop_button.clicked.connect(lambda: rate_stop(interrupted=True)) rate_vbox.addWidget(rate_stop_button) rate_vbox.setSpacing(6) rate_vbox.setContentsMargins(3,3,3,3) -rate_info_box = QtGui.QGroupBox(title="Information", flat=False) +rate_info_box = QtWidgets.QGroupBox(title="Information", flat=False) format_box_for_parameter(rate_info_box) -rate_info_layout = QtGui.QVBoxLayout() +rate_info_layout = QtWidgets.QVBoxLayout() rate_info_box.setLayout(rate_info_layout) rate_current_crate_entry = make_label_entry(rate_info_layout, "Current C-rate") rate_current_crate_entry.setReadOnly(True) @@ -1446,17 +1446,17 @@ def rate_stop(interrupted=True): tabs[3].setLayout(rate_vbox) -hbox = QtGui.QHBoxLayout() +hbox = QtWidgets.QHBoxLayout() hbox.addLayout(display_plot_frame) hbox.addWidget(tab_frame) -vbox = QtGui.QVBoxLayout() -statustext = QtGui.QPlainTextEdit() +vbox = QtWidgets.QVBoxLayout() +statustext = QtWidgets.QPlainTextEdit() statustext.setFixedHeight(90) vbox.addLayout(hbox) vbox.addWidget(statustext) -mainwidget = QtGui.QWidget() +mainwidget = QtWidgets.QWidget() win.setCentralWidget(mainwidget) vbox.setContentsMargins(0,0,0,0) mainwidget.setLayout(vbox)