Added GUI files initially
This commit is contained in:
parent
a408bb05a4
commit
b088ad2cdb
27
README.md
27
README.md
@ -41,7 +41,7 @@ The CLI script ([tasmotonov.py](tasmotonov.py)) relies on two libaries apart fro
|
||||
- `fqdn`: for validating the FQDN
|
||||
- `requests`: for making the HTTP requests
|
||||
|
||||
To use it, just execute the following command:
|
||||
To install it, just execute the following command:
|
||||
|
||||
```bash
|
||||
pip install fqdn requests
|
||||
@ -49,9 +49,30 @@ pip install fqdn requests
|
||||
|
||||
---
|
||||
|
||||
The GUI application is based on Qt with it's python3 bindings PyQt6.
|
||||
The GUI application is based on Qt with it's python3 bindings PyQt6:
|
||||
|
||||
TODO
|
||||
- `PySide6`: for running all the GUI stuff
|
||||
|
||||
To install it, just execute the following command:
|
||||
|
||||
```bash
|
||||
pip install PySide6
|
||||
```
|
||||
|
||||
|
||||
## Running
|
||||
|
||||
CLI: Use `./tasmotonov.py`
|
||||
|
||||
GUI: Use `./tasmotonov-gui.py`
|
||||
|
||||
|
||||
## Plans
|
||||
|
||||
I plan to add
|
||||
|
||||
- a darkmode maybe (but of course the interface doesn't look good either lol ;)
|
||||
- and bundle everything together to get a desktop application (e.g. runnable under windows without development tools)
|
||||
|
||||
|
||||
## License
|
||||
|
77
tasmotonov-gui.py
Executable file
77
tasmotonov-gui.py
Executable file
@ -0,0 +1,77 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
from PySide6.QtUiTools import QUiLoader
|
||||
from PySide6.QtWidgets import QApplication,QFileDialog
|
||||
from PySide6.QtCore import QFile, QUrl, QIODevice
|
||||
|
||||
filename = ""
|
||||
action = "toggle"
|
||||
|
||||
def tab1_load_file():
|
||||
global filename
|
||||
dialog = QFileDialog()
|
||||
dialog.setFileMode(QFileDialog.AnyFile)
|
||||
#fileNames = QStringList()
|
||||
if dialog.exec():
|
||||
filename = dialog.selectedFiles()[0]
|
||||
window.tab1_label.setText(f"File loaded: {filename}")
|
||||
window.tab1_label.show()
|
||||
window.tab1_filecontent_textBrowser.setSource(QUrl(filename))
|
||||
def tab1_action():
|
||||
if filename != "":
|
||||
p = subprocess.Popen(["python3", "tasmotonov.py", "file", filename, action], stdout=subprocess.PIPE)
|
||||
out, err = p.communicate()
|
||||
window.tab3_textBrowser.append("==== RUNNING ====\n" + str(out) + "\n=================\n")
|
||||
else:
|
||||
window.tab3_textBrowser.append("Will not run, no file selected!")
|
||||
def tab2_action():
|
||||
content = window.tab2_plainTextEdit.toPlainText()
|
||||
if content != "":
|
||||
p = subprocess.Popen(["python3", "tasmotonov.py", "inline", content, action], stdout=subprocess.PIPE)
|
||||
out, err = p.communicate()
|
||||
window.tab3_textBrowser.append("==== RUNNING ====\n" + str(out) + "\n=================\n")
|
||||
print(out)
|
||||
else:
|
||||
window.tab3_textBrowser.append("Will not run, no input given!")
|
||||
def select_on():
|
||||
global action
|
||||
action = "on"
|
||||
window.tab3_textBrowser.append("Now turning everything on when running.")
|
||||
def select_off():
|
||||
global action
|
||||
action = "off"
|
||||
window.tab3_textBrowser.append("Now turning everything off when running.")
|
||||
def select_toggle():
|
||||
global action
|
||||
action = "toggle"
|
||||
window.tab3_textBrowser.append("Now toggling when running.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
ui_file_name = "tasmotonov.ui"
|
||||
ui_file = QFile(ui_file_name)
|
||||
if not ui_file.open(QIODevice.ReadOnly):
|
||||
print(f"Cannot open {ui_file_name}: {ui_file.errorString()}")
|
||||
sys.exit(-1)
|
||||
loader = QUiLoader()
|
||||
window = loader.load(ui_file)
|
||||
ui_file.close()
|
||||
if not window:
|
||||
print(loader.errorString())
|
||||
sys.exit(-1)
|
||||
|
||||
window.tab1_label.hide()
|
||||
window.tab1_load_file_pushButton.clicked.connect(tab1_load_file)
|
||||
window.tab1_action_pushButton.clicked.connect(tab1_action)
|
||||
window.tab2_action_pushButton.clicked.connect(tab2_action)
|
||||
window.radioButton_on.clicked.connect(select_on)
|
||||
window.radioButton_off.clicked.connect(select_off)
|
||||
window.radioButton_toggle.clicked.connect(select_toggle)
|
||||
|
||||
window.show()
|
||||
|
||||
sys.exit(app.exec())
|
||||
|
170
tasmotonov.ui
Normal file
170
tasmotonov.ui
Normal file
@ -0,0 +1,170 @@
|
||||
<?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>630</width>
|
||||
<height>404</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Tasmotonov</string>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tabShape">
|
||||
<enum>QTabWidget::TabShape::Rounded</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::TabPosition::East</enum>
|
||||
</property>
|
||||
<property name="tabShape">
|
||||
<enum>QTabWidget::TabShape::Rounded</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="usesScrollButtons">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="documentMode">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab1_from_file">
|
||||
<attribute name="title">
|
||||
<string>From File</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="3" column="0">
|
||||
<widget class="QTextBrowser" name="tab1_filecontent_textBrowser">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Shadow::Sunken</enum>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="tab1_label">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>File loaded: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QPushButton" name="tab1_action_pushButton">
|
||||
<property name="text">
|
||||
<string>Run!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="tab1_load_file_pushButton">
|
||||
<property name="text">
|
||||
<string>Load file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab2_from_inline">
|
||||
<attribute name="title">
|
||||
<string>From Inline</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="tab2_plainTextEdit">
|
||||
<property name="lineWrapMode">
|
||||
<enum>QPlainTextEdit::LineWrapMode::WidgetWidth</enum>
|
||||
</property>
|
||||
<property name="plainText">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextEditable|Qt::TextInteractionFlag::TextEditorInteraction|Qt::TextInteractionFlag::TextSelectableByKeyboard|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Enter your addresses here (IP-Adresses, or Domain names / FQDNs). The list can be either comma-, semicolon-, or whitespace-separated, but should not be mixed!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="tab2_action_pushButton">
|
||||
<property name="text">
|
||||
<string>Run!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab3_output">
|
||||
<attribute name="title">
|
||||
<string>Console</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="tab3_label_output">
|
||||
<property name="text">
|
||||
<string>Tasmotonov.py output</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="tab3_textBrowser"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_on">
|
||||
<property name="text">
|
||||
<string>All ON!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_off">
|
||||
<property name="text">
|
||||
<string>All OFF!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioButton_toggle">
|
||||
<property name="text">
|
||||
<string>TOGGLE all!</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
x
Reference in New Issue
Block a user