8===D~
commit
8ef165507d
|
@ -0,0 +1,9 @@
|
|||
all: zip install view
|
||||
zip:
|
||||
cd hs-applet; zip -r ../hs-applet.zip .
|
||||
|
||||
install:
|
||||
plasmapkg -u hs-applet.zip
|
||||
|
||||
view:
|
||||
plasma-windowed hs-applet
|
|
@ -0,0 +1,66 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- encoding: utf-8 -*-
|
||||
from PyQt4.QtCore import Qt, pyqtSignature
|
||||
from PyQt4 import QtCore
|
||||
from PyQt4.QtGui import QGraphicsLinearLayout, QIcon
|
||||
from PyKDE4.plasma import Plasma
|
||||
from PyKDE4 import plasmascript
|
||||
from urllib2 import urlopen, URLError, HTTPError
|
||||
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)
|
||||
self.setAspectRatioMode(Plasma.IgnoreAspectRatio)
|
||||
|
||||
self.theme = Plasma.Svg(self)
|
||||
self.theme.setImagePath("widgets/background")
|
||||
self.setBackgroundHints(Plasma.Applet.DefaultBackground)
|
||||
|
||||
self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.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.resize(125, 125)
|
||||
|
||||
def get_user_list(self):
|
||||
try:
|
||||
api_content = urlopen("https://at.hackerspace.pl/api").read()
|
||||
except (URLError, HTTPError):
|
||||
pass # TODO:
|
||||
users = json.loads(api_content)["users"]
|
||||
return (x["login"] for x in users)
|
||||
|
||||
|
||||
def connectToEngine(self):
|
||||
self.timeEngine = self.dataEngine("time")
|
||||
self.timeEngine.connectSource(self.currentTimezone,
|
||||
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)
|
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
|
@ -0,0 +1,19 @@
|
|||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=hs-applet
|
||||
Type=Service
|
||||
ServiceTypes=Plasma/Applet
|
||||
Icon=chronometer
|
||||
X-Plasma-API=python
|
||||
X-Plasma-MainScript=code/main.py
|
||||
X-Plasma-DefaultSize=125,125
|
||||
|
||||
X-KDE-PluginInfo-Author=Papież Polak
|
||||
X-KDE-PluginInfo-Email=daz@hackerspace.pl
|
||||
X-KDE-PluginInfo-Name=hs-applet2
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=http://plasma.kde.org/
|
||||
X-KDE-PluginInfo-Category=Examples
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
Loading…
Reference in New Issue