Skip to content

Commit c75f2a6

Browse files
committed
creating the app folder to store custom apps
also adding a template for custom apps
1 parent fdfc661 commit c75f2a6

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed

src/pymodaq_plugins_template/app/__init__.py

Whitespace-only changes.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
from qtpy import QtWidgets
2+
3+
from pymodaq.utils import gui_utils as gutils
4+
5+
6+
#todo: modify the name of this class to reflect its application and chnage the name in the main
7+
# method at the end of the script
8+
class CustomAppTemplate(gutils.CustomApp):
9+
10+
#todo: if you wish to create custom Parameter and corresponding widgets. These will be
11+
# automatically added as children of self.settings. Morevover, the self.settings_tree will
12+
# render the widgets in a Qtree. If you wish to see it in your app, add is into a Dock
13+
params = []
14+
15+
def __init__(self, parent: gutils.DockArea):
16+
super().__init__(parent)
17+
18+
self.setup_ui()
19+
20+
def setup_docks(self):
21+
"""Mandatory method to be subclassed to setup the docks layout
22+
23+
Examples
24+
--------
25+
>>>self.docks['ADock'] = gutils.Dock('ADock name')
26+
>>>self.dockarea.addDock(self.docks['ADock'])
27+
>>>self.docks['AnotherDock'] = gutils.Dock('AnotherDock name')
28+
>>>self.dockarea.addDock(self.docks['AnotherDock'''], 'bottom', self.docks['ADock'])
29+
30+
See Also
31+
--------
32+
pyqtgraph.dockarea.Dock
33+
"""
34+
#todo: create docks and add them here to hold your widgets
35+
# reminder, the attribute self.settings_tree will render the widgets in a Qtree.
36+
# If you wish to see it in your app, add is into a Dock
37+
raise NotImplementedError
38+
39+
def setup_actions(self):
40+
"""Method where to create actions to be subclassed. Mandatory
41+
42+
Examples
43+
--------
44+
>>> self.add_action('Quit', 'close2', "Quit program")
45+
>>> self.add_action('Grab', 'camera', "Grab from camera", checkable=True)
46+
>>> self.add_action('Load', 'Open', "Load target file (.h5, .png, .jpg) or data from camera"
47+
, checkable=False)
48+
>>> self.add_action('Save', 'SaveAs', "Save current data", checkable=False)
49+
50+
See Also
51+
--------
52+
ActionManager.add_action
53+
"""
54+
raise NotImplementedError(f'You have to define actions here')
55+
56+
def connect_things(self):
57+
"""Connect actions and/or other widgets signal to methods"""
58+
raise NotImplementedError
59+
60+
def setup_menu(self):
61+
"""Non mandatory method to be subclassed in order to create a menubar
62+
63+
create menu for actions contained into the self._actions, for instance:
64+
65+
Examples
66+
--------
67+
>>>file_menu = self.mainwindow.menuBar().addMenu('File')
68+
>>>self.affect_to('load', file_menu)
69+
>>>self.affect_to('save', file_menu)
70+
71+
>>>file_menu.addSeparator()
72+
>>>self.affect_to('quit', file_menu)
73+
74+
See Also
75+
--------
76+
pymodaq.utils.managers.action_manager.ActionManager
77+
"""
78+
#todo create and populate menu using actions defined above in self.setup_actions
79+
pass
80+
81+
82+
83+
84+
85+
def main():
86+
from pymodaq.utils.gui_utils.utils import mkQApp
87+
app = mkQApp('CustomApp')
88+
89+
mainwindow = QtWidgets.QMainWindow()
90+
dockarea = gutils.DockArea()
91+
mainwindow.setCentralWidget(dockarea)
92+
93+
#todo: change the name here to be the same as your app class
94+
prog = CustomAppTemplate(dockarea)
95+
96+
mainwindow.show()
97+
98+
app.exec()
99+
100+
101+
if __name__ == '__main__':
102+
main()

0 commit comments

Comments
 (0)