Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugin_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_name() -> str:
def get_description() -> str:
return _('Lab Gui integration')

@classmethod
def get_icon(self):
return self.create_icon('mdi.chip')

Expand Down
34 changes: 16 additions & 18 deletions pylab_ml/gui/instruments/base_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"""

import os
import qdarkstyle
from PyQt5 import QtCore, QtWidgets, uic
import qtawesome as qta
from pylab_ml.misc.iasvg import InteractiveSvgWidget
Expand Down Expand Up @@ -91,7 +90,7 @@ class Gui(object):
def __init__(self, grandparent=None, name=None, parentwindow=None):
"""
Init the Gui, create a window and load the ui-file with the same name as the class.

Parameters
----------
grandparent : object, optional
Expand Down Expand Up @@ -126,7 +125,6 @@ def __init__(self, grandparent=None, name=None, parentwindow=None):
self.mqtt_initlist = []
self.mqtt_cmds = []
self.publish("mqtt_status", "connect") # I'm alive
window.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
# self.gui.myframe.setEnabled(True)

def adjustUI(self):
Expand All @@ -151,7 +149,7 @@ def adjustUI(self):
def add_menue(self, menue, connect, enabled, checkable=False, checked=False):
"""
Add a menue item to Setup

Parameters
----------
menue : string
Expand Down Expand Up @@ -211,7 +209,7 @@ def retranslateUi(self, Form):
def setLabel(self, Label, value, ext=None):
"""
Set the text of a label.

Parameters
----------
Label : object
Expand All @@ -234,7 +232,7 @@ def setLabel(self, Label, value, ext=None):
def set_Geometry(self, geometry):
"""
Set the geometry of the GUI, check if the geometry is on the actual screen.

Parameters
----------
geometry : tuple
Expand Down Expand Up @@ -274,7 +272,7 @@ def filtersubtopic(self, value):
def unitOfMeasurement(self, value, unit=None):
"""
Convert a value with a unit to its numerical representation.

Parameters
----------
value : string
Expand Down Expand Up @@ -311,12 +309,12 @@ def objectName2mqttName(self, name):
= MQTT_set_I_limit -> I_limit listen only on set
= MQTT_get_I_limit -> I_limit listen only on get
= TAB_ch -> Name for a tab-name

Parameters
----------
name : string
The object name to be filtered.

Returns
-------
listen : string
Expand Down Expand Up @@ -350,7 +348,7 @@ def objectName2mqttName(self, name):
def mqttreceive(self, instName, msg, check=False):
"""
Common MQTT receive messages, get raw MQTT data for receiving more information.

Parameters
----------
instName : string
Expand All @@ -359,12 +357,12 @@ def mqttreceive(self, instName, msg, check=False):
The MQTT message received, expected to have keys "cmd", "payload", and "type".
check : bool, optional
If True, only process the message if the command is in self.mqtt_cmds. The default is False.

Returns
-------
result : bool
True if the message was processed successfully, False otherwise.
"""
"""
self.dprint(f' {instName}.mqttreceive from base class: search {msg["cmd"]}')
result = False
if "cmd" in tuple(msg.keys()) and "payload" in tuple(msg.keys()) and (msg["cmd"] in self.mqtt_cmds or not check):
Expand Down Expand Up @@ -532,7 +530,7 @@ def mqttConnectSVGWidget(self, filename, name, channel=None):
"""
Create an InteractiveSvgWidget and load the filname.
Connect all clicks to the text id's to the function svg2mqtt().

Parameters
----------
filename : string
Expand All @@ -541,7 +539,7 @@ def mqttConnectSVGWidget(self, filename, name, channel=None):
The base name for the widget, used for MQTT topic construction.
channel : string, optional
An optional channel identifier to be appended to the name for MQTT topic construction. The default is None.

Returns
-------
svgWidget : InteractiveSvgWidget
Expand Down Expand Up @@ -598,7 +596,7 @@ def status(self, value):
def publish(self, cmd, value="", instName=None):
"""
Publish a command and value over MQTT.

Parameters
----------
cmd : string
Expand All @@ -617,12 +615,12 @@ def publish(self, cmd, value="", instName=None):
def gui2mqtt(self, widget):
"""
Function connect a Gui-widget to mqtt, it sends a mqtt set command with the value from the Gui-widget.

Parameters
----------
widget : QtWidgets.QWidget
The GUI widget that triggered the MQTT command, expected to have an objectName that follows the

Returns
-------
None.
Expand Down Expand Up @@ -650,7 +648,7 @@ def svg2mqtt(self, name, value):
"""
Publish the name and value over mqtt.
Overwrite this function if you need a more complex form.

Parameters
----------
name : string
Expand Down
10 changes: 4 additions & 6 deletions pylab_ml/gui/instruments/coil/coil_3a.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
This script defines a GUI class for a coil instrument, which is part of the PyLab-ML project.
The GUI allows users to interact with the coil instrument, send MQTT commands, and receive updates.
This script defines a GUI class for a coil instrument, which is part of the PyLab-ML project.
The GUI allows users to interact with the coil instrument, send MQTT commands, and receive updates.
The class inherits from a base instrument GUI class and implements specific functionality for the coil instrument.

Created on Mon Jan 3 09:19:17 2022
Expand All @@ -11,7 +11,6 @@
"""

import sys
import qdarkstyle

# import numpy as np
import os
Expand Down Expand Up @@ -45,7 +44,7 @@ class Gui(Guibase):
def __init__(self, parent=None, name="scope", parentwindow=None, channel=None):
"""
Initialize the GUI for the coil instrument.

Parameters
----------
parent: object, optional
Expand Down Expand Up @@ -97,7 +96,7 @@ def mqttMeasureEvent(self, event):
def mqttreceive(self, instName, msg):
"""
Handle incoming MQTT messages and update the GUI accordingly.

