start repository
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
__pycache__
|
||||||
|
.venv
|
||||||
38
Highlighter.py
Normal file
38
Highlighter.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
from PySide6 import QtWidgets, QtGui, QtCore
|
||||||
|
|
||||||
|
from TextFormat import TextFormat
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Rule:
|
||||||
|
name: str
|
||||||
|
enable: bool
|
||||||
|
format: TextFormat
|
||||||
|
regex: QtCore.QRegularExpression
|
||||||
|
|
||||||
|
def isEnable(self):
|
||||||
|
return self.enable
|
||||||
|
|
||||||
|
def getTextCharFormat(self):
|
||||||
|
return self.format.format
|
||||||
|
|
||||||
|
def setPattern(self, pattern: str):
|
||||||
|
self.regex.setPattern(pattern)
|
||||||
|
|
||||||
|
class Highlighter(QtGui.QSyntaxHighlighter):
|
||||||
|
def __init__(self, document):
|
||||||
|
super().__init__(document)
|
||||||
|
self.rules: list[Rule] = []
|
||||||
|
|
||||||
|
def setListOfRules(self, rules: list[Rule]):
|
||||||
|
self.rules = rules
|
||||||
|
|
||||||
|
def highlightBlock(self, text):
|
||||||
|
for rule in self.rules:
|
||||||
|
if not rule.enable:
|
||||||
|
continue
|
||||||
|
i = rule.regex.globalMatch(text)
|
||||||
|
while i.hasNext():
|
||||||
|
match = i.next()
|
||||||
|
# print(f"0: {match.captured(0)}, 1: {match.captured(1)}, start: {match.capturedStart(1)}, lenght: {match.capturedLength(1)}")
|
||||||
|
self.setFormat(match.capturedStart(1), match.capturedLength(1), rule.getTextCharFormat())
|
||||||
455
MainWindow.ui
Normal file
455
MainWindow.ui
Normal file
@@ -0,0 +1,455 @@
|
|||||||
|
<?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>1024</width>
|
||||||
|
<height>480</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Serial Vizualizer</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_connect">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Connect</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_settings">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Settings</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="0,1,0">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_addPattern">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_removePattern">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="lst_regex">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropMode">
|
||||||
|
<enum>QAbstractItemView::InternalMove</enum>
|
||||||
|
</property>
|
||||||
|
<property name="defaultDropAction">
|
||||||
|
<enum>Qt::MoveAction</enum>
|
||||||
|
</property>
|
||||||
|
<property name="movement">
|
||||||
|
<enum>QListView::Snap</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Pattern info</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<property name="horizontalSpacing">
|
||||||
|
<number>20</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="lbl_namePattern">
|
||||||
|
<property name="text">
|
||||||
|
<string>Regex1</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Pattern:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="lbl_patternPattern">
|
||||||
|
<property name="text">
|
||||||
|
<string>"/d/d/d"</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>isValid:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLabel" name="lbl_isValidPattern">
|
||||||
|
<property name="text">
|
||||||
|
<string>True</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>Matches:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="lbl_matchesCountPattern">
|
||||||
|
<property name="text">
|
||||||
|
<string>120</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="text">
|
||||||
|
<string>Example:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0" colspan="2">
|
||||||
|
<widget class="QPushButton" name="btn_editPattern">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Edit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="lbl_examplePattern">
|
||||||
|
<property name="layoutDirection">
|
||||||
|
<enum>Qt::LeftToRight</enum>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: rgb(35, 35, 35);
|
||||||
|
color: rgb(244, 244, 244);</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>__example text__</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_timestamp">
|
||||||
|
<property name="text">
|
||||||
|
<string>Timestamp</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_clearMainTerminal">
|
||||||
|
<property name="text">
|
||||||
|
<string>Clear</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_autoScrollMainTermianl">
|
||||||
|
<property name="text">
|
||||||
|
<string>AutoScroll</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPlainTextEdit" name="txtEdit_mainTerminal"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_endLine">
|
||||||
|
<property name="text">
|
||||||
|
<string>EndLine</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_send">
|
||||||
|
<property name="text">
|
||||||
|
<string>Send</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_10">
|
||||||
|
<property name="text">
|
||||||
|
<string>Edit Commands</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>120</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
<property name="widgetResizable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>101</width>
|
||||||
|
<height>318</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_command1">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command1</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_command2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command2</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_command3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command3</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_command4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command4</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_command5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command5</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_command6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command6</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_command7">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command7</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_command8">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command8</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_command9">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command9</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btn_command10">
|
||||||
|
<property name="text">
|
||||||
|
<string>Command10</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_9">
|
||||||
|
<property name="text">
|
||||||
|
<string>PushButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
1480
MainWindow_ui.py
Normal file
1480
MainWindow_ui.py
Normal file
File diff suppressed because it is too large
Load Diff
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# SerialVisualizer
|
||||||
|
|
||||||
|
Program wspierający testowanie komunikacji z mikrokontrolerem za pomocą portu szeregowego.
|
||||||
224
RegexSettings.ui
Normal file
224
RegexSettings.ui
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>RegexSettings</class>
|
||||||
|
<widget class="QDialog" name="RegexSettings">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::ApplicationModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>463</width>
|
||||||
|
<height>269</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Regex Settings</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1,0">
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<property name="fieldGrowthPolicy">
|
||||||
|
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLineEdit" name="le_regexName"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="le_regexPattern"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_regexName">
|
||||||
|
<property name="text">
|
||||||
|
<string>Name</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_regexPattern">
|
||||||
|
<property name="text">
|
||||||
|
<string>Pattern</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gbox_font">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Font</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0" columnstretch="0,1,1,1,1" columnminimumwidth="100,0,0,0,0">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_echoFont">
|
||||||
|
<property name="text">
|
||||||
|
<string>Family:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_echoStyle">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Style:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" colspan="4">
|
||||||
|
<widget class="QFontComboBox" name="cb_regexFont">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="frame">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" colspan="4">
|
||||||
|
<widget class="QComboBox" name="cb_regexFontSize"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_echoFontSize">
|
||||||
|
<property name="text">
|
||||||
|
<string>Size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QToolButton" name="btn_regexFontBold">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>B</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="4">
|
||||||
|
<widget class="QPushButton" name="btn_regexFontColor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Color</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QToolButton" name="btn_regexFontItalic">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<italic>true</italic>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>I</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="3">
|
||||||
|
<widget class="QToolButton" name="btn_regexFontUnderline">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<underline>true</underline>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>U</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>RegexSettings</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>RegexSettings</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
169
RegexSettings_ui.py
Normal file
169
RegexSettings_ui.py
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## Form generated from reading UI file 'RegexSettings.ui'
|
||||||
|
##
|
||||||
|
## Created by: Qt User Interface Compiler version 6.2.3
|
||||||
|
##
|
||||||
|
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||||
|
QMetaObject, QObject, QPoint, QRect,
|
||||||
|
QSize, QTime, QUrl, Qt)
|
||||||
|
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||||
|
QFont, QFontDatabase, QGradient, QIcon,
|
||||||
|
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||||
|
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||||
|
from PySide6.QtWidgets import (QAbstractButton, QApplication, QComboBox, QDialog,
|
||||||
|
QDialogButtonBox, QFontComboBox, QFormLayout, QGridLayout,
|
||||||
|
QGroupBox, QLabel, QLineEdit, QPushButton,
|
||||||
|
QSizePolicy, QSpacerItem, QToolButton, QVBoxLayout,
|
||||||
|
QWidget)
|
||||||
|
|
||||||
|
class Ui_RegexSettings(object):
|
||||||
|
def setupUi(self, RegexSettings):
|
||||||
|
if not RegexSettings.objectName():
|
||||||
|
RegexSettings.setObjectName(u"RegexSettings")
|
||||||
|
RegexSettings.setWindowModality(Qt.ApplicationModal)
|
||||||
|
RegexSettings.resize(463, 269)
|
||||||
|
self.verticalLayout = QVBoxLayout(RegexSettings)
|
||||||
|
self.verticalLayout.setObjectName(u"verticalLayout")
|
||||||
|
self.formLayout = QFormLayout()
|
||||||
|
self.formLayout.setObjectName(u"formLayout")
|
||||||
|
self.formLayout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)
|
||||||
|
self.formLayout.setContentsMargins(9, -1, 10, -1)
|
||||||
|
self.le_regexName = QLineEdit(RegexSettings)
|
||||||
|
self.le_regexName.setObjectName(u"le_regexName")
|
||||||
|
|
||||||
|
self.formLayout.setWidget(1, QFormLayout.FieldRole, self.le_regexName)
|
||||||
|
|
||||||
|
self.le_regexPattern = QLineEdit(RegexSettings)
|
||||||
|
self.le_regexPattern.setObjectName(u"le_regexPattern")
|
||||||
|
|
||||||
|
self.formLayout.setWidget(2, QFormLayout.FieldRole, self.le_regexPattern)
|
||||||
|
|
||||||
|
self.lbl_regexName = QLabel(RegexSettings)
|
||||||
|
self.lbl_regexName.setObjectName(u"lbl_regexName")
|
||||||
|
|
||||||
|
self.formLayout.setWidget(1, QFormLayout.LabelRole, self.lbl_regexName)
|
||||||
|
|
||||||
|
self.lbl_regexPattern = QLabel(RegexSettings)
|
||||||
|
self.lbl_regexPattern.setObjectName(u"lbl_regexPattern")
|
||||||
|
|
||||||
|
self.formLayout.setWidget(2, QFormLayout.LabelRole, self.lbl_regexPattern)
|
||||||
|
|
||||||
|
|
||||||
|
self.verticalLayout.addLayout(self.formLayout)
|
||||||
|
|
||||||
|
self.gbox_font = QGroupBox(RegexSettings)
|
||||||
|
self.gbox_font.setObjectName(u"gbox_font")
|
||||||
|
self.gbox_font.setEnabled(True)
|
||||||
|
self.gbox_font.setChecked(False)
|
||||||
|
self.gridLayout_3 = QGridLayout(self.gbox_font)
|
||||||
|
self.gridLayout_3.setObjectName(u"gridLayout_3")
|
||||||
|
self.lbl_echoFont = QLabel(self.gbox_font)
|
||||||
|
self.lbl_echoFont.setObjectName(u"lbl_echoFont")
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.lbl_echoFont, 0, 0, 1, 1)
|
||||||
|
|
||||||
|
self.lbl_echoStyle = QLabel(self.gbox_font)
|
||||||
|
self.lbl_echoStyle.setObjectName(u"lbl_echoStyle")
|
||||||
|
self.lbl_echoStyle.setMaximumSize(QSize(16777215, 20))
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.lbl_echoStyle, 2, 0, 1, 1)
|
||||||
|
|
||||||
|
self.cb_regexFont = QFontComboBox(self.gbox_font)
|
||||||
|
self.cb_regexFont.setObjectName(u"cb_regexFont")
|
||||||
|
self.cb_regexFont.setEditable(False)
|
||||||
|
self.cb_regexFont.setFrame(True)
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.cb_regexFont, 0, 1, 1, 4)
|
||||||
|
|
||||||
|
self.cb_regexFontSize = QComboBox(self.gbox_font)
|
||||||
|
self.cb_regexFontSize.setObjectName(u"cb_regexFontSize")
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.cb_regexFontSize, 1, 1, 1, 4)
|
||||||
|
|
||||||
|
self.lbl_echoFontSize = QLabel(self.gbox_font)
|
||||||
|
self.lbl_echoFontSize.setObjectName(u"lbl_echoFontSize")
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.lbl_echoFontSize, 1, 0, 1, 1)
|
||||||
|
|
||||||
|
self.btn_regexFontBold = QToolButton(self.gbox_font)
|
||||||
|
self.btn_regexFontBold.setObjectName(u"btn_regexFontBold")
|
||||||
|
font = QFont()
|
||||||
|
font.setPointSize(10)
|
||||||
|
font.setBold(True)
|
||||||
|
self.btn_regexFontBold.setFont(font)
|
||||||
|
self.btn_regexFontBold.setCheckable(True)
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.btn_regexFontBold, 2, 1, 1, 1)
|
||||||
|
|
||||||
|
self.btn_regexFontColor = QPushButton(self.gbox_font)
|
||||||
|
self.btn_regexFontColor.setObjectName(u"btn_regexFontColor")
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.btn_regexFontColor, 2, 4, 1, 1)
|
||||||
|
|
||||||
|
self.btn_regexFontItalic = QToolButton(self.gbox_font)
|
||||||
|
self.btn_regexFontItalic.setObjectName(u"btn_regexFontItalic")
|
||||||
|
font1 = QFont()
|
||||||
|
font1.setPointSize(10)
|
||||||
|
font1.setItalic(True)
|
||||||
|
self.btn_regexFontItalic.setFont(font1)
|
||||||
|
self.btn_regexFontItalic.setCheckable(True)
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.btn_regexFontItalic, 2, 2, 1, 1)
|
||||||
|
|
||||||
|
self.btn_regexFontUnderline = QToolButton(self.gbox_font)
|
||||||
|
self.btn_regexFontUnderline.setObjectName(u"btn_regexFontUnderline")
|
||||||
|
font2 = QFont()
|
||||||
|
font2.setPointSize(10)
|
||||||
|
font2.setUnderline(True)
|
||||||
|
self.btn_regexFontUnderline.setFont(font2)
|
||||||
|
self.btn_regexFontUnderline.setCheckable(True)
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.btn_regexFontUnderline, 2, 3, 1, 1)
|
||||||
|
|
||||||
|
self.gridLayout_3.setColumnStretch(1, 1)
|
||||||
|
self.gridLayout_3.setColumnStretch(2, 1)
|
||||||
|
self.gridLayout_3.setColumnStretch(3, 1)
|
||||||
|
self.gridLayout_3.setColumnStretch(4, 1)
|
||||||
|
self.gridLayout_3.setColumnMinimumWidth(0, 100)
|
||||||
|
|
||||||
|
self.verticalLayout.addWidget(self.gbox_font)
|
||||||
|
|
||||||
|
self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||||
|
|
||||||
|
self.verticalLayout.addItem(self.verticalSpacer)
|
||||||
|
|
||||||
|
self.buttonBox = QDialogButtonBox(RegexSettings)
|
||||||
|
self.buttonBox.setObjectName(u"buttonBox")
|
||||||
|
self.buttonBox.setOrientation(Qt.Horizontal)
|
||||||
|
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
|
||||||
|
|
||||||
|
self.verticalLayout.addWidget(self.buttonBox)
|
||||||
|
|
||||||
|
self.verticalLayout.setStretch(2, 1)
|
||||||
|
|
||||||
|
self.retranslateUi(RegexSettings)
|
||||||
|
self.buttonBox.accepted.connect(RegexSettings.accept)
|
||||||
|
self.buttonBox.rejected.connect(RegexSettings.reject)
|
||||||
|
|
||||||
|
QMetaObject.connectSlotsByName(RegexSettings)
|
||||||
|
# setupUi
|
||||||
|
|
||||||
|
def retranslateUi(self, RegexSettings):
|
||||||
|
RegexSettings.setWindowTitle(QCoreApplication.translate("RegexSettings", u"Regex Settings", None))
|
||||||
|
self.lbl_regexName.setText(QCoreApplication.translate("RegexSettings", u"Name", None))
|
||||||
|
self.lbl_regexPattern.setText(QCoreApplication.translate("RegexSettings", u"Pattern", None))
|
||||||
|
self.gbox_font.setTitle(QCoreApplication.translate("RegexSettings", u"Font", None))
|
||||||
|
self.lbl_echoFont.setText(QCoreApplication.translate("RegexSettings", u"Family:", None))
|
||||||
|
self.lbl_echoStyle.setText(QCoreApplication.translate("RegexSettings", u"Style:", None))
|
||||||
|
self.lbl_echoFontSize.setText(QCoreApplication.translate("RegexSettings", u"Size:", None))
|
||||||
|
self.btn_regexFontBold.setText(QCoreApplication.translate("RegexSettings", u"B", None))
|
||||||
|
self.btn_regexFontColor.setText(QCoreApplication.translate("RegexSettings", u"Color", None))
|
||||||
|
self.btn_regexFontItalic.setText(QCoreApplication.translate("RegexSettings", u"I", None))
|
||||||
|
self.btn_regexFontUnderline.setText(QCoreApplication.translate("RegexSettings", u"U", None))
|
||||||
|
# retranslateUi
|
||||||
|
|
||||||
193
SettingsDialog.py
Normal file
193
SettingsDialog.py
Normal file
@@ -0,0 +1,193 @@
|
|||||||
|
from json import dumps
|
||||||
|
import json
|
||||||
|
from PySide6 import QtWidgets, QtGui, QtCore, QtSerialPort
|
||||||
|
from SettingsDialog_ui import Ui_SettingsDialog
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class SettingsWindow(QtWidgets.QDialog):
|
||||||
|
def __init__(self, settings: dict):
|
||||||
|
super().__init__()
|
||||||
|
self.ui = Ui_SettingsDialog()
|
||||||
|
self.ui.setupUi(self)
|
||||||
|
self.setWindowModality(QtCore.Qt.ApplicationModal)
|
||||||
|
# self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
||||||
|
|
||||||
|
self.setupListOptions()
|
||||||
|
self.setupConnectionOption()
|
||||||
|
self.setupFontsOption()
|
||||||
|
self.setupDisplayOption()
|
||||||
|
|
||||||
|
|
||||||
|
if settings:
|
||||||
|
self.connectionOption = settings["connection"]
|
||||||
|
self.fontsOption = settings["fonts"]
|
||||||
|
self.displayOption = settings["display"]
|
||||||
|
else:
|
||||||
|
self.saveConnectionSettings()
|
||||||
|
self.saveFontSettings()
|
||||||
|
self.saveDisplaySettings()
|
||||||
|
|
||||||
|
self.applyConnectionSettings()
|
||||||
|
self.applyFontSettings()
|
||||||
|
self.applyDisplaySettings()
|
||||||
|
|
||||||
|
|
||||||
|
def setupListOptions(self):
|
||||||
|
self.ui.lstview_options.addItems(["Connection", "Fonts", "Display"])
|
||||||
|
self.ui.lstview_options.itemClicked.connect(self.on_listItemClicked)
|
||||||
|
self.ui.lstview_options.setCurrentRow(0)
|
||||||
|
self.ui.stackedWidget.setCurrentIndex(0)
|
||||||
|
|
||||||
|
def setupConnectionOption(self):
|
||||||
|
self.connectionOption = dict()
|
||||||
|
self.on_refreshPortsClicked()
|
||||||
|
|
||||||
|
font = self.ui.cb_port.font()
|
||||||
|
font.setPointSize(8)
|
||||||
|
self.ui.cb_port.setFont(font)
|
||||||
|
|
||||||
|
self.ui.cb_baudrate.addItems([str(baudrate) for baudrate in QtSerialPort.QSerialPortInfo.standardBaudRates()])
|
||||||
|
self.ui.cb_baudrate.setCurrentText("9600")
|
||||||
|
self.ui.cb_databits.addItems([data_bits[4:] for data_bits in QtSerialPort.QSerialPort.DataBits.values])
|
||||||
|
self.ui.cb_databits.setCurrentText("8")
|
||||||
|
self.ui.cb_stopbits.addItems([stop_bits for stop_bits in QtSerialPort.QSerialPort.StopBits.values])
|
||||||
|
self.ui.cb_stopbits.setCurrentText("OneStop")
|
||||||
|
self.ui.cb_parity.addItems([parity for parity in QtSerialPort.QSerialPort.Parity.values])
|
||||||
|
self.ui.cb_parity.setCurrentText("NoParity")
|
||||||
|
|
||||||
|
self.ui.btn_refreshports.clicked.connect(self.on_refreshPortsClicked)
|
||||||
|
|
||||||
|
def setupFontsOption(self):
|
||||||
|
FONTSIZE = [str(x) for x in range(6,22) if (x<12 or x%2 == 0)]
|
||||||
|
|
||||||
|
self.fontsOption = {"terminal": {}, "echo": {}}
|
||||||
|
self._fontColor = {"terminal": (0,0,0), "echo": (0,0,0)}
|
||||||
|
self._backgroundTerminalColor = (255,255,255)
|
||||||
|
|
||||||
|
self.ui.cb_terminalFont.currentFontChanged.connect(lambda arg: self.on_fontFamilyChanged(arg, "terminal"))
|
||||||
|
|
||||||
|
self.ui.cb_terminalFontSize.addItems(FONTSIZE)
|
||||||
|
self.ui.cb_terminalFontSize.setCurrentIndex(4)
|
||||||
|
self.ui.cb_terminalFontSize.currentIndexChanged.connect(lambda arg: self.on_fontSizeChanged(arg, "terminal"))
|
||||||
|
|
||||||
|
self.ui.btn_terminalFontColor.clicked.connect(lambda: self.on_fontColorClicked("terminal"))
|
||||||
|
self.ui.btn_terminalBackgroundColor.clicked.connect(self.on_backgroundTerminalColorClicked)
|
||||||
|
|
||||||
|
self.ui.cb_echoFontSize.addItems(FONTSIZE)
|
||||||
|
self.ui.cb_echoFontSize.setCurrentIndex(4)
|
||||||
|
|
||||||
|
self.ui.btn_echoFontColor.clicked.connect(lambda: self.on_fontColorClicked("echo"))
|
||||||
|
|
||||||
|
def setupDisplayOption(self):
|
||||||
|
self.displayOption = dict()
|
||||||
|
|
||||||
|
def saveConnectionSettings(self):
|
||||||
|
self.connectionOption["com_port"] = self.ui.cb_port.currentText()
|
||||||
|
self.connectionOption["baudrate"] = self.ui.cb_baudrate.currentText()
|
||||||
|
self.connectionOption["data_bits"] = self.ui.cb_databits.currentText()
|
||||||
|
self.connectionOption["stop_bits"] = self.ui.cb_stopbits.currentText()
|
||||||
|
self.connectionOption["parity"] = self.ui.cb_parity.currentText()
|
||||||
|
|
||||||
|
def saveFontSettings(self):
|
||||||
|
self.fontsOption["terminal"]["font_family"] = self.ui.cb_terminalFont.currentText()
|
||||||
|
self.fontsOption["terminal"]["font_size"] = self.ui.cb_terminalFontSize.currentText()
|
||||||
|
self.fontsOption["terminal"]["bold"] = self.ui.btn_terminalFontBold.isChecked()
|
||||||
|
self.fontsOption["terminal"]["italic"] = self.ui.btn_terminalFontItalic.isChecked()
|
||||||
|
self.fontsOption["terminal"]["underline"] = self.ui.btn_terminalFontUnderline.isChecked()
|
||||||
|
self.fontsOption["terminal"]["fg_color"] = self._fontColor["terminal"]
|
||||||
|
self.fontsOption["terminal"]["bg_color"] = self._backgroundTerminalColor
|
||||||
|
|
||||||
|
self.fontsOption["echo"]["enable"] = self.ui.gbox_echoFont.isChecked()
|
||||||
|
self.fontsOption["echo"]["font_family"] = self.ui.cb_echoFont.currentText()
|
||||||
|
self.fontsOption["echo"]["font_size"] = self.ui.cb_echoFontSize.currentText()
|
||||||
|
self.fontsOption["echo"]["bold"] = self.ui.btn_echoFontBold.isChecked()
|
||||||
|
self.fontsOption["echo"]["italic"] = self.ui.btn_echoFontItalic.isChecked()
|
||||||
|
self.fontsOption["echo"]["underline"] = self.ui.btn_echoFontUnderline.isChecked()
|
||||||
|
self.fontsOption["echo"]["fg_color"] = self._fontColor["echo"]
|
||||||
|
|
||||||
|
def applyConnectionSettings(self):
|
||||||
|
self.on_refreshPortsClicked()
|
||||||
|
|
||||||
|
cb_port_items = [self.ui.cb_port.itemText(i) for i in range(self.ui.cb_port.count())]
|
||||||
|
if self.connectionOption["com_port"] in cb_port_items:
|
||||||
|
self.ui.cb_port.setCurrentText(self.connectionOption["com_port"])
|
||||||
|
|
||||||
|
self.ui.cb_baudrate.setCurrentText(self.connectionOption["baudrate"])
|
||||||
|
self.ui.cb_databits.setCurrentText(self.connectionOption["data_bits"])
|
||||||
|
self.ui.cb_stopbits.setCurrentText(self.connectionOption["stop_bits"])
|
||||||
|
self.ui.cb_parity.setCurrentText(self.connectionOption["parity"])
|
||||||
|
|
||||||
|
def applyFontSettings(self):
|
||||||
|
self.ui.cb_terminalFont.setCurrentText(self.fontsOption["terminal"]["font_family"])
|
||||||
|
self.ui.cb_terminalFontSize.setCurrentText(self.fontsOption["terminal"]["font_size"])
|
||||||
|
self.ui.btn_terminalFontBold.setChecked(self.fontsOption["terminal"]["bold"])
|
||||||
|
self.ui.btn_terminalFontItalic.setChecked(self.fontsOption["terminal"]["italic"])
|
||||||
|
self.ui.btn_terminalFontUnderline.setChecked(self.fontsOption["terminal"]["underline"])
|
||||||
|
self._fontColor["terminal"] = self.fontsOption["terminal"]["fg_color"]
|
||||||
|
self._backgroundTerminalColor = self.fontsOption["terminal"]["bg_color"]
|
||||||
|
|
||||||
|
self.ui.gbox_echoFont.setChecked(self.fontsOption["echo"]["enable"])
|
||||||
|
self.ui.cb_echoFont.setCurrentText(self.fontsOption["echo"]["font_family"])
|
||||||
|
self.ui.cb_echoFontSize.setCurrentText(self.fontsOption["echo"]["font_size"])
|
||||||
|
self.ui.btn_echoFontBold.setChecked(self.fontsOption["echo"]["bold"])
|
||||||
|
self.ui.btn_echoFontItalic.setChecked(self.fontsOption["echo"]["italic"])
|
||||||
|
self.ui.btn_echoFontUnderline.setChecked(self.fontsOption["echo"]["underline"])
|
||||||
|
self._fontColor["echo"] = self.fontsOption["echo"]["fg_color"]
|
||||||
|
|
||||||
|
def applyDisplaySettings(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def saveDisplaySettings(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def showEvent(self, arg__1: QtGui.QShowEvent) -> None:
|
||||||
|
self.applyConnectionSettings()
|
||||||
|
self.applyFontSettings()
|
||||||
|
return super().showEvent(arg__1)
|
||||||
|
|
||||||
|
def accept(self) -> None:
|
||||||
|
self.saveConnectionSettings()
|
||||||
|
self.saveFontSettings()
|
||||||
|
self.saveDisplaySettings()
|
||||||
|
return super().accept()
|
||||||
|
|
||||||
|
def getSettings(self):
|
||||||
|
return {
|
||||||
|
"connection": self.connectionOption,
|
||||||
|
"fonts" : self.fontsOption,
|
||||||
|
"display" : self.displayOption
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def on_listItemClicked(self, item: QtWidgets.QListWidgetItem):
|
||||||
|
self.ui.stackedWidget.setCurrentIndex(self.ui.lstview_options.currentRow())
|
||||||
|
|
||||||
|
def on_refreshPortsClicked(self):
|
||||||
|
self.ui.cb_port.clear()
|
||||||
|
|
||||||
|
for info in QtSerialPort.QSerialPortInfo.availablePorts():
|
||||||
|
self.ui.cb_port.addItem(f"{info.portName()} ({info.description()}, {info.manufacturer()})", info.portName())
|
||||||
|
|
||||||
|
def on_fontFamilyChanged(self, font: QtGui.QFont, sender: str):
|
||||||
|
if self.ui.gbox_echoFont.isChecked():
|
||||||
|
self.ui.cb_echoFont.setCurrentText(self.ui.cb_terminalFont.currentText())
|
||||||
|
|
||||||
|
def on_fontSizeChanged(self, index: int, sender: str):
|
||||||
|
if not self.ui.gbox_echoFont.isChecked():
|
||||||
|
self.ui.cb_echoFontSize.setCurrentText(self.ui.cb_terminalFontSize.currentText())
|
||||||
|
|
||||||
|
def on_fontColorClicked(self, sender: str):
|
||||||
|
current_color: QtGui.QColor = QtGui.QColor(*self.fontsOption[sender]["fg_color"])
|
||||||
|
new_color: QtGui.QColor = QtWidgets.QColorDialog.getColor(parent=self, initial=current_color)
|
||||||
|
if new_color.isValid():
|
||||||
|
self._fontColor[sender] = new_color.getRgb()
|
||||||
|
|
||||||
|
def on_backgroundTerminalColorClicked(self):
|
||||||
|
current_color: QtGui.QColor = QtGui.QColor(*self.fontsOption["terminal"]["bg_color"])
|
||||||
|
new_color: QtGui.QColor = QtWidgets.QColorDialog.getColor(parent=self, initial=current_color)
|
||||||
|
if new_color.isValid():
|
||||||
|
self._backgroundTerminalColor = new_color.getRgb()
|
||||||
|
|
||||||
|
|
||||||
607
SettingsDialog.ui
Normal file
607
SettingsDialog.ui
Normal file
@@ -0,0 +1,607 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>SettingsDialog</class>
|
||||||
|
<widget class="QDialog" name="SettingsDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>531</width>
|
||||||
|
<height>348</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Settings</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="lay_settings">
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="lstview_options">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>150</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>150</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="connection_page">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gbox_serialOptions">
|
||||||
|
<property name="title">
|
||||||
|
<string>Serial Port Options</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout" columnstretch="0,2" columnminimumwidth="100,0">
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QComboBox" name="cb_parity"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_parity">
|
||||||
|
<property name="text">
|
||||||
|
<string>Parity:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="cb_port"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_stopbits">
|
||||||
|
<property name="text">
|
||||||
|
<string>Stop bits:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0" colspan="2">
|
||||||
|
<widget class="QPushButton" name="btn_refreshports">
|
||||||
|
<property name="text">
|
||||||
|
<string>Re-Scan Serial Ports</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_baudrate">
|
||||||
|
<property name="text">
|
||||||
|
<string>Baudrate:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QComboBox" name="cb_stopbits"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="cb_baudrate"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_databits">
|
||||||
|
<property name="text">
|
||||||
|
<string>Data bits:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_port">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ports:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QComboBox" name="cb_databits"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="terminalFont_page">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="0,0,0">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gbox_terminalFont">
|
||||||
|
<property name="title">
|
||||||
|
<string>Terminal Font</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1,1,1,1" columnminimumwidth="100,10,10,10,10">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_terminalFont">
|
||||||
|
<property name="text">
|
||||||
|
<string>Family:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="4">
|
||||||
|
<widget class="QPushButton" name="btn_terminalFontColor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Color</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QToolButton" name="btn_terminalFontItalic">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<italic>true</italic>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>I</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="3">
|
||||||
|
<widget class="QToolButton" name="btn_terminalFontUnderline">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<underline>true</underline>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>U</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QToolButton" name="btn_terminalFontBold">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>B</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_terminalFontSize">
|
||||||
|
<property name="text">
|
||||||
|
<string>Size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_terminalStyle">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Style:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_terminalBackgroundColor">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Background:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" colspan="4">
|
||||||
|
<widget class="QFontComboBox" name="cb_termianalFont">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="frame">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" colspan="4">
|
||||||
|
<widget class="QComboBox" name="cb_terminalFontSize">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1" colspan="4">
|
||||||
|
<widget class="QPushButton" name="btn_terminalBackgroundColor">
|
||||||
|
<property name="text">
|
||||||
|
<string>background color</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gbox_echoFont">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Local Echo</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3" rowstretch="0,0,0" columnstretch="0,1,1,1,1" columnminimumwidth="100,0,0,0,0">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_echoFont">
|
||||||
|
<property name="text">
|
||||||
|
<string>Family:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_echoStyle">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Style:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" colspan="4">
|
||||||
|
<widget class="QFontComboBox" name="cb_echoFont">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="frame">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" colspan="4">
|
||||||
|
<widget class="QComboBox" name="cb_echoFontSize"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_echoFontSize">
|
||||||
|
<property name="text">
|
||||||
|
<string>Size:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QToolButton" name="btn_echoFontBold">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>B</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="4">
|
||||||
|
<widget class="QPushButton" name="btn_echoFontColor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Color</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QToolButton" name="btn_echoFontItalic">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<italic>true</italic>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>I</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="3">
|
||||||
|
<widget class="QToolButton" name="btn_echoFontUnderline">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
<underline>true</underline>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>U</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="terminalOptions_page">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gbox_timestamp">
|
||||||
|
<property name="title">
|
||||||
|
<string>Timestamp</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_timeFormat">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Time Format:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QRadioButton" name="rdbtn_ssms">
|
||||||
|
<property name="text">
|
||||||
|
<string>ss.ms</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QRadioButton" name="rdbtn_mmssms">
|
||||||
|
<property name="text">
|
||||||
|
<string>mm:ss.ms</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QRadioButton" name="rdbtn_hhmmssms">
|
||||||
|
<property name="text">
|
||||||
|
<string>hh:mm:ss.ms</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gbox_text">
|
||||||
|
<property name="title">
|
||||||
|
<string>Text</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout_2">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_endLine">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>End Line:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QRadioButton" name="rdbtn_crlf">
|
||||||
|
<property name="text">
|
||||||
|
<string>CR+LF</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QRadioButton" name="rdbtn_cr">
|
||||||
|
<property name="text">
|
||||||
|
<string>CR</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QRadioButton" name="rdbtn_lf">
|
||||||
|
<property name="text">
|
||||||
|
<string>LF</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="chbox_showAscii">
|
||||||
|
<property name="text">
|
||||||
|
<string>Show unprintable characters</string>
|
||||||
|
</property>
|
||||||
|
<property name="tristate">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="chbox_wrapText">
|
||||||
|
<property name="text">
|
||||||
|
<string>Wrap text</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
<property name="centerButtons">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>SettingsDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>SettingsDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
459
SettingsDialog_ui.py
Normal file
459
SettingsDialog_ui.py
Normal file
@@ -0,0 +1,459 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
## Form generated from reading UI file 'SerialVizualizerSettings.ui'
|
||||||
|
##
|
||||||
|
## Created by: Qt User Interface Compiler version 6.2.3
|
||||||
|
##
|
||||||
|
## WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
|
||||||
|
QMetaObject, QObject, QPoint, QRect,
|
||||||
|
QSize, QTime, QUrl, Qt)
|
||||||
|
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
|
||||||
|
QFont, QFontDatabase, QGradient, QIcon,
|
||||||
|
QImage, QKeySequence, QLinearGradient, QPainter,
|
||||||
|
QPalette, QPixmap, QRadialGradient, QTransform)
|
||||||
|
from PySide6.QtWidgets import (QAbstractButton, QApplication, QCheckBox, QComboBox,
|
||||||
|
QDialog, QDialogButtonBox, QFontComboBox, QFormLayout,
|
||||||
|
QGridLayout, QGroupBox, QHBoxLayout, QLabel,
|
||||||
|
QLayout, QListWidget, QListWidgetItem, QPushButton,
|
||||||
|
QRadioButton, QSizePolicy, QSpacerItem, QStackedWidget,
|
||||||
|
QToolButton, QVBoxLayout, QWidget)
|
||||||
|
|
||||||
|
class Ui_SettingsDialog(object):
|
||||||
|
def setupUi(self, SettingsDialog):
|
||||||
|
if not SettingsDialog.objectName():
|
||||||
|
SettingsDialog.setObjectName(u"SettingsDialog")
|
||||||
|
SettingsDialog.resize(531, 348)
|
||||||
|
font = QFont()
|
||||||
|
font.setPointSize(10)
|
||||||
|
SettingsDialog.setFont(font)
|
||||||
|
self.verticalLayout = QVBoxLayout(SettingsDialog)
|
||||||
|
self.verticalLayout.setObjectName(u"verticalLayout")
|
||||||
|
self.lay_settings = QHBoxLayout()
|
||||||
|
self.lay_settings.setObjectName(u"lay_settings")
|
||||||
|
self.lstview_options = QListWidget(SettingsDialog)
|
||||||
|
self.lstview_options.setObjectName(u"lstview_options")
|
||||||
|
sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
|
||||||
|
sizePolicy.setHorizontalStretch(0)
|
||||||
|
sizePolicy.setVerticalStretch(0)
|
||||||
|
sizePolicy.setHeightForWidth(self.lstview_options.sizePolicy().hasHeightForWidth())
|
||||||
|
self.lstview_options.setSizePolicy(sizePolicy)
|
||||||
|
self.lstview_options.setMinimumSize(QSize(150, 0))
|
||||||
|
self.lstview_options.setMaximumSize(QSize(150, 16777215))
|
||||||
|
|
||||||
|
self.lay_settings.addWidget(self.lstview_options)
|
||||||
|
|
||||||
|
self.stackedWidget = QStackedWidget(SettingsDialog)
|
||||||
|
self.stackedWidget.setObjectName(u"stackedWidget")
|
||||||
|
self.connection_page = QWidget()
|
||||||
|
self.connection_page.setObjectName(u"connection_page")
|
||||||
|
self.verticalLayout_2 = QVBoxLayout(self.connection_page)
|
||||||
|
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
|
||||||
|
self.gbox_serialOptions = QGroupBox(self.connection_page)
|
||||||
|
self.gbox_serialOptions.setObjectName(u"gbox_serialOptions")
|
||||||
|
self.gbox_serialOptions.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop)
|
||||||
|
self.gbox_serialOptions.setFlat(False)
|
||||||
|
self.gbox_serialOptions.setCheckable(False)
|
||||||
|
self.gridLayout = QGridLayout(self.gbox_serialOptions)
|
||||||
|
self.gridLayout.setObjectName(u"gridLayout")
|
||||||
|
self.cb_parity = QComboBox(self.gbox_serialOptions)
|
||||||
|
self.cb_parity.setObjectName(u"cb_parity")
|
||||||
|
|
||||||
|
self.gridLayout.addWidget(self.cb_parity, 3, 1, 1, 1)
|
||||||
|
|
||||||
|
self.lbl_parity = QLabel(self.gbox_serialOptions)
|
||||||
|
self.lbl_parity.setObjectName(u"lbl_parity")
|
||||||
|
|
||||||
|
self.gridLayout.addWidget(self.lbl_parity, 3, 0, 1, 1)
|
||||||
|
|
||||||
|
self.cb_port = QComboBox(self.gbox_serialOptions)
|
||||||
|
self.cb_port.setObjectName(u"cb_port")
|
||||||
|
|
||||||
|
self.gridLayout.addWidget(self.cb_port, 0, 1, 1, 1)
|
||||||
|
|
||||||
|
self.lbl_stopbits = QLabel(self.gbox_serialOptions)
|
||||||
|
self.lbl_stopbits.setObjectName(u"lbl_stopbits")
|
||||||
|
|
||||||
|
self.gridLayout.addWidget(self.lbl_stopbits, 4, 0, 1, 1)
|
||||||
|
|
||||||
|
self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||||
|
|
||||||
|
self.gridLayout.addItem(self.verticalSpacer, 5, 0, 1, 1)
|
||||||
|
|
||||||
|
self.btn_refreshports = QPushButton(self.gbox_serialOptions)
|
||||||
|
self.btn_refreshports.setObjectName(u"btn_refreshports")
|
||||||
|
|
||||||
|
self.gridLayout.addWidget(self.btn_refreshports, 6, 0, 1, 2)
|
||||||
|
|
||||||
|
self.lbl_baudrate = QLabel(self.gbox_serialOptions)
|
||||||
|
self.lbl_baudrate.setObjectName(u"lbl_baudrate")
|
||||||
|
|
||||||
|
self.gridLayout.addWidget(self.lbl_baudrate, 1, 0, 1, 1)
|
||||||
|
|
||||||
|
self.cb_stopbits = QComboBox(self.gbox_serialOptions)
|
||||||
|
self.cb_stopbits.setObjectName(u"cb_stopbits")
|
||||||
|
|
||||||
|
self.gridLayout.addWidget(self.cb_stopbits, 4, 1, 1, 1)
|
||||||
|
|
||||||
|
self.cb_baudrate = QComboBox(self.gbox_serialOptions)
|
||||||
|
self.cb_baudrate.setObjectName(u"cb_baudrate")
|
||||||
|
|
||||||
|
self.gridLayout.addWidget(self.cb_baudrate, 1, 1, 1, 1)
|
||||||
|
|
||||||
|
self.lbl_databits = QLabel(self.gbox_serialOptions)
|
||||||
|
self.lbl_databits.setObjectName(u"lbl_databits")
|
||||||
|
|
||||||
|
self.gridLayout.addWidget(self.lbl_databits, 2, 0, 1, 1)
|
||||||
|
|
||||||
|
self.lbl_port = QLabel(self.gbox_serialOptions)
|
||||||
|
self.lbl_port.setObjectName(u"lbl_port")
|
||||||
|
|
||||||
|
self.gridLayout.addWidget(self.lbl_port, 0, 0, 1, 1)
|
||||||
|
|
||||||
|
self.cb_databits = QComboBox(self.gbox_serialOptions)
|
||||||
|
self.cb_databits.setObjectName(u"cb_databits")
|
||||||
|
|
||||||
|
self.gridLayout.addWidget(self.cb_databits, 2, 1, 1, 1)
|
||||||
|
|
||||||
|
self.gridLayout.setColumnStretch(1, 2)
|
||||||
|
self.gridLayout.setColumnMinimumWidth(0, 100)
|
||||||
|
|
||||||
|
self.verticalLayout_2.addWidget(self.gbox_serialOptions)
|
||||||
|
|
||||||
|
self.stackedWidget.addWidget(self.connection_page)
|
||||||
|
self.terminalFont_page = QWidget()
|
||||||
|
self.terminalFont_page.setObjectName(u"terminalFont_page")
|
||||||
|
self.verticalLayout_3 = QVBoxLayout(self.terminalFont_page)
|
||||||
|
self.verticalLayout_3.setObjectName(u"verticalLayout_3")
|
||||||
|
self.gbox_terminalFont = QGroupBox(self.terminalFont_page)
|
||||||
|
self.gbox_terminalFont.setObjectName(u"gbox_terminalFont")
|
||||||
|
self.gridLayout_2 = QGridLayout(self.gbox_terminalFont)
|
||||||
|
self.gridLayout_2.setObjectName(u"gridLayout_2")
|
||||||
|
self.gridLayout_2.setSizeConstraint(QLayout.SetDefaultConstraint)
|
||||||
|
self.lbl_terminalFont = QLabel(self.gbox_terminalFont)
|
||||||
|
self.lbl_terminalFont.setObjectName(u"lbl_terminalFont")
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.lbl_terminalFont, 0, 0, 1, 1)
|
||||||
|
|
||||||
|
self.btn_terminalFontColor = QPushButton(self.gbox_terminalFont)
|
||||||
|
self.btn_terminalFontColor.setObjectName(u"btn_terminalFontColor")
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.btn_terminalFontColor, 2, 4, 1, 1)
|
||||||
|
|
||||||
|
self.btn_terminalFontItalic = QToolButton(self.gbox_terminalFont)
|
||||||
|
self.btn_terminalFontItalic.setObjectName(u"btn_terminalFontItalic")
|
||||||
|
font1 = QFont()
|
||||||
|
font1.setPointSize(10)
|
||||||
|
font1.setItalic(True)
|
||||||
|
self.btn_terminalFontItalic.setFont(font1)
|
||||||
|
self.btn_terminalFontItalic.setCheckable(True)
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.btn_terminalFontItalic, 2, 2, 1, 1)
|
||||||
|
|
||||||
|
self.btn_terminalFontUnderline = QToolButton(self.gbox_terminalFont)
|
||||||
|
self.btn_terminalFontUnderline.setObjectName(u"btn_terminalFontUnderline")
|
||||||
|
font2 = QFont()
|
||||||
|
font2.setPointSize(10)
|
||||||
|
font2.setUnderline(True)
|
||||||
|
self.btn_terminalFontUnderline.setFont(font2)
|
||||||
|
self.btn_terminalFontUnderline.setCheckable(True)
|
||||||
|
self.btn_terminalFontUnderline.setChecked(False)
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.btn_terminalFontUnderline, 2, 3, 1, 1)
|
||||||
|
|
||||||
|
self.btn_terminalFontBold = QToolButton(self.gbox_terminalFont)
|
||||||
|
self.btn_terminalFontBold.setObjectName(u"btn_terminalFontBold")
|
||||||
|
font3 = QFont()
|
||||||
|
font3.setPointSize(10)
|
||||||
|
font3.setBold(True)
|
||||||
|
self.btn_terminalFontBold.setFont(font3)
|
||||||
|
self.btn_terminalFontBold.setCheckable(True)
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.btn_terminalFontBold, 2, 1, 1, 1)
|
||||||
|
|
||||||
|
self.lbl_terminalFontSize = QLabel(self.gbox_terminalFont)
|
||||||
|
self.lbl_terminalFontSize.setObjectName(u"lbl_terminalFontSize")
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.lbl_terminalFontSize, 1, 0, 1, 1)
|
||||||
|
|
||||||
|
self.lbl_terminalStyle = QLabel(self.gbox_terminalFont)
|
||||||
|
self.lbl_terminalStyle.setObjectName(u"lbl_terminalStyle")
|
||||||
|
sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
|
||||||
|
sizePolicy1.setHorizontalStretch(0)
|
||||||
|
sizePolicy1.setVerticalStretch(0)
|
||||||
|
sizePolicy1.setHeightForWidth(self.lbl_terminalStyle.sizePolicy().hasHeightForWidth())
|
||||||
|
self.lbl_terminalStyle.setSizePolicy(sizePolicy1)
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.lbl_terminalStyle, 2, 0, 1, 1)
|
||||||
|
|
||||||
|
self.lbl_terminalBackgroundColor = QLabel(self.gbox_terminalFont)
|
||||||
|
self.lbl_terminalBackgroundColor.setObjectName(u"lbl_terminalBackgroundColor")
|
||||||
|
sizePolicy2 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
|
||||||
|
sizePolicy2.setHorizontalStretch(0)
|
||||||
|
sizePolicy2.setVerticalStretch(0)
|
||||||
|
sizePolicy2.setHeightForWidth(self.lbl_terminalBackgroundColor.sizePolicy().hasHeightForWidth())
|
||||||
|
self.lbl_terminalBackgroundColor.setSizePolicy(sizePolicy2)
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.lbl_terminalBackgroundColor, 3, 0, 1, 1)
|
||||||
|
|
||||||
|
self.cb_terminalFont = QFontComboBox(self.gbox_terminalFont)
|
||||||
|
self.cb_terminalFont.setObjectName(u"cb_termianalFont")
|
||||||
|
sizePolicy3 = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
|
||||||
|
sizePolicy3.setHorizontalStretch(0)
|
||||||
|
sizePolicy3.setVerticalStretch(0)
|
||||||
|
sizePolicy3.setHeightForWidth(self.cb_terminalFont.sizePolicy().hasHeightForWidth())
|
||||||
|
self.cb_terminalFont.setSizePolicy(sizePolicy3)
|
||||||
|
self.cb_terminalFont.setEditable(False)
|
||||||
|
self.cb_terminalFont.setFrame(True)
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.cb_terminalFont, 0, 1, 1, 4)
|
||||||
|
|
||||||
|
self.cb_terminalFontSize = QComboBox(self.gbox_terminalFont)
|
||||||
|
self.cb_terminalFontSize.setObjectName(u"cb_terminalFontSize")
|
||||||
|
sizePolicy3.setHeightForWidth(self.cb_terminalFontSize.sizePolicy().hasHeightForWidth())
|
||||||
|
self.cb_terminalFontSize.setSizePolicy(sizePolicy3)
|
||||||
|
self.cb_terminalFontSize.setEditable(False)
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.cb_terminalFontSize, 1, 1, 1, 4)
|
||||||
|
|
||||||
|
self.btn_terminalBackgroundColor = QPushButton(self.gbox_terminalFont)
|
||||||
|
self.btn_terminalBackgroundColor.setObjectName(u"btn_terminalBackgroundColor")
|
||||||
|
|
||||||
|
self.gridLayout_2.addWidget(self.btn_terminalBackgroundColor, 3, 1, 1, 4)
|
||||||
|
|
||||||
|
self.gridLayout_2.setColumnStretch(1, 1)
|
||||||
|
self.gridLayout_2.setColumnStretch(2, 1)
|
||||||
|
self.gridLayout_2.setColumnStretch(3, 1)
|
||||||
|
self.gridLayout_2.setColumnStretch(4, 1)
|
||||||
|
self.gridLayout_2.setColumnMinimumWidth(0, 100)
|
||||||
|
self.gridLayout_2.setColumnMinimumWidth(1, 10)
|
||||||
|
self.gridLayout_2.setColumnMinimumWidth(2, 10)
|
||||||
|
self.gridLayout_2.setColumnMinimumWidth(3, 10)
|
||||||
|
self.gridLayout_2.setColumnMinimumWidth(4, 10)
|
||||||
|
|
||||||
|
self.verticalLayout_3.addWidget(self.gbox_terminalFont)
|
||||||
|
|
||||||
|
self.gbox_echoFont = QGroupBox(self.terminalFont_page)
|
||||||
|
self.gbox_echoFont.setObjectName(u"gbox_echoFont")
|
||||||
|
self.gbox_echoFont.setEnabled(True)
|
||||||
|
self.gbox_echoFont.setCheckable(True)
|
||||||
|
self.gbox_echoFont.setChecked(False)
|
||||||
|
self.gridLayout_3 = QGridLayout(self.gbox_echoFont)
|
||||||
|
self.gridLayout_3.setObjectName(u"gridLayout_3")
|
||||||
|
self.lbl_echoFont = QLabel(self.gbox_echoFont)
|
||||||
|
self.lbl_echoFont.setObjectName(u"lbl_echoFont")
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.lbl_echoFont, 0, 0, 1, 1)
|
||||||
|
|
||||||
|
self.lbl_echoStyle = QLabel(self.gbox_echoFont)
|
||||||
|
self.lbl_echoStyle.setObjectName(u"lbl_echoStyle")
|
||||||
|
self.lbl_echoStyle.setMaximumSize(QSize(16777215, 20))
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.lbl_echoStyle, 2, 0, 1, 1)
|
||||||
|
|
||||||
|
self.cb_echoFont = QFontComboBox(self.gbox_echoFont)
|
||||||
|
self.cb_echoFont.setObjectName(u"cb_echoFont")
|
||||||
|
self.cb_echoFont.setEditable(False)
|
||||||
|
self.cb_echoFont.setFrame(True)
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.cb_echoFont, 0, 1, 1, 4)
|
||||||
|
|
||||||
|
self.cb_echoFontSize = QComboBox(self.gbox_echoFont)
|
||||||
|
self.cb_echoFontSize.setObjectName(u"cb_echoFontSize")
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.cb_echoFontSize, 1, 1, 1, 4)
|
||||||
|
|
||||||
|
self.lbl_echoFontSize = QLabel(self.gbox_echoFont)
|
||||||
|
self.lbl_echoFontSize.setObjectName(u"lbl_echoFontSize")
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.lbl_echoFontSize, 1, 0, 1, 1)
|
||||||
|
|
||||||
|
self.btn_echoFontBold = QToolButton(self.gbox_echoFont)
|
||||||
|
self.btn_echoFontBold.setObjectName(u"btn_echoFontBold")
|
||||||
|
self.btn_echoFontBold.setFont(font3)
|
||||||
|
self.btn_echoFontBold.setCheckable(True)
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.btn_echoFontBold, 2, 1, 1, 1)
|
||||||
|
|
||||||
|
self.btn_echoFontColor = QPushButton(self.gbox_echoFont)
|
||||||
|
self.btn_echoFontColor.setObjectName(u"btn_echoFontColor")
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.btn_echoFontColor, 2, 4, 1, 1)
|
||||||
|
|
||||||
|
self.btn_echoFontItalic = QToolButton(self.gbox_echoFont)
|
||||||
|
self.btn_echoFontItalic.setObjectName(u"btn_echoFontItalic")
|
||||||
|
self.btn_echoFontItalic.setFont(font1)
|
||||||
|
self.btn_echoFontItalic.setCheckable(True)
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.btn_echoFontItalic, 2, 2, 1, 1)
|
||||||
|
|
||||||
|
self.btn_echoFontUnderline = QToolButton(self.gbox_echoFont)
|
||||||
|
self.btn_echoFontUnderline.setObjectName(u"btn_echoFontUnderline")
|
||||||
|
self.btn_echoFontUnderline.setFont(font2)
|
||||||
|
self.btn_echoFontUnderline.setCheckable(True)
|
||||||
|
|
||||||
|
self.gridLayout_3.addWidget(self.btn_echoFontUnderline, 2, 3, 1, 1)
|
||||||
|
|
||||||
|
self.gridLayout_3.setColumnStretch(1, 1)
|
||||||
|
self.gridLayout_3.setColumnStretch(2, 1)
|
||||||
|
self.gridLayout_3.setColumnStretch(3, 1)
|
||||||
|
self.gridLayout_3.setColumnStretch(4, 1)
|
||||||
|
self.gridLayout_3.setColumnMinimumWidth(0, 100)
|
||||||
|
|
||||||
|
self.verticalLayout_3.addWidget(self.gbox_echoFont)
|
||||||
|
|
||||||
|
self.verticalSpacer_2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||||
|
|
||||||
|
self.verticalLayout_3.addItem(self.verticalSpacer_2)
|
||||||
|
|
||||||
|
self.stackedWidget.addWidget(self.terminalFont_page)
|
||||||
|
self.terminalOptions_page = QWidget()
|
||||||
|
self.terminalOptions_page.setObjectName(u"terminalOptions_page")
|
||||||
|
self.verticalLayout_4 = QVBoxLayout(self.terminalOptions_page)
|
||||||
|
self.verticalLayout_4.setObjectName(u"verticalLayout_4")
|
||||||
|
self.gbox_timestamp = QGroupBox(self.terminalOptions_page)
|
||||||
|
self.gbox_timestamp.setObjectName(u"gbox_timestamp")
|
||||||
|
self.gbox_timestamp.setCheckable(False)
|
||||||
|
self.gbox_timestamp.setChecked(False)
|
||||||
|
self.formLayout = QFormLayout(self.gbox_timestamp)
|
||||||
|
self.formLayout.setObjectName(u"formLayout")
|
||||||
|
self.lbl_timeFormat = QLabel(self.gbox_timestamp)
|
||||||
|
self.lbl_timeFormat.setObjectName(u"lbl_timeFormat")
|
||||||
|
self.lbl_timeFormat.setMinimumSize(QSize(100, 0))
|
||||||
|
|
||||||
|
self.formLayout.setWidget(0, QFormLayout.LabelRole, self.lbl_timeFormat)
|
||||||
|
|
||||||
|
self.rdbtn_ssms = QRadioButton(self.gbox_timestamp)
|
||||||
|
self.rdbtn_ssms.setObjectName(u"rdbtn_ssms")
|
||||||
|
self.rdbtn_ssms.setChecked(True)
|
||||||
|
|
||||||
|
self.formLayout.setWidget(0, QFormLayout.FieldRole, self.rdbtn_ssms)
|
||||||
|
|
||||||
|
self.rdbtn_mmssms = QRadioButton(self.gbox_timestamp)
|
||||||
|
self.rdbtn_mmssms.setObjectName(u"rdbtn_mmssms")
|
||||||
|
|
||||||
|
self.formLayout.setWidget(1, QFormLayout.FieldRole, self.rdbtn_mmssms)
|
||||||
|
|
||||||
|
self.rdbtn_hhmmssms = QRadioButton(self.gbox_timestamp)
|
||||||
|
self.rdbtn_hhmmssms.setObjectName(u"rdbtn_hhmmssms")
|
||||||
|
|
||||||
|
self.formLayout.setWidget(2, QFormLayout.FieldRole, self.rdbtn_hhmmssms)
|
||||||
|
|
||||||
|
|
||||||
|
self.verticalLayout_4.addWidget(self.gbox_timestamp)
|
||||||
|
|
||||||
|
self.gbox_text = QGroupBox(self.terminalOptions_page)
|
||||||
|
self.gbox_text.setObjectName(u"gbox_text")
|
||||||
|
self.formLayout_2 = QFormLayout(self.gbox_text)
|
||||||
|
self.formLayout_2.setObjectName(u"formLayout_2")
|
||||||
|
self.lbl_endLine = QLabel(self.gbox_text)
|
||||||
|
self.lbl_endLine.setObjectName(u"lbl_endLine")
|
||||||
|
self.lbl_endLine.setMinimumSize(QSize(100, 0))
|
||||||
|
|
||||||
|
self.formLayout_2.setWidget(0, QFormLayout.LabelRole, self.lbl_endLine)
|
||||||
|
|
||||||
|
self.rdbtn_crlf = QRadioButton(self.gbox_text)
|
||||||
|
self.rdbtn_crlf.setObjectName(u"rdbtn_crlf")
|
||||||
|
self.rdbtn_crlf.setChecked(True)
|
||||||
|
|
||||||
|
self.formLayout_2.setWidget(0, QFormLayout.FieldRole, self.rdbtn_crlf)
|
||||||
|
|
||||||
|
self.rdbtn_cr = QRadioButton(self.gbox_text)
|
||||||
|
self.rdbtn_cr.setObjectName(u"rdbtn_cr")
|
||||||
|
|
||||||
|
self.formLayout_2.setWidget(1, QFormLayout.FieldRole, self.rdbtn_cr)
|
||||||
|
|
||||||
|
self.rdbtn_lf = QRadioButton(self.gbox_text)
|
||||||
|
self.rdbtn_lf.setObjectName(u"rdbtn_lf")
|
||||||
|
|
||||||
|
self.formLayout_2.setWidget(2, QFormLayout.FieldRole, self.rdbtn_lf)
|
||||||
|
|
||||||
|
self.chbox_showAscii = QCheckBox(self.gbox_text)
|
||||||
|
self.chbox_showAscii.setObjectName(u"chbox_showAscii")
|
||||||
|
self.chbox_showAscii.setTristate(False)
|
||||||
|
|
||||||
|
self.formLayout_2.setWidget(3, QFormLayout.SpanningRole, self.chbox_showAscii)
|
||||||
|
|
||||||
|
self.chbox_wrapText = QCheckBox(self.gbox_text)
|
||||||
|
self.chbox_wrapText.setObjectName(u"chbox_wrapText")
|
||||||
|
|
||||||
|
self.formLayout_2.setWidget(4, QFormLayout.SpanningRole, self.chbox_wrapText)
|
||||||
|
|
||||||
|
|
||||||
|
self.verticalLayout_4.addWidget(self.gbox_text)
|
||||||
|
|
||||||
|
self.verticalSpacer_3 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
|
||||||
|
|
||||||
|
self.verticalLayout_4.addItem(self.verticalSpacer_3)
|
||||||
|
|
||||||
|
self.verticalLayout_4.setStretch(2, 1)
|
||||||
|
self.stackedWidget.addWidget(self.terminalOptions_page)
|
||||||
|
|
||||||
|
self.lay_settings.addWidget(self.stackedWidget)
|
||||||
|
|
||||||
|
|
||||||
|
self.verticalLayout.addLayout(self.lay_settings)
|
||||||
|
|
||||||
|
self.buttonBox = QDialogButtonBox(SettingsDialog)
|
||||||
|
self.buttonBox.setObjectName(u"buttonBox")
|
||||||
|
self.buttonBox.setOrientation(Qt.Horizontal)
|
||||||
|
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok)
|
||||||
|
self.buttonBox.setCenterButtons(False)
|
||||||
|
|
||||||
|
self.verticalLayout.addWidget(self.buttonBox)
|
||||||
|
|
||||||
|
|
||||||
|
self.retranslateUi(SettingsDialog)
|
||||||
|
self.buttonBox.accepted.connect(SettingsDialog.accept)
|
||||||
|
self.buttonBox.rejected.connect(SettingsDialog.reject)
|
||||||
|
|
||||||
|
self.stackedWidget.setCurrentIndex(2)
|
||||||
|
|
||||||
|
|
||||||
|
QMetaObject.connectSlotsByName(SettingsDialog)
|
||||||
|
# setupUi
|
||||||
|
|
||||||
|
def retranslateUi(self, SettingsDialog):
|
||||||
|
SettingsDialog.setWindowTitle(QCoreApplication.translate("SettingsDialog", u"Settings", None))
|
||||||
|
self.gbox_serialOptions.setTitle(QCoreApplication.translate("SettingsDialog", u"Serial Port Options", None))
|
||||||
|
self.lbl_parity.setText(QCoreApplication.translate("SettingsDialog", u"Parity:", None))
|
||||||
|
self.lbl_stopbits.setText(QCoreApplication.translate("SettingsDialog", u"Stop bits:", None))
|
||||||
|
self.btn_refreshports.setText(QCoreApplication.translate("SettingsDialog", u"Re-Scan Serial Ports", None))
|
||||||
|
self.lbl_baudrate.setText(QCoreApplication.translate("SettingsDialog", u"Baudrate:", None))
|
||||||
|
self.lbl_databits.setText(QCoreApplication.translate("SettingsDialog", u"Data bits:", None))
|
||||||
|
self.lbl_port.setText(QCoreApplication.translate("SettingsDialog", u"Ports:", None))
|
||||||
|
self.gbox_terminalFont.setTitle(QCoreApplication.translate("SettingsDialog", u"Terminal Font", None))
|
||||||
|
self.lbl_terminalFont.setText(QCoreApplication.translate("SettingsDialog", u"Family:", None))
|
||||||
|
self.btn_terminalFontColor.setText(QCoreApplication.translate("SettingsDialog", u"Color", None))
|
||||||
|
self.btn_terminalFontItalic.setText(QCoreApplication.translate("SettingsDialog", u"I", None))
|
||||||
|
self.btn_terminalFontUnderline.setText(QCoreApplication.translate("SettingsDialog", u"U", None))
|
||||||
|
self.btn_terminalFontBold.setText(QCoreApplication.translate("SettingsDialog", u"B", None))
|
||||||
|
self.lbl_terminalFontSize.setText(QCoreApplication.translate("SettingsDialog", u"Size:", None))
|
||||||
|
self.lbl_terminalStyle.setText(QCoreApplication.translate("SettingsDialog", u"Style:", None))
|
||||||
|
self.lbl_terminalBackgroundColor.setText(QCoreApplication.translate("SettingsDialog", u"Background:", None))
|
||||||
|
self.btn_terminalBackgroundColor.setText(QCoreApplication.translate("SettingsDialog", u"background color", None))
|
||||||
|
self.gbox_echoFont.setTitle(QCoreApplication.translate("SettingsDialog", u"Local Echo", None))
|
||||||
|
self.lbl_echoFont.setText(QCoreApplication.translate("SettingsDialog", u"Family:", None))
|
||||||
|
self.lbl_echoStyle.setText(QCoreApplication.translate("SettingsDialog", u"Style:", None))
|
||||||
|
self.lbl_echoFontSize.setText(QCoreApplication.translate("SettingsDialog", u"Size:", None))
|
||||||
|
self.btn_echoFontBold.setText(QCoreApplication.translate("SettingsDialog", u"B", None))
|
||||||
|
self.btn_echoFontColor.setText(QCoreApplication.translate("SettingsDialog", u"Color", None))
|
||||||
|
self.btn_echoFontItalic.setText(QCoreApplication.translate("SettingsDialog", u"I", None))
|
||||||
|
self.btn_echoFontUnderline.setText(QCoreApplication.translate("SettingsDialog", u"U", None))
|
||||||
|
self.gbox_timestamp.setTitle(QCoreApplication.translate("SettingsDialog", u"Timestamp", None))
|
||||||
|
self.lbl_timeFormat.setText(QCoreApplication.translate("SettingsDialog", u"Time Format:", None))
|
||||||
|
self.rdbtn_ssms.setText(QCoreApplication.translate("SettingsDialog", u"ss.ms", None))
|
||||||
|
self.rdbtn_mmssms.setText(QCoreApplication.translate("SettingsDialog", u"mm:ss.ms", None))
|
||||||
|
self.rdbtn_hhmmssms.setText(QCoreApplication.translate("SettingsDialog", u"hh:mm:ss.ms", None))
|
||||||
|
self.gbox_text.setTitle(QCoreApplication.translate("SettingsDialog", u"Text", None))
|
||||||
|
self.lbl_endLine.setText(QCoreApplication.translate("SettingsDialog", u"End Line:", None))
|
||||||
|
self.rdbtn_crlf.setText(QCoreApplication.translate("SettingsDialog", u"CR+LF", None))
|
||||||
|
self.rdbtn_cr.setText(QCoreApplication.translate("SettingsDialog", u"CR", None))
|
||||||
|
self.rdbtn_lf.setText(QCoreApplication.translate("SettingsDialog", u"LF", None))
|
||||||
|
self.chbox_showAscii.setText(QCoreApplication.translate("SettingsDialog", u"Show unprintable characters", None))
|
||||||
|
self.chbox_wrapText.setText(QCoreApplication.translate("SettingsDialog", u"Wrap text", None))
|
||||||
|
# retranslateUi
|
||||||
|
|
||||||
26
TextFormat.py
Normal file
26
TextFormat.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
from dataclasses import dataclass, field
|
||||||
|
from PySide6 import QtWidgets, QtGui, QtCore
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class TextFormat:
|
||||||
|
font_family: str = "Segoe UI"
|
||||||
|
font_size: str = "10"
|
||||||
|
bold: bool = False
|
||||||
|
italic: bool = False
|
||||||
|
underline: bool = False
|
||||||
|
fg_color: tuple[int] = field(default=(0,0,0))
|
||||||
|
format: QtGui.QTextCharFormat = field(default_factory=QtGui.QTextCharFormat, init=False, repr=False)
|
||||||
|
|
||||||
|
def __post_init__(self):
|
||||||
|
format = QtGui.QTextCharFormat()
|
||||||
|
format.setFontFamily(self.font_family)
|
||||||
|
format.setFontPointSize(int(self.font_size))
|
||||||
|
format.setForeground(QtGui.QColor(*self.fg_color))
|
||||||
|
if self.bold:
|
||||||
|
format.setFontWeight(QtGui.QFont.Bold)
|
||||||
|
if self.italic:
|
||||||
|
format.setFontItalic(True)
|
||||||
|
if self.underline:
|
||||||
|
format.setUnderlineStyle(QtGui.QTextCharFormat.SingleUnderline)
|
||||||
|
|
||||||
|
self.format = format
|
||||||
174
main.py
Normal file
174
main.py
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
import json
|
||||||
|
import sys
|
||||||
|
from PySide6 import QtWidgets, QtGui, QtCore
|
||||||
|
from Highlighter import Highlighter, Rule
|
||||||
|
from MainWindow_ui import Ui_MainWindow
|
||||||
|
from SettingsDialog import SettingsWindow
|
||||||
|
from TextFormat import TextFormat
|
||||||
|
|
||||||
|
def loadSettingsFromFile() -> dict:
|
||||||
|
try:
|
||||||
|
with open("settings.json", 'r') as f:
|
||||||
|
return json.load(f)
|
||||||
|
except IOError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def saveSettingsToFile(settings: dict) -> None:
|
||||||
|
with open("settings.json", 'w') as f:
|
||||||
|
json.dump(settings, f, indent=4)
|
||||||
|
|
||||||
|
|
||||||
|
class CommandStack:
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self.__stack = list()
|
||||||
|
self.__curIndex = -1
|
||||||
|
|
||||||
|
def add(self, cmd: str) -> None:
|
||||||
|
self.__stack.append(cmd)
|
||||||
|
self.__curIndex = len(self.__stack)
|
||||||
|
# print("lenght: ", len(self.__stack))
|
||||||
|
|
||||||
|
def hasPrevious(self) -> bool:
|
||||||
|
return self.__curIndex > 0
|
||||||
|
|
||||||
|
def hasNext(self) -> bool:
|
||||||
|
return (self.__curIndex + 1 < len(self.__stack)) and (len(self.__stack) != 0)
|
||||||
|
|
||||||
|
def getPrevious(self) -> str:
|
||||||
|
if len(self.__stack) < 1:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
self.__curIndex -= 1
|
||||||
|
if self.__curIndex < 0:
|
||||||
|
self.__curIndex = 0
|
||||||
|
|
||||||
|
# print("index: ", self.__curIndex)
|
||||||
|
return self.__stack[self.__curIndex]
|
||||||
|
|
||||||
|
def getNext(self):
|
||||||
|
if len(self.__stack) < 1:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
self.__curIndex = min(self.__curIndex + 1, len(self.__stack))
|
||||||
|
if self.__curIndex == len(self.__stack):
|
||||||
|
return self.__stack[self.__curIndex-1]
|
||||||
|
|
||||||
|
return self.__stack[self.__curIndex]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class MainWindow(QtWidgets.QMainWindow):
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__()
|
||||||
|
self.ui = Ui_MainWindow()
|
||||||
|
self.ui.setupUi(self)
|
||||||
|
|
||||||
|
settings = loadSettingsFromFile()
|
||||||
|
self.ui_settings = SettingsWindow(settings=settings)
|
||||||
|
|
||||||
|
self.stack = CommandStack()
|
||||||
|
self.highlighter = Highlighter(self.ui.txtEdit_mainTerminal.document())
|
||||||
|
|
||||||
|
self.setup()
|
||||||
|
|
||||||
|
self.ruleItemList = []
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
# header buttons
|
||||||
|
self.ui.btn_settings.clicked.connect(self.on_settingsClicked)
|
||||||
|
self.ui.btn_connect.clicked.connect(self.on_connectClicked)
|
||||||
|
|
||||||
|
# left side
|
||||||
|
self.ui.btn_addPattern.clicked.connect(self.on_addPaternClicked)
|
||||||
|
# self.ui.btn_removePattern.clicked.connect(self.on_removePatternClicked)
|
||||||
|
self.ui.lst_regex.model().rowsMoved.connect(self.on_item_move)
|
||||||
|
|
||||||
|
# right side
|
||||||
|
|
||||||
|
# main side
|
||||||
|
self.ui.lineEdit.returnPressed.connect(self.on_returnPressed)
|
||||||
|
self.ui.lineEdit.installEventFilter(self)
|
||||||
|
|
||||||
|
def on_connectClicked(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_settingsClicked(self):
|
||||||
|
if self.ui_settings.exec():
|
||||||
|
self.setTerminalFont(**self.ui_settings.fontsOption["terminal"])
|
||||||
|
self.setCommandFont(**self.ui_settings.fontsOption["echo"])
|
||||||
|
|
||||||
|
saveSettingsToFile(self.ui_settings.getSettings())
|
||||||
|
|
||||||
|
def on_addPaternClicked(self):
|
||||||
|
item = QtWidgets.QListWidgetItem(f"regex{str(self.ui.lst_regex.count())}")
|
||||||
|
item.setFlags(item.flags() | QtGui.Qt.ItemIsUserCheckable)
|
||||||
|
item.setCheckState(QtGui.Qt.Unchecked)
|
||||||
|
self.ui.lst_regex.addItem(item)
|
||||||
|
|
||||||
|
textFormat = TextFormat()
|
||||||
|
regex = QtCore.QRegularExpression()
|
||||||
|
rule = Rule(item.text(), True, textFormat, regex)
|
||||||
|
self.ruleItemList.append((item, rule))
|
||||||
|
print( [ ( i.text(), r.name )for i, r in self.ruleItemList ] )
|
||||||
|
self.highlighter.setListOfRules([ r for i, r in self.ruleItemList])
|
||||||
|
|
||||||
|
def on_item_move(self):
|
||||||
|
itemList = [self.ui.lst_regex.item(row) for row in range(self.ui.lst_regex.count())]
|
||||||
|
self.ruleItemList.sort(key=lambda t: itemList.index(t[0]))
|
||||||
|
print( [ ( i.text(), r.name )for i, r in self.ruleItemList ] )
|
||||||
|
self.highlighter.setListOfRules([ r for i, r in self.ruleItemList])
|
||||||
|
|
||||||
|
def on_returnPressed(self):
|
||||||
|
cmd = self.ui.lineEdit.text()
|
||||||
|
self.stack.add(cmd)
|
||||||
|
self.ui.txtEdit_mainTerminal.appendPlainText(cmd)
|
||||||
|
self.ui.lineEdit.clear()
|
||||||
|
|
||||||
|
def setTerminalFont(self, font_family: str, font_size: str, bold: bool, italic: bool, underline: bool, fg_color: tuple, bg_color: tuple):
|
||||||
|
font = list()
|
||||||
|
font.append(f'font-family: "{font_family}"')
|
||||||
|
font.append(f"font-size: {font_size}pt")
|
||||||
|
font.append(f'font-weight: {"bold" if bold else "normal"}')
|
||||||
|
font.append(f'font-style: {"italic" if italic else "normal"}')
|
||||||
|
font.append(f'text-decoration: {"underline" if underline else "none"}')
|
||||||
|
font.append(f"color: rgb({fg_color[0]}, {fg_color[1]}, {fg_color[2]})")
|
||||||
|
font.append(f"background-color: rgb({bg_color[0]}, {bg_color[1]}, {bg_color[2]})")
|
||||||
|
self.ui.txtEdit_mainTerminal.setStyleSheet(";".join(font))
|
||||||
|
self.ui.lbl_examplePattern.setStyleSheet(";".join(font))
|
||||||
|
|
||||||
|
def setCommandFont(self, font_family: str, font_size: str, bold: bool, italic: bool, underline: bool, fg_color: tuple, enable: bool):
|
||||||
|
textFormat = TextFormat(font_family, font_size, bold, italic, underline, fg_color)
|
||||||
|
regex = QtCore.QRegularExpression(r"^<<[\s]*(.*)")
|
||||||
|
rule = Rule("command", enable, textFormat, regex)
|
||||||
|
self.highlighter.addRule(rule)
|
||||||
|
self.highlighter.rehighlight()
|
||||||
|
|
||||||
|
def eventFilter(self, watched: QtCore.QObject, event: QtCore.QEvent) -> bool:
|
||||||
|
if watched is self.ui.lineEdit:
|
||||||
|
if event.type() == QtCore.QEvent.KeyPress:
|
||||||
|
keyEvent = QtGui.QKeyEvent(event)
|
||||||
|
if keyEvent.key() == QtCore.Qt.Key_Up:
|
||||||
|
self.on_upArrow()
|
||||||
|
if keyEvent.key() == QtCore.Qt.Key_Down:
|
||||||
|
self.on_downArrow()
|
||||||
|
|
||||||
|
return super().eventFilter(watched, event)
|
||||||
|
|
||||||
|
def on_upArrow(self):
|
||||||
|
if self.stack.hasPrevious():
|
||||||
|
self.ui.lineEdit.setText(self.stack.getPrevious())
|
||||||
|
|
||||||
|
def on_downArrow(self):
|
||||||
|
if self.stack.hasNext():
|
||||||
|
self.ui.lineEdit.setText(self.stack.getNext())
|
||||||
|
|
||||||
|
def main():
|
||||||
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
|
|
||||||
|
window = MainWindow()
|
||||||
|
window.show()
|
||||||
|
|
||||||
|
sys.exit(app.exec())
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
45
settings.json
Normal file
45
settings.json
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"connection": {
|
||||||
|
"com_port": "COM1 (Port komunikacyjny, (Standardowe typy port\u00f3w))",
|
||||||
|
"baudrate": "19200",
|
||||||
|
"data_bits": "8",
|
||||||
|
"stop_bits": "OneStop",
|
||||||
|
"parity": "NoParity"
|
||||||
|
},
|
||||||
|
"fonts": {
|
||||||
|
"terminal": {
|
||||||
|
"font_family": "Segoe UI",
|
||||||
|
"font_size": "10",
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": false,
|
||||||
|
"fg_color": [
|
||||||
|
255,
|
||||||
|
255,
|
||||||
|
255,
|
||||||
|
255
|
||||||
|
],
|
||||||
|
"bg_color": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
255
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"echo": {
|
||||||
|
"enable": true,
|
||||||
|
"font_family": "Segoe UI",
|
||||||
|
"font_size": "10",
|
||||||
|
"bold": false,
|
||||||
|
"italic": false,
|
||||||
|
"underline": true,
|
||||||
|
"fg_color": [
|
||||||
|
255,
|
||||||
|
255,
|
||||||
|
11,
|
||||||
|
255
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"display": {}
|
||||||
|
}
|
||||||
25
tescik.py
Normal file
25
tescik.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
|
||||||
|
# x = {1: 20, 3: 40, 4: 30, 2: 10, 0: 0}
|
||||||
|
|
||||||
|
# list_of_tuple = sorted(x.items(), key=lambda item: item[0])
|
||||||
|
# print([ v for k, v in list_of_tuple])
|
||||||
|
|
||||||
|
# print( { k: v for k, v in sorted(x.items(), key=lambda item: item[0])} )
|
||||||
|
|
||||||
|
|
||||||
|
l = [5, 8, 2, 4, 1, 10, None]
|
||||||
|
|
||||||
|
|
||||||
|
class test:
|
||||||
|
def __init__(self, l) -> None:
|
||||||
|
self.l = l
|
||||||
|
|
||||||
|
def print(self):
|
||||||
|
print(l)
|
||||||
|
|
||||||
|
t = test(l)
|
||||||
|
|
||||||
|
l.sort(key=lambda x: (x is None, x))
|
||||||
|
|
||||||
|
t.print()
|
||||||
Reference in New Issue
Block a user