2020-05-04 10:09:59 +02:00
|
|
|
|
|
|
|
class DBUSItem:
|
2020-05-05 09:56:59 +02:00
|
|
|
def __init__(self, name, text='', style='', icon='', iconStyle='', onClick='', box=''):
|
2020-05-04 10:09:59 +02:00
|
|
|
self.name = name
|
|
|
|
self.text = text
|
|
|
|
self.style= style
|
|
|
|
self.icon = icon
|
|
|
|
self.iconStyle = iconStyle
|
|
|
|
self.onClick = onClick
|
2020-05-05 09:56:59 +02:00
|
|
|
self.box = box
|
|
|
|
|
2020-05-04 10:09:59 +02:00
|
|
|
self._checkValues()
|
|
|
|
|
|
|
|
def _checkValues(self):
|
|
|
|
if self.onClick and not self.onClick in ('signal', 'delete'):
|
|
|
|
raise ValueError('Invalid onClick value')
|
2020-05-05 09:56:59 +02:00
|
|
|
if self.box and not self.box in ('left', 'center', 'right'):
|
|
|
|
raise ValueError('Invalid box value')
|
2020-05-04 10:09:59 +02:00
|
|
|
|
|
|
|
def toMap(self):
|
|
|
|
myMap = {"name":self.name}
|
2020-05-05 09:56:59 +02:00
|
|
|
for p in ('text', 'style', 'icon', 'box'):
|
2020-05-04 10:09:59 +02:00
|
|
|
if self.__dict__[p]:
|
|
|
|
myMap[p] = self.__dict__[p]
|
|
|
|
if self.iconStyle:
|
|
|
|
myMap['icon-style'] = self.iconStyle
|
|
|
|
if self.onClick:
|
|
|
|
myMap['on-click'] = self.onClick
|
|
|
|
return [myMap]
|