Commit c9cb0448 authored by Projects's avatar Projects Committed by Grzegorz Daniluk

Removed Python GUI

parent 38cc7d5c
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>510</width>
<height>597</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="geometry">
<rect>
<x>70</x>
<y>90</y>
<width>101</width>
<height>351</height>
</rect>
</property>
<property name="title">
<string>Slot 1</string>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>0</x>
<y>90</y>
<width>31</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>1</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
<widget class="QPushButton" name="pushButton_2">
<property name="geometry">
<rect>
<x>0</x>
<y>120</y>
<width>31</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>2</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</widget>
<widget class="QGroupBox" name="groupBox_2">
<property name="geometry">
<rect>
<x>220</x>
<y>90</y>
<width>101</width>
<height>351</height>
</rect>
</property>
<property name="title">
<string>Slot 2</string>
</property>
<widget class="QPushButton" name="pushButton_3">
<property name="geometry">
<rect>
<x>0</x>
<y>90</y>
<width>31</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>3</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
<widget class="QPushButton" name="pushButton_4">
<property name="geometry">
<rect>
<x>0</x>
<y>120</y>
<width>31</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>4</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QPushButton" name="but1">
<property name="geometry">
<rect>
<x>410</x>
<y>330</y>
<width>99</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
<widget class="QRadioButton" name="radioButton">
<property name="geometry">
<rect>
<x>80</x>
<y>150</y>
<width>117</width>
<height>22</height>
</rect>
</property>
<property name="text">
<string>RadioButton</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>
#!/usr/bin/python3
###############################################################################
# This work is part of the Distributed I/O Tier project
# Copyright (c) 2018 CERN (www.cern.ch)
# Author: Greg Daniluk <grzegorz.daniluk@cern.ch>
# Released according to the GNU GPL, version 2 or any later version.
###############################################################################
import sys
import copy
from PyQt5.QtWidgets import *
from PyQt5 import QtCore
from ui_dialog import Ui_Dialog
import threading
import time
class TestDialog(QDialog, Ui_Dialog):
def __init__(self):
super(TestDialog, self).__init__()
# setup GUI from Qt Designer
self.setupUi(self)
self.show()
##########################################################
## DiotSlot class definition ##
##########################################################
class DiotSlot():
def __init__(self, Dialog, num, idx):
self.btn_state = []
self.io_state = []
self.btn_test = []
#######################
self.groupBox = QGroupBox(Dialog)
self.groupBox.setGeometry(QtCore.QRect(20+idx*170, 20, 150, 40+num*30))
self.groupBox.setTitle("Slot "+str(idx+1))
for i in range(0, num):
self.io_state.append(True)
self.btn_state.append(QPushButton(self.groupBox))
self.btn_state[i].setGeometry(QtCore.QRect(20, 30+i*30, 30, 30))
self.btn_state[i].setText(str((i+1)+idx*num))
self.btn_state[i].setStyleSheet("background-color: green")
self.btn_test.append(QPushButton(self.groupBox))
self.btn_test[i].setGeometry(QtCore.QRect(50, 30+i*30, 80, 30))
self.btn_test[i].setText("Test")
self.btn_test[i].clicked.connect(lambda state, slot=idx, io=i: self.action_click(slot, io))
def action_click(self, slot, io):
print("Button test clicked - slot(" + str(slot) +") io(" + str(io) + ")")
## TODO: add here sending new output state over fieldbus
self.update_state(io, not self.io_state[io])
def update_state(self, io, new_state):
self.io_state[io] = new_state
# and refresh color
if self.io_state[io] == True:
self.btn_state[io].setStyleSheet("background-color: green")
else:
self.btn_state[io].setStyleSheet("background-color: red")
##########################################################
## Thread class definition ##
##########################################################
class ReadThread (threading.Thread):
def __init__(self, threadID, name, slots):
threading.Thread.__init__(self)
self.threadID = threadID
self.name = name
self.slots = slots
self.end_thread = 0
def run(self):
## TODO: put here cyclic reading of all IO state
while self.end_thread == 0:
time.sleep(1)
self.slots[3].update_state(5, not self.slots[3].io_state[5])
print("thread updated io")
def stop(self):
self.end_thread = 1
if __name__ == '__main__':
app = QApplication(sys.argv)
#w = TestDialog()
w = QDialog()
slots = []
for i in range (0, 8):
slots.append(DiotSlot(w, 16, i))
#ui = Ui_Dialog()
#ui.setupUi(w)
w.show()
thread1 = ReadThread(1, "ReadThread-1", slots)
thread1.start()
sys.exit(app.exec_())
print("Exiting")
thread1.stop()
print("thread stopped?")
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'dialog.ui'
#
# Created by: PyQt5 UI code generator 5.10.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(510, 597)
self.groupBox = QtWidgets.QGroupBox(Dialog)
self.groupBox.setGeometry(QtCore.QRect(70, 90, 101, 351))
self.groupBox.setObjectName("groupBox")
self.pushButton = QtWidgets.QPushButton(self.groupBox)
self.pushButton.setGeometry(QtCore.QRect(0, 90, 31, 27))
self.pushButton.setCheckable(False)
self.pushButton.setChecked(False)
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(self.groupBox)
self.pushButton_2.setGeometry(QtCore.QRect(0, 120, 31, 27))
self.pushButton_2.setCheckable(False)
self.pushButton_2.setChecked(False)
self.pushButton_2.setObjectName("pushButton_2")
self.groupBox_2 = QtWidgets.QGroupBox(Dialog)
self.groupBox_2.setGeometry(QtCore.QRect(220, 90, 101, 351))
self.groupBox_2.setObjectName("groupBox_2")
self.pushButton_3 = QtWidgets.QPushButton(self.groupBox_2)
self.pushButton_3.setGeometry(QtCore.QRect(0, 90, 31, 27))
self.pushButton_3.setCheckable(False)
self.pushButton_3.setChecked(False)
self.pushButton_3.setObjectName("pushButton_3")
self.pushButton_4 = QtWidgets.QPushButton(self.groupBox_2)
self.pushButton_4.setGeometry(QtCore.QRect(0, 120, 31, 27))
self.pushButton_4.setCheckable(False)
self.pushButton_4.setChecked(False)
self.pushButton_4.setObjectName("pushButton_4")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.groupBox.setTitle(_translate("Dialog", "Slot 1"))
self.pushButton.setText(_translate("Dialog", "1"))
self.pushButton_2.setText(_translate("Dialog", "2"))
self.groupBox_2.setTitle(_translate("Dialog", "Slot 2"))
self.pushButton_3.setText(_translate("Dialog", "3"))
self.pushButton_4.setText(_translate("Dialog", "4"))
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'main_win.ui'
#
# Created by: PyQt5 UI code generator 5.10.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.but1 = QtWidgets.QPushButton(self.centralwidget)
self.but1.setGeometry(QtCore.QRect(410, 330, 99, 27))
self.but1.setObjectName("but1")
self.radioButton = QtWidgets.QRadioButton(self.centralwidget)
self.radioButton.setGeometry(QtCore.QRect(140, 180, 117, 22))
self.radioButton.setObjectName("radioButton")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 25))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.but1.setText(_translate("MainWindow", "PushButton"))
self.radioButton.setText(_translate("MainWindow", "RadioButton"))
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