Aug-11-2019, 11:58 AM
The complicated if structures can be replaced by a dictionary:
def __call__(self, **kwargs): methods = {'t': self.title, 'n': self.widgetName, 'c': self.color, 'p': self.parent} for key in kwargs: methods[key]()or as a class attribute:
class Widget(QtWidgets.QWidget): methods = {'t': 'title', 'n': 'widgetName', 'c': 'color', 'p': 'parent'} def __call__(self, **kwargs): for key in kwargs: getattr(self, methods[key])()
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures