reorganize files for Qt application

This commit is contained in:
Thomas Peetz
2025-01-11 01:54:05 +01:00
committed by Thomas Peetz
parent f1d36acff7
commit d2b1cb999a
19 changed files with 136 additions and 77 deletions
-7
View File
@@ -1,7 +0,0 @@
from PySide6.QtGui import QIcon
tick = QIcon('tick.png')
cross = QIcon('cross.png')
import_icon = QIcon("application-import.png")
export_icon = QIcon("application-export.png")
circle_icon = QIcon("arrow-circle-double.png")
+2
View File
@@ -0,0 +1,2 @@
deployment/
kontor.bin
@@ -1,5 +1,5 @@
import mariadb import mariadb
from sqlalchemy import create_engine, text, MetaData, join from sqlalchemy import create_engine, select, text, MetaData, join
from sqlalchemy.orm import DeclarativeBase, relationship, sessionmaker from sqlalchemy.orm import DeclarativeBase, relationship, sessionmaker
from database.base import Base from database.base import Base
@@ -31,54 +31,20 @@ class KontorDB:
self.session = __session__() self.session = __session__()
def get_table_id(self, table_name): def get_table_id(self, table_name):
cursor = self.db_conn.cursor() result = self.session.execute(select(MetaDataTable.id).where(MetaDataTable.table_name == table_name)).scalar()
cursor.execute("SELECT id, created_date, last_modified_date FROM meta_data_table WHERE table_name=?", return result
(table_name,))
row = cursor.fetchone()
cursor.close()
# table_ids = self.session.query(MetaDataTable).filter(MetaDataTable.table_name == table_name).all()
# print(type(table_ids))
return row[0]
def get_table_names(self) -> list: def get_table_names(self) -> list:
tables_names = []
cursor = self.db_conn.cursor()
cursor.execute("SELECT id, table_name from meta_data_table")
rows = cursor.fetchall().all
for row in rows:
print(row)
for (_, table_name) in rows:
tables_names.append(table_name)
cursor.close()
tables = self.session.query(MetaDataTable).all() tables = self.session.query(MetaDataTable).all()
for table in tables: result = [table.table_name for table in tables]
print(table) return result
return tables_names
def get_column_meta_data(self, table_id: str, table_name: str): def get_column_meta_data(self, table_id: str, table_name: str) -> dict:
cursor = self.db_conn.cursor()
meta_data = {} meta_data = {}
cursor.execute(
"SELECT column_name, column_order, column_label FROM meta_data_column WHERE table_id=? AND is_shown is true ORDER bY column_order",
(table_id,))
rows = cursor.fetchall()
order = 0 order = 0
for (column_name, column_order, column_label) in rows: for (_, column) in self.session.query(MetaDataTable, MetaDataColumn).filter(MetaDataTable.id == MetaDataColumn.table_id).filter(MetaDataTable.table_name == table_name).filter(MetaDataColumn.is_shown == 1).all():
meta_data[order] = {'column': column_name, 'label': column_label, 'order': column_order} meta_data[order] = {'column': column.column_name, 'label': column.column_label, 'order': column.column_order}
order += 1 order += 1
cursor.close()
columns = (self.session.query(MetaDataColumn).
join(MetaDataTable, MetaDataTable.id == MetaDataColumn.table_id).
filter(MetaDataTable.table_name == table_name).
filter(MetaDataColumn.is_shown is True).
order_by(MetaDataColumn.column_order).all())
print(columns)
for column in columns:
print(column)
result = repr(column)
if result is not None:
print(result)
# print(f"retrieved {len(rows)} columns, set {len(meta_data)} headers")
return meta_data return meta_data
def get_filters(self, table_id): def get_filters(self, table_id):
@@ -14,11 +14,10 @@ class MetaDataTable(Base):
table_columns = relationship("MetaDataColumn") table_columns = relationship("MetaDataColumn")
def __repr__(self): def __repr__(self):
print(f'MetaDataTable({self.id} {self.table_name})') return f'MetaDataTable({self.id} {self.table_name})'
def __str__(self): def __str__(self):
print(f'{self.table_name}({self.id})') return f'{self.table_name}({self.id})'
class MetaDataColumn(Base): class MetaDataColumn(Base):
__tablename__ = 'meta_data_column' __tablename__ = 'meta_data_column'
@@ -40,10 +39,10 @@ class MetaDataColumn(Base):
def __repr__(self): def __repr__(self):
if self.column_name is None: if self.column_name is None:
print(f'MetaDataColumn({self.id} {self.table.table_name}.__)') return f'MetaDataColumn({self.id} {self.table.table_name}.__)'
else: else:
print(f'MetaDataColumn({self.id} {self.table.table_name}.{self.column_name})') return f'MetaDataColumn({self.id} {self.table.table_name}.{self.column_name})'
def __str__(self): def __str__(self):
print(f'{self.column_name}({self.id})') return f'{self.column_name}({self.id})'
View File
+1 -20
View File
@@ -1,14 +1,6 @@
"""
PyQT6 GUI for Kontor
"""
import sys
from pathlib import Path
import yaml
from PySide6.QtGui import QAction, QIcon from PySide6.QtGui import QAction, QIcon
from PySide6.QtWidgets import QWidget, QVBoxLayout, QMenu, QMessageBox, QTabWidget, QTableView from PySide6.QtWidgets import QWidget, QVBoxLayout, QMenu, QMessageBox, QTabWidget, QTableView
from PySide6.QtWidgets import QApplication, QLabel, QMainWindow from PySide6.QtWidgets import QLabel, QMainWindow
from platformdirs import PlatformDirs
from database import KontorDB from database import KontorDB
from dialogs import ExportKontorDialog, ImportKontorDialog from dialogs import ExportKontorDialog, ImportKontorDialog
@@ -138,14 +130,3 @@ class MainWindow(QMainWindow):
layout.addWidget(table_view) layout.addWidget(table_view)
model.refresh() model.refresh()
return data_tab return data_tab
if __name__ == '__main__':
app = QApplication(sys.argv)
dirs = PlatformDirs("kontor")
database_config = Path(dirs.user_config_dir, 'database-config.yaml')
with open(database_config, 'rt') as f:
db_config = yaml.safe_load(f.read())
window = MainWindow(db_config)
window.show()
app.exec()
@@ -2,7 +2,6 @@ import mariadb
from PySide6.QtWidgets import QHBoxLayout, QCheckBox from PySide6.QtWidgets import QHBoxLayout, QCheckBox
from database import KontorDB from database import KontorDB
from database.comic import Comic
class KontorModelConfig: class KontorModelConfig:
+1 -1
View File
@@ -3,7 +3,7 @@ from datetime import datetime
from PySide6.QtCore import QAbstractTableModel, QModelIndex from PySide6.QtCore import QAbstractTableModel, QModelIndex
from PySide6.QtGui import Qt from PySide6.QtGui import Qt
from model_config import KontorModelConfig from gui.model_config import KontorModelConfig
class KontorTableModel(QAbstractTableModel): class KontorTableModel(QAbstractTableModel):
+21
View File
@@ -0,0 +1,21 @@
"""
PyQT6 GUI for Kontor
"""
import sys
from pathlib import Path
from platformdirs import PlatformDirs
from PySide6.QtWidgets import QApplication
import yaml
from gui.main_window import MainWindow
if __name__ == '__main__':
app = QApplication(sys.argv)
dirs = PlatformDirs("kontor")
database_config = Path(dirs.user_config_dir, 'database-config.yaml')
with open(database_config, 'rt') as f:
db_config = yaml.safe_load(f.read())
window = MainWindow(db_config)
window.show()
app.exec()
+98
View File
@@ -0,0 +1,98 @@
[app]
# title of your application
title = kontor
# project directory. the general assumption is that project_dir is the parent directory
# of input_file
project_dir = /home/tpeetz/projects/kontor/qt
# source file path
input_file = /home/tpeetz/projects/kontor/qt/kontor.py
# directory where exec is stored
exec_directory = .
# path to .pyproject project file
project_file =
# application icon
icon = /usr/local/lib/python3.11/dist-packages/PySide6/scripts/deploy_lib/pyside_icon.jpg
[python]
# python path
python_path = /usr/bin/python3
# python packages to install
packages = Nuitka==2.4.8
# buildozer = for deploying Android application
android_packages = buildozer==1.5.0,cython==0.29.33
[qt]
# comma separated path to qml files required
# normally all the qml files required by the project are added automatically
qml_files =
# excluded qml plugin binaries
excluded_qml_plugins =
# qt modules used. comma separated
modules = Gui,DBus,Core,Widgets
# qt plugins used by the application
plugins = platformthemes,imageformats,platforms,generic,iconengines,egldeviceintegrations,styles,xcbglintegrations,platforms/darwin,platforminputcontexts,accessiblebridge
[android]
# path to pyside wheel
wheel_pyside =
# path to shiboken wheel
wheel_shiboken =
# plugins to be copied to libs folder of the packaged application. comma separated
plugins =
[nuitka]
# usage description for permissions requested by the app as found in the info.plist file
# of the app bundle
# eg = extra_args = --show-modules --follow-stdlib
macos.permissions =
# mode of using nuitka. accepts standalone or onefile. default is onefile.
mode = onefile
# (str) specify any extra nuitka arguments
extra_args = --quiet --noinclude-qt-translations
[buildozer]
# build mode
# possible options = [release, debug]
# release creates an aab, while debug creates an apk
mode = debug
# contrains path to pyside6 and shiboken6 recipe dir
recipe_dir =
# path to extra qt android jars to be loaded by the application
jars_dir =
# if empty uses default ndk path downloaded by buildozer
ndk_path =
# if empty uses default sdk path downloaded by buildozer
sdk_path =
# other libraries to be loaded. comma separated.
# loaded at app startup
local_libs =
# architecture of deployed platform
# possible values = ["aarch64", "armv7a", "i686", "x86_64"]
arch =

Before

Width:  |  Height:  |  Size: 513 B

After

Width:  |  Height:  |  Size: 513 B

Before

Width:  |  Height:  |  Size: 524 B

After

Width:  |  Height:  |  Size: 524 B

Before

Width:  |  Height:  |  Size: 836 B

After

Width:  |  Height:  |  Size: 836 B

Before

Width:  |  Height:  |  Size: 544 B

After

Width:  |  Height:  |  Size: 544 B

Before

Width:  |  Height:  |  Size: 634 B

After

Width:  |  Height:  |  Size: 634 B