Add docstrings. Also add safe_cast function. Finally
fix some minor issues.
This commit is contained in:
@@ -2,11 +2,18 @@ from PyQt5.QtWidgets import QPushButton
|
||||
from PyQt5.QtCore import pyqtSlot
|
||||
|
||||
class DoubleTextButton(QPushButton):
|
||||
"""Subclass QPushButton.
|
||||
|
||||
A click will deactivate/activate a series of 'slave' widgets depending
|
||||
on the 'checked' status of the button."""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
"""Extends QPushButton.__init__."""
|
||||
super().__init__(parent)
|
||||
self.clicked.connect(self.__manage_click)
|
||||
|
||||
def set_texts(self, text_a, text_b):
|
||||
"""Set the two texts to be displayed."""
|
||||
self.__text_a = text_a
|
||||
self.__text_b = text_b
|
||||
|
||||
@@ -15,6 +22,14 @@ class DoubleTextButton(QPushButton):
|
||||
ruled_by_radio_1=None,
|
||||
radio_2=None,
|
||||
ruled_by_radio_2=None):
|
||||
"""Set all the 'slave' widgets.
|
||||
|
||||
Keyword arguments:
|
||||
simple_ones -- a list of widgets.
|
||||
radio_1 -- a radio button.
|
||||
ruled_by_radio_1 -- a list of widgets whose status depend upon radio_1.
|
||||
radio_2 -- a radio button.
|
||||
ruled_by_radio_2 -- a list of widgets whose status depend upon radio_2."""
|
||||
self.__simple_ones = simple_ones
|
||||
self.__ruled_by_radio_1 = ruled_by_radio_1
|
||||
self.__radio_1 = radio_1
|
||||
@@ -23,6 +38,7 @@ class DoubleTextButton(QPushButton):
|
||||
|
||||
@pyqtSlot()
|
||||
def __manage_click(self):
|
||||
"""Set the status of all the 'slave widgets' based on the status of the instance."""
|
||||
if self.isChecked():
|
||||
self.setText(self.__text_b)
|
||||
enable = False
|
||||
|
||||
Reference in New Issue
Block a user