daz 2013-11-23 20:28:30 +01:00
parent ce100c451d
commit b92f36bbb2
1 changed files with 5 additions and 10 deletions

View File

@ -12,8 +12,6 @@ import json
INTERVAL = 15
class HelloPython(plasmascript.Applet):
def __init__(self,parent,args=None):
super(HelloPython, self).__init__(parent)
def init(self):
self.setHasConfigurationInterface(False)
@ -28,13 +26,14 @@ class HelloPython(plasmascript.Applet):
hs_button = Plasma.ToolButton();
hs_button.setIcon(QIcon(self.package().path() + "contents/images/syrenka-small.png"))
QtCore.QObject.connect(hs_button, QtCore.SIGNAL('clicked()'), self.update_list)
self.at_list = Plasma.Label(self.applet)
self.layout.addItem(self.at_list)
self.layout.addItem(hs_button)
self.applet.setLayout(self.layout)
self.update_list()
self.connect_to_engine()
self.resize(125, 125)
def get_user_list(self):
@ -45,22 +44,18 @@ class HelloPython(plasmascript.Applet):
users = json.loads(api_content)["users"]
return (x["login"] for x in users)
def connectToEngine(self):
def connect_to_engine(self):
self.timeEngine = self.dataEngine("time")
self.timeEngine.connectSource(self.currentTimezone,
self.timeEngine.connectSource("Local",
self, INTERVAL*6000, Plasma.AlignToMinute)
def update_list(self):
self.at_list.setText("\n".join(self.get_user_list()))
@pyqtSignature("dataUpdated(const QString &, const Plasma::DataEngine::Data &)")
def dataUpdated(self, sourceName, data):
self.update_list()
def CreateApplet(parent):
return HelloPython(parent)