doc: dev: Update with PamhyrWindow, and minor change in hash computation.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-09-26 14:19:22 +02:00
1 parent 624e9b6f71
commit e7fd2077bd
3 files changed
+32 -28

No files matched your search

+22 -18
View File
@@ -445,33 +445,37 @@ window, and =/src/View/ui/Widgets= for custom widget.
*** Window
An abstract class ASubMainWindow is used for most of Pamhyr2
windows. This class implemente some useful method allows to easy load
an window UI file. In addition, the abstract ListedSubWindow must be
also inherits by a window class, it is allow to keep a list of open
windows and avoid window duplicate.
The abstract class PamhyrWindow and PamhyrDialog are used for most of
Pamhyr2 window. These class allow to create an window for Pamhyr2 GUI
and implemente some useful methods.
#+NAME: window
#+CAPTION: Example of Pamhyr2 window
#+begin_src python :python python3 :results output :noweb yes
class MyWindow(ASubMainWindow, ListedSubWindow):
def __init__(self, title="My window",
study=None, config=None, parent=None):
self._study = study
self._config = config
self._parent = parent
from View.Tools.PamhyrWindow import PamhyrWindow
self._title = title + " - " + study.name
class MyWindow(PamhyrWindow):
_pamhyr_ui = "MyUI"
_pamhyr_name = "My window"
def __init__(self, my_data=None,
study=None, config=None,
parent=None):
self._my_data = my_data
super(MyWindow, self).__init__(
name=title, # The windows name for windows
# registration (avoid duplicate)
ui="My", # The ui file name (here "My.ui")
parent=parent # The parent window
# Window title
title = self._pamhyr_name + " - " + study.name,
# Window standard data
study = study, config = config, parent = parent,
# Activate undo/redo and copy/paste shortcut
options = ["undo", "copy"]
)
# Set Windows title
self.ui.setWindowTitle(self._title)
# Add custom data to hash window computation
self._hash_data.append(self._my_data)
# Setup custom window components
self.setup_table()
self.setup_connections()