mirror of https://gitlab.com/pamhyr/pamhyr2
MainWindow: Add subwindow list.
parent
c4373fa00a
commit
01fcc36a67
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
# -*- 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):
|
||||
|
|
|
|||
Loading…
Reference in New Issue