Skip to content

Commit

Permalink
Release mode added
Browse files Browse the repository at this point in the history
Signed-off-by: Mehmet Cagri Aksoy <mcagriaksoy@yandex.com>
  • Loading branch information
Mehmet Cagri Aksoy committed Oct 24, 2023
1 parent b791efb commit 522f24f
Show file tree
Hide file tree
Showing 13 changed files with 341 additions and 34 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ If you have any questions or feedback, please contact me.
<div align="center">
<a href="/docs/" title="Go to project documentation"><img src="https://img.shields.io/badge/view-Documentation-blue?style=for-the-badge" alt="view - Documentation"></a>

</div>
<h2>Executable Command</h2>
The following command have been used to create AFCOM.exe
```
pyinstaller --noconfirm --onefile --windowed --icon "img/icon.ico" "src/main.py"
```
</div>
<h2>License</h2>
Released under <a href="/LICENSE">MIT</a> by <a href="https://github.com/mcagriaksoy">@mcagriaksoy</a>.
Binary file added img/icon.ico
Binary file not shown.
37 changes: 37 additions & 0 deletions main.spec
Original file line number Diff line number Diff line change
@@ -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,
)
Binary file removed src/__pycache__/main_window.cpython-311.pyc
Binary file not shown.
Binary file removed src/__pycache__/ui_main.cpython-310.pyc
Binary file not shown.
Binary file removed src/__pycache__/ui_main.cpython-311.pyc
Binary file not shown.
Binary file removed src/__pycache__/ui_main.cpython-312.pyc
Binary file not shown.
18 changes: 15 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -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()
start_ui_design()
245 changes: 245 additions & 0 deletions src/ui_config.py
Original file line number Diff line number Diff line change
@@ -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"))
45 changes: 31 additions & 14 deletions src/ui_main.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
Loading

0 comments on commit 522f24f

Please sign in to comment.