Commit 01fcc36a authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

MainWindow: Add subwindow list.

Showing with 37 additions and 2 deletions
+37 -2
......@@ -23,3 +23,8 @@ class ASubWindow(QDialog):
self
)
self.name = name
self.parent = parent
def closeEvent(self, event):
if not self.parent is None:
self.parent.sub_win_del(self.name)
......@@ -4,5 +4,5 @@ from view.ASubWindow import ASubWindow
class DummyWindow(ASubWindow):
def __init__(self, title="Dummy", parent=None):
super(DummyWindow, self).__init__(ui="dummy", parent=parent)
super(DummyWindow, self).__init__(name=title, ui="dummy", parent=parent)
self.ui.setWindowTitle(title)
# -*- coding: utf-8 -*-
class ListedSubWindow(object):
def __init__(self):
super(ListedSubWindow, self).__init__()
self.sub_win_cnt = 0
self.sub_win_list = []
def sub_win_count(self):
return self.sub_win_cnt
def sub_win_list(self):
return self.sub_win_list.copy()
def sub_win_add(self, name, win):
self.sub_win_list.append((name, win))
self.sub_win_cnt += 1
print(f"+ {name} ({self.sub_win_cnt})")
def sub_win_del(self, name):
self.sub_win_list = list(
filter(
lambda x: x[0] != name,
self.sub_win_list
)
)
self.sub_win_cnt = len(self.sub_win_list)
print(f"- {name} ({self.sub_win_cnt})")
......@@ -7,10 +7,11 @@ from PyQt5.QtWidgets import (
QMainWindow, QApplication, QAction,
)
from PyQt5.uic import loadUi
from view.ListedSubWindow import ListedSubWindow
from view.DummyWindow import DummyWindow
from view.AboutWindow import AboutWindow
class ApplicationWindow(QMainWindow):
class ApplicationWindow(QMainWindow, ListedSubWindow):
def __init__(self):
super(ApplicationWindow, self).__init__()
self.ui = loadUi(
......@@ -28,6 +29,7 @@ class ApplicationWindow(QMainWindow):
title=title if type(title) is str else "Dummy",
parent=self
)
self.sub_win_add(title, self.dummy)
self.dummy.show()
def open_about(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment