From b088ad2cdb4fc24ec29969377924d785559ba2a2 Mon Sep 17 00:00:00 2001 From: BlueFox Date: Sat, 17 May 2025 02:23:05 +0200 Subject: [PATCH] Added GUI files initially --- README.md | 27 +++++++- tasmotonov-gui.py | 77 +++++++++++++++++++++ tasmotonov.ui | 170 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 271 insertions(+), 3 deletions(-) create mode 100755 tasmotonov-gui.py create mode 100644 tasmotonov.ui diff --git a/README.md b/README.md index 73ddaf1..73b7794 100644 --- a/README.md +++ b/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 diff --git a/tasmotonov-gui.py b/tasmotonov-gui.py new file mode 100755 index 0000000..8d9320e --- /dev/null +++ b/tasmotonov-gui.py @@ -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()) + diff --git a/tasmotonov.ui b/tasmotonov.ui new file mode 100644 index 0000000..2de2aab --- /dev/null +++ b/tasmotonov.ui @@ -0,0 +1,170 @@ + + + mainWindow + + + + 0 + 0 + 630 + 404 + + + + Tasmotonov + + + false + + + QTabWidget::TabShape::Rounded + + + + + + + QTabWidget::TabPosition::East + + + QTabWidget::TabShape::Rounded + + + 1 + + + true + + + true + + + + From File + + + + + + QFrame::Shadow::Sunken + + + true + + + + + + + true + + + + 0 + 0 + + + + File loaded: + + + + + + + Run! + + + + + + + Load file + + + + + + + + From Inline + + + + + + QPlainTextEdit::LineWrapMode::WidgetWidth + + + + + + Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextEditable|Qt::TextInteractionFlag::TextEditorInteraction|Qt::TextInteractionFlag::TextSelectableByKeyboard|Qt::TextInteractionFlag::TextSelectableByMouse + + + 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! + + + + + + + Run! + + + + + + + + Console + + + + + + Tasmotonov.py output + + + + + + + + + + + + + + + + All ON! + + + + + + + All OFF! + + + + + + + TOGGLE all! + + + true + + + + + + + + + + +