Parameters
----------
instName: str
Expand Down Expand Up @@ -176,7 +175,6 @@ def smustatus(self, msg):
# mqttclient.init()

app = QtWidgets.QApplication(sys.argv)
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
window = Gui(app)
app.exec_()
# window.scope.anim.event_source.stop()
39 changes: 18 additions & 21 deletions pylab_ml/gui/instruments/matrix/matrix.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""
This script defines a GUI class for a matrix instrument, which is part of the PyLab-ML project.
This script defines a GUI class for a matrix instrument, which is part of the PyLab-ML project.
The GUI allows users to interact with the matrix instrument, send MQTT commands, and receive updates.

Created on Fri Jul 10 13:43:20 2020
Expand All @@ -20,7 +20,6 @@
# farbige Darstellung von connections und wire
# kleinere Darstellung der Matrix ....
#
import qdarkstyle
import numpy as np
import os
from PyQt5 import QtCore, QtGui, QtWidgets
Expand All @@ -38,7 +37,7 @@

class VerticalLabel(QLabel):
""" VerticalLabel is a custom QLabel that displays text vertically. It overrides the paintEvent to rotate the text. """

def __init__(self, *args):
"""Initialize the VerticalLabel."""
QLabel.__init__(self, *args)
Expand Down Expand Up @@ -82,7 +81,7 @@ class Gui(Guibase):
def __init__(self, parent=None, name="matrix", parentwindow=None):
"""
Initialize the GUI for the matrix instrument.

Parameters
----------
parent: QWidget, optional
Expand Down Expand Up @@ -159,7 +158,7 @@ def myadjustUI(self):
def create_CBox(self, index):
"""
Create a combo box and its associated label for the given index.

Parameters
----------
index: int
Expand Down Expand Up @@ -225,7 +224,7 @@ def update_mainwindow(self):
def update_CBox(self, index, name, color):
"""
Update the combo box and its associated label for the given index, name, and color.

Parameters
----------
index: int
Expand Down Expand Up @@ -286,7 +285,6 @@ def show_matrix(self):
self.lineEdit.source_object = None
self.matrix_window = matrix_window
self.matrix_window.nets = nets
matrix_window.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
matrix_window.setMinimumSize(
self.X_OFFSET + (self.x_max + 1) * self.X_STEP + self.X_RLABELWIDTH + 30,
self.Y_OFFSET + self.Y_TLABELHIGH + self.y_max * self.Y_STEP + self.Y_BLABELHIGH + 30,
Expand Down Expand Up @@ -327,12 +325,12 @@ def update_matrixcolor(self):
def color_inaktiv(self, color):
"""
Calculate the inactive color based on the given color and the COLOR_INAKTIV factor.

Parameters
----------
color : tuple
The RGB color to be modified.

Returns
-------
result : tuple
Expand All @@ -345,14 +343,14 @@ def color_inaktiv(self, color):
def get_nets(self, categorie, scenario):
"""
Get the nets for a given category and scenario from the connection table.

Parameters
----------
categorie : str
The category of the nets.
scenario : str
The scenario of the nets.

Returns
-------
color : tuple
Expand All @@ -374,7 +372,7 @@ def get_nets(self, categorie, scenario):
def create_net(self, form, x, y):
"""
Create a radio button representing a net at the given x and y coordinates.

Parameters
----------
form : QWidget
Expand All @@ -383,7 +381,7 @@ def create_net(self, form, x, y):
The x-coordinate of the net.
y : int
The y-coordinate of the net.

Returns
-------
radioButton : QRadioButton
Expand Down Expand Up @@ -415,7 +413,7 @@ def create_label(self, form, x, y, text=None):
x== -2 -> place wire text right
y== -1 -> pace wire number at top vertical
y== -2 -> pace wire text at bottom vertical

Parameters
----------
form : QWidget
Expand All @@ -430,7 +428,7 @@ def create_label(self, form, x, y, text=None):
-2: place wire text at the bottom
text : str, optional
The text to display on the label. If None, default text will be used based on the coordinates.

Returns
-------
label : QLabel
Expand Down Expand Up @@ -500,15 +498,15 @@ def create_label(self, form, x, y, text=None):
def edit_label(self, event, source_object=None):
"""
Handle the mouse press event on a label to allow editing of the label's text.

Parameters
----------
event : QMouseEvent
The mouse event that triggered the label editing.
source_object : QLabel, optional
The label that was clicked, triggering the edit. If None, the event's source will be used.
"""

if self.lineEdit.source_object is not None:
self.editfinish_label()
if event.button() == 1:
Expand All @@ -528,7 +526,7 @@ def editfinish_label(self):
def create_line(self, form, x, y):
"""
Create a line (horizontal or vertical) in the given form.

Parameters
----------
form : QWidget
Expand All @@ -537,7 +535,7 @@ def create_line(self, form, x, y):
The x-coordinate or special value indicating a horizontal line (-1).
y : int
The y-coordinate or special value indicating a vertical line (-1).

Returns
-------
line : QFrame
Expand Down Expand Up @@ -580,7 +578,7 @@ def retranslateUi(self, Form):
def mqttreceive(self, instName, msg):
"""
Handle incoming MQTT messages and update the GUI elements accordingly.

Parameters
----------
instName : str
Expand Down Expand Up @@ -839,7 +837,6 @@ def discardTable(self):
# mqttclient.init()

app = QtWidgets.QApplication(sys.argv)
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
window = Gui(app)
app.exec_()
# window.scope.anim.event_source.stop()
Loading
Loading