diff --git a/README.md b/README.md index 2d609ef..13c7b7c 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,12 @@ If you have any questions or feedback, please contact me.
view - Documentation +
+

Executable Command

+The following command have been used to create AFCOM.exe +``` +pyinstaller --noconfirm --onefile --windowed --icon "img/icon.ico" "src/main.py" +```

License

Released under MIT by @mcagriaksoy. diff --git a/img/icon.ico b/img/icon.ico new file mode 100644 index 0000000..ac30a27 Binary files /dev/null and b/img/icon.ico differ diff --git a/main.spec b/main.spec new file mode 100644 index 0000000..9cf3959 --- /dev/null +++ b/main.spec @@ -0,0 +1,37 @@ +# -*- mode: python ; coding: utf-8 -*- + + +a = Analysis( + ['src/main.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='main', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=False, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) diff --git a/src/__pycache__/main_window.cpython-311.pyc b/src/__pycache__/main_window.cpython-311.pyc deleted file mode 100644 index 39385f4..0000000 Binary files a/src/__pycache__/main_window.cpython-311.pyc and /dev/null differ diff --git a/src/__pycache__/ui_main.cpython-310.pyc b/src/__pycache__/ui_main.cpython-310.pyc deleted file mode 100644 index 1621aba..0000000 Binary files a/src/__pycache__/ui_main.cpython-310.pyc and /dev/null differ diff --git a/src/__pycache__/ui_main.cpython-311.pyc b/src/__pycache__/ui_main.cpython-311.pyc deleted file mode 100644 index 4cfa9cb..0000000 Binary files a/src/__pycache__/ui_main.cpython-311.pyc and /dev/null differ diff --git a/src/__pycache__/ui_main.cpython-312.pyc b/src/__pycache__/ui_main.cpython-312.pyc deleted file mode 100644 index ca67bdd..0000000 Binary files a/src/__pycache__/ui_main.cpython-312.pyc and /dev/null differ diff --git a/src/main.py b/src/main.py index 5db10ea..95d7991 100644 --- a/src/main.py +++ b/src/main.py @@ -1,5 +1,17 @@ -__author__ = 'Mehmet Cagri Aksoy - github.com/mcagriaksoy' -from ui_main import start_ui_design +# -*- coding: utf-8 -*- +""" +AFCOM - Serial Communication GUI Program +Usage: python main.py +""" +__author__ = "Mehmet Cagri Aksoy - github.com/mcagriaksoy" +__copyright__ = "Copyright 2023, The AFCOM Project" +__credits__ = ["Mehmet Cagri Aksoy"] +__license__ = "MIT" +__version__ = "1.0.1" +__maintainer__ = "Mehmet Cagri Aksoy" +__status__ = "Production" + +from ui_main import start_ui_design if __name__ == "__main__": - start_ui_design() \ No newline at end of file + start_ui_design() diff --git a/src/ui_config.py b/src/ui_config.py new file mode 100644 index 0000000..75a811f --- /dev/null +++ b/src/ui_config.py @@ -0,0 +1,245 @@ +# Form implementation generated from reading ui file 'main_window.ui' +# +# Created by: PyQt6 UI code generator 6.5.2 +# +# WARNING: Any manual changes made to this file will be lost when pyuic6 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt6 import QtCore, QtGui, QtWidgets + + +class Ui_main_window(object): + def setupUi(self, main_window): + main_window.setObjectName("main_window") + main_window.resize(939, 486) + main_window.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.ArrowCursor)) + icon = QtGui.QIcon() + icon.addPixmap(QtGui.QPixmap("icon.ico"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off) + main_window.setWindowIcon(icon) + main_window.setWindowOpacity(1.0) + self.centralwidget = QtWidgets.QWidget(parent=main_window) + self.centralwidget.setObjectName("centralwidget") + self.formLayoutWidget = QtWidgets.QWidget(parent=self.centralwidget) + self.formLayoutWidget.setGeometry(QtCore.QRect(740, 10, 191, 211)) + self.formLayoutWidget.setObjectName("formLayoutWidget") + self.formLayout = QtWidgets.QFormLayout(self.formLayoutWidget) + self.formLayout.setContentsMargins(0, 0, 0, 0) + self.formLayout.setObjectName("formLayout") + self.label_2 = QtWidgets.QLabel(parent=self.formLayoutWidget) + self.label_2.setObjectName("label_2") + self.formLayout.setWidget(0, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_2) + self.label_6 = QtWidgets.QLabel(parent=self.formLayoutWidget) + self.label_6.setObjectName("label_6") + self.formLayout.setWidget(1, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_6) + self.comboBox_1 = QtWidgets.QComboBox(parent=self.formLayoutWidget) + self.comboBox_1.setObjectName("comboBox_1") + self.comboBox_1.addItem("") + self.comboBox_1.addItem("") + self.comboBox_1.addItem("") + self.comboBox_1.addItem("") + self.comboBox_1.addItem("") + self.comboBox_1.addItem("") + self.comboBox_1.addItem("") + self.comboBox_1.addItem("") + self.formLayout.setWidget(1, QtWidgets.QFormLayout.ItemRole.FieldRole, self.comboBox_1) + self.label_7 = QtWidgets.QLabel(parent=self.formLayoutWidget) + self.label_7.setObjectName("label_7") + self.formLayout.setWidget(2, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_7) + self.comboBox_2 = QtWidgets.QComboBox(parent=self.formLayoutWidget) + self.comboBox_2.setObjectName("comboBox_2") + self.comboBox_2.addItem("") + self.comboBox_2.addItem("") + self.comboBox_2.addItem("") + self.comboBox_2.addItem("") + self.formLayout.setWidget(2, QtWidgets.QFormLayout.ItemRole.FieldRole, self.comboBox_2) + self.comboBox = QtWidgets.QComboBox(parent=self.formLayoutWidget) + self.comboBox.setObjectName("comboBox") + self.comboBox.addItem("") + self.comboBox.addItem("") + self.comboBox.addItem("") + self.comboBox.addItem("") + self.comboBox.addItem("") + self.comboBox.addItem("") + self.comboBox.addItem("") + self.comboBox.addItem("") + self.formLayout.setWidget(3, QtWidgets.QFormLayout.ItemRole.FieldRole, self.comboBox) + self.label_12 = QtWidgets.QLabel(parent=self.formLayoutWidget) + self.label_12.setObjectName("label_12") + self.formLayout.setWidget(3, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_12) + self.comboBox_3 = QtWidgets.QComboBox(parent=self.formLayoutWidget) + self.comboBox_3.setObjectName("comboBox_3") + self.formLayout.setWidget(0, QtWidgets.QFormLayout.ItemRole.FieldRole, self.comboBox_3) + self.label_13 = QtWidgets.QLabel(parent=self.formLayoutWidget) + self.label_13.setObjectName("label_13") + self.formLayout.setWidget(4, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_13) + self.comboBox_4 = QtWidgets.QComboBox(parent=self.formLayoutWidget) + self.comboBox_4.setObjectName("comboBox_4") + self.comboBox_4.addItem("") + self.comboBox_4.addItem("") + self.comboBox_4.addItem("") + self.comboBox_4.addItem("") + self.comboBox_4.addItem("") + self.formLayout.setWidget(4, QtWidgets.QFormLayout.ItemRole.FieldRole, self.comboBox_4) + self.label_14 = QtWidgets.QLabel(parent=self.formLayoutWidget) + self.label_14.setObjectName("label_14") + self.formLayout.setWidget(5, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_14) + self.save_button = QtWidgets.QPushButton(parent=self.formLayoutWidget) + self.save_button.setObjectName("save_button") + self.formLayout.setWidget(6, QtWidgets.QFormLayout.ItemRole.FieldRole, self.save_button) + self.comboBox_5 = QtWidgets.QComboBox(parent=self.formLayoutWidget) + self.comboBox_5.setObjectName("comboBox_5") + self.comboBox_5.addItem("") + self.comboBox_5.addItem("") + self.comboBox_5.addItem("") + self.formLayout.setWidget(5, QtWidgets.QFormLayout.ItemRole.FieldRole, self.comboBox_5) + self.gridLayoutWidget = QtWidgets.QWidget(parent=self.centralwidget) + self.gridLayoutWidget.setGeometry(QtCore.QRect(0, 0, 731, 411)) + self.gridLayoutWidget.setObjectName("gridLayoutWidget") + self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget) + self.gridLayout.setContentsMargins(0, 0, 0, 0) + self.gridLayout.setObjectName("gridLayout") + self.label_3 = QtWidgets.QLabel(parent=self.gridLayoutWidget) + self.label_3.setObjectName("label_3") + self.gridLayout.addWidget(self.label_3, 1, 0, 1, 1) + self.textEdit_3 = QtWidgets.QTextEdit(parent=self.gridLayoutWidget) + self.textEdit_3.setAutoFillBackground(False) + self.textEdit_3.setObjectName("textEdit_3") + self.gridLayout.addWidget(self.textEdit_3, 2, 0, 1, 1) + self.formLayoutWidget_2 = QtWidgets.QWidget(parent=self.centralwidget) + self.formLayoutWidget_2.setGeometry(QtCore.QRect(740, 240, 191, 21)) + self.formLayoutWidget_2.setObjectName("formLayoutWidget_2") + self.formLayout_2 = QtWidgets.QFormLayout(self.formLayoutWidget_2) + self.formLayout_2.setContentsMargins(0, 0, 0, 0) + self.formLayout_2.setObjectName("formLayout_2") + self.label_4 = QtWidgets.QLabel(parent=self.formLayoutWidget_2) + font = QtGui.QFont() + font.setFamily("Arial") + font.setPointSize(9) + font.setBold(False) + font.setWeight(50) + self.label_4.setFont(font) + self.label_4.setObjectName("label_4") + self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.ItemRole.LabelRole, self.label_4) + self.label_5 = QtWidgets.QLabel(parent=self.formLayoutWidget_2) + font = QtGui.QFont() + font.setFamily("Arial") + font.setPointSize(9) + font.setBold(False) + font.setWeight(50) + self.label_5.setFont(font) + self.label_5.setStyleSheet("") + self.label_5.setObjectName("label_5") + self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.ItemRole.FieldRole, self.label_5) + self.verticalLayoutWidget = QtWidgets.QWidget(parent=self.centralwidget) + self.verticalLayoutWidget.setGeometry(QtCore.QRect(736, 270, 201, 141)) + self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") + self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget) + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.verticalLayout.setObjectName("verticalLayout") + self.label_10 = QtWidgets.QLabel(parent=self.verticalLayoutWidget) + self.label_10.setObjectName("label_10") + self.verticalLayout.addWidget(self.label_10) + self.horizontalLayout_2 = QtWidgets.QHBoxLayout() + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.end_button = QtWidgets.QPushButton(parent=self.verticalLayoutWidget) + font = QtGui.QFont() + font.setPointSize(9) + font.setBold(True) + font.setWeight(75) + self.end_button.setFont(font) + self.end_button.setLocale(QtCore.QLocale(QtCore.QLocale.Language.English, QtCore.QLocale.Country.UnitedStates)) + self.end_button.setObjectName("end_button") + self.horizontalLayout_2.addWidget(self.end_button) + self.start_button = QtWidgets.QPushButton(parent=self.verticalLayoutWidget) + font = QtGui.QFont() + font.setPointSize(9) + font.setBold(True) + font.setWeight(75) + self.start_button.setFont(font) + self.start_button.setObjectName("start_button") + self.horizontalLayout_2.addWidget(self.start_button) + self.verticalLayout.addLayout(self.horizontalLayout_2) + self.textEdit = QtWidgets.QTextEdit(parent=self.verticalLayoutWidget) + self.textEdit.setObjectName("textEdit") + self.verticalLayout.addWidget(self.textEdit) + self.save_txt_button = QtWidgets.QPushButton(parent=self.centralwidget) + self.save_txt_button.setGeometry(QtCore.QRect(600, 430, 121, 31)) + self.save_txt_button.setObjectName("save_txt_button") + self.label_9 = QtWidgets.QLabel(parent=self.centralwidget) + self.label_9.setGeometry(QtCore.QRect(0, 400, 451, 31)) + self.label_9.setObjectName("label_9") + self.textEdit_2 = QtWidgets.QTextEdit(parent=self.centralwidget) + self.textEdit_2.setGeometry(QtCore.QRect(0, 430, 501, 31)) + self.textEdit_2.setObjectName("textEdit_2") + self.send_data_button = QtWidgets.QPushButton(parent=self.centralwidget) + self.send_data_button.setGeometry(QtCore.QRect(500, 430, 101, 31)) + font = QtGui.QFont() + font.setBold(True) + font.setWeight(75) + self.send_data_button.setFont(font) + self.send_data_button.setObjectName("send_data_button") + self.label = QtWidgets.QLabel(parent=self.centralwidget) + self.label.setGeometry(QtCore.QRect(770, 430, 141, 31)) + self.label.setObjectName("label") + main_window.setCentralWidget(self.centralwidget) + self.actionAna_Ekran = QtGui.QAction(parent=main_window) + self.actionAna_Ekran.setObjectName("actionAna_Ekran") + self.actionHelp = QtGui.QAction(parent=main_window) + self.actionHelp.setObjectName("actionHelp") + + self.retranslateUi(main_window) + QtCore.QMetaObject.connectSlotsByName(main_window) + + def retranslateUi(self, main_window): + _translate = QtCore.QCoreApplication.translate + main_window.setWindowTitle(_translate("main_window", "AFCOM Client (A free COM port data transfer client)")) + main_window.setStatusTip(_translate("main_window", "Mehmet Cagri Aksoy")) + main_window.setWhatsThis(_translate("main_window", "Serial Communication Program Mehmet Cagri Aksoy")) + self.label_2.setText(_translate("main_window", "Selected Port:")) + self.label_6.setText(_translate("main_window", "Baud Rate:")) + self.comboBox_1.setItemText(0, _translate("main_window", "9600")) + self.comboBox_1.setItemText(1, _translate("main_window", "1200")) + self.comboBox_1.setItemText(2, _translate("main_window", "2400")) + self.comboBox_1.setItemText(3, _translate("main_window", "4800")) + self.comboBox_1.setItemText(4, _translate("main_window", "19200")) + self.comboBox_1.setItemText(5, _translate("main_window", "38400")) + self.comboBox_1.setItemText(6, _translate("main_window", "57600")) + self.comboBox_1.setItemText(7, _translate("main_window", "115200")) + self.label_7.setText(_translate("main_window", "Length (B):")) + self.comboBox_2.setItemText(0, _translate("main_window", "5")) + self.comboBox_2.setItemText(1, _translate("main_window", "6")) + self.comboBox_2.setItemText(2, _translate("main_window", "7")) + self.comboBox_2.setItemText(3, _translate("main_window", "8")) + self.comboBox.setItemText(0, _translate("main_window", "2")) + self.comboBox.setItemText(1, _translate("main_window", "3")) + self.comboBox.setItemText(2, _translate("main_window", "4")) + self.comboBox.setItemText(3, _translate("main_window", "5")) + self.comboBox.setItemText(4, _translate("main_window", "10")) + self.comboBox.setItemText(5, _translate("main_window", "30")) + self.comboBox.setItemText(6, _translate("main_window", "50")) + self.comboBox.setItemText(7, _translate("main_window", "100")) + self.label_12.setText(_translate("main_window", "Timeout:")) + self.label_13.setText(_translate("main_window", "Parity:")) + self.comboBox_4.setItemText(0, _translate("main_window", "None")) + self.comboBox_4.setItemText(1, _translate("main_window", "Even")) + self.comboBox_4.setItemText(2, _translate("main_window", "Odd")) + self.comboBox_4.setItemText(3, _translate("main_window", "Mark")) + self.comboBox_4.setItemText(4, _translate("main_window", "Space")) + self.label_14.setText(_translate("main_window", "StopBits:")) + self.save_button.setText(_translate("main_window", "Save")) + self.comboBox_5.setItemText(0, _translate("main_window", "1")) + self.comboBox_5.setItemText(1, _translate("main_window", "1.5")) + self.comboBox_5.setItemText(2, _translate("main_window", "2")) + self.label_3.setText(_translate("main_window", "Gathering / Sending Data (Rx/Tx)")) + self.label_4.setText(_translate("main_window", "Port Status :")) + self.label_5.setText(_translate("main_window", "Not Connected")) + self.label_10.setText(_translate("main_window", "Connection Options:")) + self.end_button.setText(_translate("main_window", "STOP")) + self.start_button.setText(_translate("main_window", "START")) + self.save_txt_button.setText(_translate("main_window", "Save as .txt")) + self.label_9.setText(_translate("main_window", "Send DATA:")) + self.send_data_button.setText(_translate("main_window", "SEND")) + self.label.setText(_translate("main_window", "github.com/mcagriaksoy")) + self.actionAna_Ekran.setText(_translate("main_window", "Ana Ekran")) + self.actionHelp.setText(_translate("main_window", "Help")) diff --git a/src/ui_main.py b/src/ui_main.py index 65dcc71..a48920d 100644 --- a/src/ui_main.py +++ b/src/ui_main.py @@ -1,18 +1,32 @@ +# -*- coding: utf-8 -*- +""" +AFCOM - Serial Communication GUI Program +Cannot be used directly, it is a part of main.py +""" + __author__ = 'Mehmet Cagri Aksoy - github.com/mcagriaksoy' -__annotations__ = 'Serial Communication GUI Program' +__annotations__ = 'AFCOM - Serial Communication GUI Program' # IMPORTS import sys import glob import os +# Runtime Type Checking +PROGRAM_TYPE_DEBUG = 1 +PROGRAM_TYPE_RELEASE = 0 + try: import serial import serial.tools.list_ports from serial import SerialException from PyQt6.QtCore import QObject, QThread, pyqtSignal, pyqtSlot - from PyQt6.QtWidgets import (QApplication, QMainWindow, QMessageBox) - from PyQt6.uic import loadUi + from PyQt6.QtWidgets import QApplication, QMainWindow, QMessageBox + + if (PROGRAM_TYPE_DEBUG): + from PyQt6.uic import loadUi + else: # PROGRAM_TYPE_RELEASE + from ui_config import Ui_main_window except ImportError as e: print("Import Error! Please install the required libraries: " + str(e)) sys.exit(1) @@ -79,14 +93,6 @@ def __init__(self): """ Initialize Main Window """ QMainWindow.__init__(self) - file_path = os.path.join("../ui/main_window.ui") - - if not os.path.exists(file_path): - print("UI File Not Found!") - sys.exit(1) - - loadUi(file_path, self) - PORTS = get_serial_port() self.thread = None @@ -209,6 +215,17 @@ def on_send_data_button_clicked(self): def start_ui_design(): """ Start the UI Design """ app = QApplication(sys.argv) - widget = MainWindow() - widget.show() - sys.exit(app.exec()) + window_object = QMainWindow() + + if PROGRAM_TYPE_RELEASE: + ui = Ui_main_window() + ui.setupUi(window_object) + elif PROGRAM_TYPE_DEBUG: + file_path = os.path.join("../ui/main_window.ui") + if not os.path.exists(file_path): + print("UI File Not Found!") + sys.exit(1) + loadUi(file_path, window_object) + + window_object.show() + sys.exit(app.exec()) \ No newline at end of file diff --git a/ui/main_window.ui b/ui/main_window.ui index 20d6132..929952d 100644 --- a/ui/main_window.ui +++ b/ui/main_window.ui @@ -1,7 +1,7 @@ - qt - + main_window + 0 @@ -328,10 +328,10 @@ - 740 - 290 - 197 - 121 + 736 + 270 + 201 + 141 @@ -440,7 +440,7 @@ - 750 + 770 430 141 31 @@ -451,7 +451,6 @@ - Ana Ekran diff --git a/ui/qt.py:Zone.Identifier b/ui/qt.py:Zone.Identifier deleted file mode 100644 index 1bf0b28..0000000 --- a/ui/qt.py:Zone.Identifier +++ /dev/null @@ -1,3 +0,0 @@ -[ZoneTransfer] -ZoneId=3 -HostUrl=https://github.com/ diff --git a/ui/usage.txt b/ui/usage.txt deleted file mode 100644 index 3b67173..0000000 --- a/ui/usage.txt +++ /dev/null @@ -1,6 +0,0 @@ -I do not prefer text version of ui file on the python code. -Instead I am calling pyuic tool to convert it for python usage. - -pip install pyuic5-tool - -pyuic5 input.ui -o output.py \ No newline at end of file