fix exporting and importing from file
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
from PySide6.QtWidgets import QMainWindow, QWidget, QVBoxLayout, QTabWidget, QMenu, QTableView
|
||||
|
||||
from gui.model_config import KontorModelConfig
|
||||
from gui.table_model import KontorTableModel
|
||||
|
||||
|
||||
class ComicWindow(QWidget):
|
||||
def __init__(self, main_window):
|
||||
super().__init__()
|
||||
self.statusBar = main_window.statusBar
|
||||
self._main_window = main_window
|
||||
self.data_views = list()
|
||||
# self._create_menubar()
|
||||
self._init_gui()
|
||||
|
||||
def _init_gui(self):
|
||||
self.central_widget = QWidget()
|
||||
layout = QVBoxLayout()
|
||||
#self.central_widget.setLayout(parent_layout)
|
||||
self.tabs = QTabWidget()
|
||||
self.tabs.addTab(self.generate_data_tab("comic"), "Comics")
|
||||
self.tabs.addTab(self.generate_data_tab("publisher"), "Publisher")
|
||||
self.tabs.currentChanged.connect(self._tab_changed)
|
||||
# label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
layout.addWidget(self.tabs)
|
||||
self.setLayout(layout)
|
||||
# self.setCentralWidget(self.central_widget)
|
||||
|
||||
# def _create_menubar(self):
|
||||
# menu_bar = self.menuBar()
|
||||
# comic_menu = QMenu("Comic")
|
||||
# menu_bar.addMenu(comic_menu)
|
||||
|
||||
def refresh(self):
|
||||
self.data_views[self.tabs.currentIndex()].refresh()
|
||||
|
||||
def _tab_changed(self, tab_index):
|
||||
self.data_views[tab_index].refresh()
|
||||
|
||||
def generate_data_tab(self, table_name):
|
||||
data_tab = QWidget()
|
||||
|
||||
table_config = KontorModelConfig(self._main_window.kontor_db, self, table_name)
|
||||
model = KontorTableModel(table_config)
|
||||
layout = QVBoxLayout()
|
||||
self.data_views.append(model)
|
||||
data_tab.setLayout(layout)
|
||||
table_view = QTableView()
|
||||
table_view.setModel(model)
|
||||
layout.addLayout(table_config.get_filter_layout())
|
||||
layout.addWidget(table_view)
|
||||
model.refresh()
|
||||
return data_tab
|
||||
|
||||
@@ -4,6 +4,7 @@ from PySide6.QtWidgets import QLabel, QMainWindow
|
||||
from sqlalchemy import Engine
|
||||
from kontor_schema import KontorDB
|
||||
|
||||
from .comic_window import ComicWindow
|
||||
from .progress import ProgressUpdate
|
||||
from .dialogs import ExportKontorDialog, ImportKontorDialog
|
||||
from .model_config import KontorModelConfig
|
||||
@@ -34,6 +35,8 @@ class MainWindow(QMainWindow):
|
||||
self.filter = {}
|
||||
self.kontor_db = KontorDB(engine, log)
|
||||
self.log = log
|
||||
|
||||
self.comic_window = ComicWindow(self)
|
||||
self.central_widget = QWidget()
|
||||
parent_layout = QVBoxLayout()
|
||||
self.central_widget.setLayout(parent_layout)
|
||||
@@ -52,6 +55,8 @@ class MainWindow(QMainWindow):
|
||||
self.newAction = QAction("&New", self)
|
||||
self.aboutAction = QAction("&Über...", self)
|
||||
self.aboutAction.triggered.connect(self.about)
|
||||
self.showComicWindow = QAction("Show/Hide &Comic Window", self)
|
||||
self.showComicWindow.triggered.connect(self.show_comic_window)
|
||||
self.importAction = QAction(self.import_icon, "&Import", self)
|
||||
self.importAction.triggered.connect(self.import_from_file)
|
||||
self.exportAction = QAction(self.export_icon, "&Export", self)
|
||||
@@ -80,6 +85,7 @@ class MainWindow(QMainWindow):
|
||||
kontor_menu.addAction(self.importAction)
|
||||
kontor_menu.addAction(self.exportAction)
|
||||
comic_menu = QMenu("&Comic")
|
||||
comic_menu.addAction(self.showComicWindow)
|
||||
tysc_menu = QMenu("&TradeYourSportCards")
|
||||
media_file_menu = QMenu("&MediaFile")
|
||||
media_file_menu.addAction(self.updateTitleAction)
|
||||
@@ -110,12 +116,18 @@ class MainWindow(QMainWindow):
|
||||
def about(self):
|
||||
QMessageBox.about(self.central_widget, "Über Kontor", f"Python: 3.11\nKontor: 0.1.0")
|
||||
|
||||
def show_comic_window(self):
|
||||
if self.comic_window.isHidden():
|
||||
self.comic_window.show()
|
||||
else:
|
||||
self.comic_window.hide()
|
||||
|
||||
def import_from_file(self):
|
||||
import_dlg = ImportKontorDialog(self)
|
||||
if import_dlg.exec():
|
||||
print(f"import DB from file {import_dlg.file_name}")
|
||||
else:
|
||||
print("no nothing for import")
|
||||
print("do nothing for import")
|
||||
pass
|
||||
|
||||
def export_to_file(self):
|
||||
|
||||
Reference in New Issue
Block a user