2020-02-08 12:45:52 +00:00
|
|
|
import core.input
|
2020-03-01 13:08:16 +00:00
|
|
|
import core.decorators
|
2020-01-26 12:58:29 +00:00
|
|
|
import util.store
|
|
|
|
|
2020-02-08 12:45:52 +00:00
|
|
|
class Widget(util.store.Store, core.input.Object):
|
2020-03-01 13:36:12 +00:00
|
|
|
def __init__(self, full_text='', name=None, module=None):
|
2020-02-08 12:45:52 +00:00
|
|
|
super(Widget, self).__init__()
|
2020-01-26 12:58:29 +00:00
|
|
|
self._full_text = full_text
|
2020-03-01 13:36:12 +00:00
|
|
|
self._module = module
|
|
|
|
self._name = name
|
|
|
|
|
|
|
|
def name(self):
|
|
|
|
return self._name
|
2020-01-26 12:58:29 +00:00
|
|
|
|
|
|
|
def full_text(self, value=None):
|
|
|
|
if value:
|
|
|
|
self._full_text = value
|
|
|
|
else:
|
|
|
|
if callable(self._full_text):
|
2020-02-23 13:47:47 +00:00
|
|
|
return self._full_text(self)
|
2020-02-07 20:32:20 +00:00
|
|
|
return self._full_text
|
2020-01-26 12:58:29 +00:00
|
|
|
|
2020-02-24 13:54:11 +00:00
|
|
|
def module(self, module=None):
|
|
|
|
if not module:
|
|
|
|
return self._module
|
2020-02-23 20:13:49 +00:00
|
|
|
self._module = module
|
|
|
|
|
|
|
|
def state(self):
|
|
|
|
rv = []
|
2020-03-13 12:56:08 +00:00
|
|
|
if self.get('state', None):
|
|
|
|
tmp = self.get('state')
|
2020-03-27 12:54:22 +00:00
|
|
|
rv = tmp[:] if isinstance(tmp, list) else [tmp]
|
2020-02-23 20:13:49 +00:00
|
|
|
if self._module:
|
2020-03-13 12:56:08 +00:00
|
|
|
tmp = self._module.state(self)
|
2020-03-27 12:54:22 +00:00
|
|
|
rv.extend(tmp if isinstance(tmp, list) else [tmp])
|
|
|
|
return rv
|
2020-02-23 20:13:49 +00:00
|
|
|
|
2020-01-26 12:58:29 +00:00
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|