-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPushButton.py
39 lines (28 loc) · 1.08 KB
/
PushButton.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
PushButton.py
MIT License (c) Faure Systems <dev at faure dot systems>
Prop control push button.
"""
from PyQt5.QtWidgets import QWidget, QPushButton, QHBoxLayout
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt
class PushButton(QWidget):
publishMessage = pyqtSignal(str, str)
# __________________________________________________________________
def __init__(self, caption, action, topic):
super(PushButton, self).__init__()
self._action = action
self._topic = topic
self._pushButton = QPushButton(caption)
self._pushButton.setFocusPolicy(Qt.NoFocus)
main_layout = QHBoxLayout()
main_layout.setContentsMargins(0, 0, 0, 0)
main_layout.setSpacing(8)
main_layout.addWidget(self._pushButton)
self.setLayout(main_layout)
self._pushButton.released.connect(self.onPushButton)
# __________________________________________________________________
@pyqtSlot()
def onPushButton(self):
self.publishMessage.emit(self._topic, self._action)