Debian Codegraph @

pymeasure/display/widgets/browser_widget.py

raw
1 #
2 # This file is part of the PyMeasure package.
3 #
4 # Copyright (c) 2013-2024 PyMeasure Developers
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 # THE SOFTWARE.
23 #
24
25 import logging
26
27 from ..browser import Browser
28 from ..Qt import QtWidgets
29
30 log = logging.getLogger(__name__)
31 log.addHandler(logging.NullHandler())
32
33
34 class BrowserWidget(QtWidgets.QWidget):
35 """
36 Widget wrapper for :class:`Browser<pymeasure.display.browser.Browser>` class
37 """
38 def __init__(self, *args, parent=None):
39 super().__init__(parent)
40 self.browser_args = args
41 self._setup_ui()
42 self._layout()
43
44 def _setup_ui(self):
45 self.browser = Browser(*self.browser_args, parent=self)
46 self.clear_button = QtWidgets.QPushButton('Clear all', self)
47 self.clear_button.setEnabled(False)
48 self.hide_button = QtWidgets.QPushButton('Hide all', self)
49 self.hide_button.setEnabled(False)
50 self.show_button = QtWidgets.QPushButton('Show all', self)
51 self.show_button.setEnabled(False)
52 self.open_button = QtWidgets.QPushButton('Open', self)
53 self.open_button.setEnabled(True)
54
55 def _layout(self):
56 vbox = QtWidgets.QVBoxLayout(self)
57 vbox.setSpacing(0)
58
59 hbox = QtWidgets.QHBoxLayout()
60 hbox.setSpacing(10)
61 hbox.setContentsMargins(-1, 6, -1, 6)
62 hbox.addWidget(self.show_button)
63 hbox.addWidget(self.hide_button)
64 hbox.addWidget(self.clear_button)
65 hbox.addStretch()
66 hbox.addWidget(self.open_button)
67
68 vbox.addLayout(hbox)
69 vbox.addWidget(self.browser)
70 self.setLayout(vbox)