Refactored markers to their own class. Currently not functional.

pull/1/head
Rune B. Broberg 2019-08-29 12:19:58 +02:00
rodzic fa6e4c32e0
commit 509ea49372
3 zmienionych plików z 45 dodań i 34 usunięć

38
Marker.py 100644
Wyświetl plik

@ -0,0 +1,38 @@
# Copyright (c) $year Rune B. Broberg
from PyQt5 import QtGui, QtWidgets, QtCore
class Marker:
name = "Marker"
frequency = ""
color = QtGui.QColor()
def __init__(self, name, initialColor, frequency=""):
super().__init__()
self.name = name
self.color = initialColor
self.frequency = frequency
self.frequencyInput = QtWidgets.QLineEdit(frequency)
self.frequencyInput.setAlignment(QtCore.Qt.AlignRight)
self.frequencyInput.returnPressed.connect(lambda: self.setFrequency(self.frequencyInput.text()))
self.btnColorPicker = QtWidgets.QPushButton("")
self.btnColorPicker.setFixedWidth(20)
p = self.btnColorPicker.palette()
p.setColor(QtGui.QPalette.ButtonText, self.color)
self.btnColorPicker.setPalette(p)
self.btnColorPicker.clicked.connect(lambda: self.setColor(QtWidgets.QColorDialog.getColor()))
self.layout = QtWidgets.QHBoxLayout()
self.layout.addWidget(self.frequencyInput)
self.layout.addWidget(self.btnColorPicker)
def setFrequency(self, frequency):
self.frequency = frequency
def setColor(self, color):
self.color = color
def getRow(self):
return (QtWidgets.QLabel(self.name), self.layout)

Wyświetl plik

@ -1,6 +1,5 @@
# Copyright (c) 2019 Rune B. Broberg
import collections
import math
import threading
from time import sleep
from typing import List
@ -8,6 +7,7 @@ from typing import List
import serial
from PyQt5 import QtWidgets, QtCore, QtGui
from Marker import Marker
from SmithChart import SmithChart
from SweepWorker import SweepWorker
@ -92,39 +92,13 @@ class NanoVNASaver(QtWidgets.QWidget):
marker_control_box.setMaximumWidth(400)
marker_control_layout = QtWidgets.QFormLayout(marker_control_box)
self.marker1FrequencyInput = QtWidgets.QLineEdit("")
self.marker1FrequencyInput.setAlignment(QtCore.Qt.AlignRight)
self.marker1FrequencyInput.returnPressed.connect(lambda: self.smithChart.setMarker1(self.marker1FrequencyInput.text()))
self.marker1 = Marker("Marker 1", QtGui.QColor(255, 0, 20))
label, layout = self.marker1.getRow()
marker_control_layout.addRow(label, layout)
self.btnMarker1ColorPicker = QtWidgets.QPushButton("")
self.btnMarker1ColorPicker.setFixedWidth(20)
p = self.btnMarker1ColorPicker.palette()
p.setColor(QtGui.QPalette.ButtonText, self.smithChart.marker1Color)
self.btnMarker1ColorPicker.setPalette(p)
self.btnMarker1ColorPicker.clicked.connect(lambda: self.setMarker1Color(QtWidgets.QColorDialog.getColor()))
marker1layout = QtWidgets.QHBoxLayout()
marker1layout.addWidget(self.marker1FrequencyInput)
marker1layout.addWidget(self.btnMarker1ColorPicker)
marker_control_layout.addRow(QtWidgets.QLabel("Marker 1"), marker1layout)
self.marker2FrequencyInput = QtWidgets.QLineEdit("")
self.marker2FrequencyInput.setAlignment(QtCore.Qt.AlignRight)
self.marker2FrequencyInput.returnPressed.connect(lambda: self.smithChart.setMarker2(self.marker2FrequencyInput.text()))
self.btnMarker2ColorPicker = QtWidgets.QPushButton("")
self.btnMarker2ColorPicker.setFixedWidth(20)
p = self.btnMarker2ColorPicker.palette()
p.setColor(QtGui.QPalette.ButtonText, self.smithChart.marker2Color)
self.btnMarker2ColorPicker.setPalette(p)
self.btnMarker2ColorPicker.clicked.connect(lambda: self.setMarker2Color(QtWidgets.QColorDialog.getColor()))
marker2layout = QtWidgets.QHBoxLayout()
marker2layout.addWidget(self.marker2FrequencyInput)
marker2layout.addWidget(self.btnMarker2ColorPicker)
marker_control_layout.addRow(QtWidgets.QLabel("Marker 2"), marker2layout)
self.marker2 = Marker("Marker 2", QtGui.QColor(20, 0, 255))
label, layout = self.marker2.getRow()
marker_control_layout.addRow(label, layout)
self.marker1label = QtWidgets.QLabel("")
marker_control_layout.addRow(QtWidgets.QLabel("Marker 1: "), self.marker1label)

Wyświetl plik

@ -1,5 +1,4 @@
# Copyright 2019 Rune B. Broberg
import collections
from PyQt5 import QtWidgets