def init(self): self.setHasConfigurationInterface(False) self.setAspectRatioMode(Plasma.Square) self.resize(300,400) self.layout = QGraphicsLinearLayout(Qt.Vertical, self.applet) self.label = Plasma.Label(self.applet) self.label.setText("Enter the text to be converted") self.label.nativeWidget().setAlignment(Qt.AlignHCenter) self.layout.addItem(self.label) self.text = Plasma.LineEdit(self.applet) self.text.setClearButtonShown(True) self.text.nativeWidget().setMaxLength(1000) self.layout.addItem(self.text) self.button = Plasma.PushButton(self.applet) self.button.setText("Generate") self.button.clicked.connect(self.generate) self.layout.addItem(self.button) self.webView = Plasma.WebView(self.applet) self.webView.setUrl(KUrl("about:blank")) self.webView.setMinimumSize(250, 250) self.layout.addItem(self.webView) self.setLayout(self.layout)
def init(self): self.setHasConfigurationInterface(False) self.setAspectRatioMode(Plasma.IgnoreAspectRatio) # -- widgets self.icon_laptop = Plasma.IconWidget( QtGui.QIcon(self.package().path() + "contents/images/mode-laptop.png"), "", self.applet) self.icon_stand = Plasma.IconWidget( QtGui.QIcon(self.package().path() + "contents/images/mode-stand.png"), "", self.applet) self.icon_tablet = Plasma.IconWidget( QtGui.QIcon(self.package().path() + "contents/images/mode-tablet.png"), "", self.applet) self.icon_tend = Plasma.IconWidget( QtGui.QIcon(self.package().path() + "contents/images/mode-tend.png"), "", self.applet) self.target = Plasma.ItemBackground(self.applet) # -- some logic self.icon_laptop.clicked.connect(self.set_laptop_mode) self.icon_stand.clicked.connect(self.set_stand_mode) self.icon_tablet.clicked.connect(self.set_tablet_mode) self.icon_tend.clicked.connect(self.set_tend_mode) # -- layoyt layout = QtGui.QGraphicsLinearLayout(Qt.Horizontal, self.applet) layout.addItem(self.icon_laptop) layout.addItem(self.icon_stand) layout.addItem(self.icon_tablet) layout.addItem(self.icon_tend) self.applet.setLayout(layout) self.set_laptop_mode()
def init(self): """ Const method for initializing the applet """ # Configuration interface support comes with plasma self.setHasConfigurationInterface(False) # Aspect ratio defined in Plasma self.setAspectRatioMode(Plasma.IgnoreAspectRatio) # Theme is a const variable holds Applet Theme self.theme = Plasma.Svg(self) # It gets default plasma theme's background self.theme.setImagePath("widgets/background") # Resize current theme as applet size self.theme.resize(self.size()) self.layout = QGraphicsLinearLayout(self.applet) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.layout.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.icon = Plasma.IconWidget() self.icon.setIcon("input-keyboard") self.icon.setToolTip("Wheel mouse to set keyboard backlight..") self.icon.setAcceptDrops(False) self.layout.addItem(self.icon) self.resize(125, 125)
def init(self): self.setAspectRatioMode(Plasma.IgnoreAspectRatio) self.setHasConfigurationInterface(True) self.dialog = None cg = self.config() self.APIkey = cg.readEntry("APIkey", QString("")).toString() self.pool = cg.readEntry("pool", 0).toInt()[0] self.mainvalue = cg.readEntry("mainvalue", 0).toInt()[0] self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet) self.applet.setLayout(self.layout) self.label = Plasma.Label(self.applet) self.label.setAlignment(Qt.AlignVCenter) svg = Plasma.Svg(self) icon_path = self.package().path() + "contents/icons/logo.svg" svg.setImagePath(icon_path) self.ttip_icon = QIcon(icon_path) self.icon = Plasma.SvgWidget(svg) self.icon.setPreferredSize(20, 20) policy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.icon.setSizePolicy(policy) self.layout.addItem(self.icon) self.layout.setAlignment(self.icon, Qt.AlignCenter) self.layout.addItem(self.label) if self.APIkey != "": self.update_data() self.update() self.startTimer(30000) #30 seconds
def init(self): self.dbusloop = DBusQtMainLoop() self.bus = dbus.SessionBus(mainloop=self.dbusloop) self.setHasConfigurationInterface(False) self.setAspectRatioMode(Plasma.IgnoreAspectRatio) # -- widgets slider = BrightnessSlider(self.bus, self.applet) icon_incr = Plasma.IconWidget( QtGui.QIcon(self.package().path() + "contents/images/brightness_incr.png"), "", self.applet) icon_decr = Plasma.IconWidget( QtGui.QIcon(self.package().path() + "contents/images/brightness_decr.png"), "", self.applet) # -- some logic icon_incr.clicked.connect(slider.stepUp) icon_decr.clicked.connect(slider.stepDown) # -- layoyt layout = QtGui.QGraphicsLinearLayout(Qt.Vertical, self.applet) layout.addItem(icon_incr) layout.addItem(slider) layout.setAlignment(slider, Qt.AlignCenter) layout.addItem(icon_decr) self.applet.setLayout(layout)
def match(self, context): if not context.isValid(): return query = context.query() search = query.__str__() # PyQt is shit if len(search) < 3: return if search.lower() in 'create note': action = Plasma.QueryMatch(self.runner) action.setText("Create new note in everpad") action.setType(Plasma.QueryMatch.ExactMatch) action.setIcon(KIcon("everpad")) action.setData(str(CREATE)) context.addMatch(query, action) if search.lower() in 'settings and management': action = Plasma.QueryMatch(self.runner) action.setText("Open everpad settings") action.setType(Plasma.QueryMatch.ExactMatch) action.setIcon(KIcon("everpad")) action.setData(str(SETTINGS)) context.addMatch(query, action) blank = dbus.Array([], signature='i') for note_struct in provider.find_notes( search, blank, blank, 0, 1000, Note.ORDER_TITLE, -1, ): note = Note.from_tuple(note_struct) action = Plasma.QueryMatch(self.runner) action.setText(note.title) action.setSubtext(html2text(note.content)) action.setType(Plasma.QueryMatch.ExactMatch) action.setIcon(KIcon("everpad")) action.setData(str(note.id)) context.addMatch(query, action)
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.Vertical, self.applet) #self.keystroke = QAction(self) #self.keystroke.setShortcut(Qt.Key_D) self.button = Plasma.PushButton(self.applet) self.name = "Counts" self.counts = 0 #self.button.setAction(self.keystroke) QObject.connect(self.button, SIGNAL("clicked()"), self.count) self.layout.addItem(self.button) self.resetbutton = Plasma.PushButton(self.applet) self.resetbutton.setText("Reset") QObject.connect(self.resetbutton, SIGNAL("clicked()"), self.reset) self.layout.addItem(self.resetbutton) self.setLayout(self.layout)
def init(self): #self.moduller=self.link.Network.Firewall[dbus.String("iptables")].listModules() self.tahta=[[0,0,0],[0,0,0],[0,0,0]] self.setHasConfigurationInterface(True) self.setAspectRatioMode(Plasma.Square) self.resize(450,250) self.theme = Plasma.Svg(self) self.theme.setImagePath("widgets/background") self.setBackgroundHints(Plasma.Applet.DefaultBackground) self.layout=QGraphicsGridLayout(self.applet) #label = Plasma.Label(self.applet) #label.setText("<h1>Firewall Plasmoid</h1>") #self.kilit=Plasma.IconWidget(self.applet) #self.bilgi_label=Plasma.Label(self.applet) #self.baslat_pb=Plasma.PushButton(self.applet) #self.baslat_pb.setText("Start") #self.durdur_pb=Plasma.PushButton(self.applet) #self.durdur_pb.setText("Stop") self.tus1=Plasma.PushButton(self.applet) self.tus1.setText("") self.tus2=Plasma.PushButton(self.applet) self.tus2.setText("") self.tus3=Plasma.PushButton(self.applet) self.tus3.setText("") self.tus4=Plasma.PushButton(self.applet) self.tus4.setText("") self.tus5=Plasma.PushButton(self.applet) self.tus5.setText("") self.tus6=Plasma.PushButton(self.applet) self.tus6.setText("") self.tus7=Plasma.PushButton(self.applet) self.tus7.setText("") self.tus8=Plasma.PushButton(self.applet) self.tus8.setText("") self.tus9=Plasma.PushButton(self.applet) self.tus9.setText("") self.layout.addItem(self.tus1, 0, 0) self.layout.addItem(self.tus2, 0, 1) self.layout.addItem(self.tus3, 0, 2) self.layout.addItem(self.tus4, 1, 0) self.layout.addItem(self.tus5, 1, 1) self.layout.addItem(self.tus6, 1, 2) self.layout.addItem(self.tus7, 2, 0) self.layout.addItem(self.tus8, 2, 1) self.layout.addItem(self.tus9, 2, 2) self.applet.setLayout(self.layout)
def initPlasmoid(self): self.line_edit = Plasma.LineEdit(self.applet) self.layout.addItem(self.line_edit,0,0) self.text_edit = Plasma.TextEdit(self.applet) self.layout.addItem(self.text_edit,1,0) self.check() self.connect(self.line_edit, SIGNAL("textEdited(const QString&)"), self.check) # Update the size of Plasmoid self.constraintsEvent(Plasma.SizeConstraint)
def __init__(self, parent, data): QGraphicsWidget.__init__(self, parent) self.layout = QGraphicsLinearLayout(Qt.Horizontal, self) self.label = Plasma.Label(self) self.label.setText(data['remote']) self.layout.addItem(self.label) self.layout.addStretch() self.meter = Plasma.Meter(self) self.meter.setMeterType(Plasma.Meter.BarMeterHorizontal) self.meter.setValue(int(data['quality'])) self.layout.addItem(self.meter)
def init(self): self.setHasConfigurationInterface(False) self.setAspectRatioMode(Plasma.Square) self.theme = Plasma.Svg(self) self.theme.setImagePath("widgets/background") self.setBackgroundHints(Plasma.Applet.DefaultBackground) self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet) label = Plasma.Label(self.applet) label.setText("Hello world!") self.layout.addItem(label) self.applet.setLayout(self.layout) self.resize(125, 125)
def createOneDayLayout(self): self.layout.setColumnMaximumWidth(0, 300) self.wasDaily = 1 self.clearLayout() self.resize(300, 300) self.nameLabel = Plasma.Label(self.applet) self.descLabel = Plasma.Label(self.applet) self.tempLabel = Plasma.Label(self.applet) self.humLabel = Plasma.Label(self.applet) self.layout.addItem(self.descLabel, 1, 0) self.layout.addItem(self.nameLabel, 0, 0) self.layout.addItem(self.tempLabel, 2, 0) self.layout.addItem(self.humLabel, 3, 0)
def init(self): """Applet settings""" self.setHasConfigurationInterface(True) self.resize(300, 300) self.setAspectRatioMode(1) self.theme = Plasma.Svg(self) self.theme.setImagePath("widgets/background") self.setBackgroundHints(Plasma.Applet.DefaultBackground) self.step = 0 self.wasWeekly = 0 self.wasDaily = 0 self.layout = QGraphicsGridLayout(self.applet) self.createOneDayLayout() self.setOneDayLayout() # SettingsDialog instance # see: settings.py self.settings_dialog = None # User credentials self.City = '' self.weekly = 1 self.path = "/home/draed/wwidg/contents/images/" self.timer = QTimer() self.connect(self.timer, SIGNAL("timeout(bool)"), self.update) def postInit(self): self.timer.start(1000 * 60 * 60) self.update()
def match(self, context): # called by krunner to let us add actions for the user if not context.isValid(): return q = context.query() runInTerminal = True # look for our keyword 'j' or 'jo' if q.startsWith("j "): q = q[1:] elif q.startsWith("jo "): q = q[2:] runInTerminal = False else: return # strip the keyword and leading space q = q.trimmed() f = os.popen('autojump --completion %s' % q) result = f.read() lines = result.split('\n') if len(lines) == 0: return for line in lines: if len(line) > 0: dir = line[line.find('/'):] # now create an action for the user, and send it to krunner m = Plasma.QueryMatch(self.runner) m.setText(dir) m.setType(Plasma.QueryMatch.ExactMatch) m.setIcon(KIcon("dialog-information")) m.setData(runInTerminal) context.addMatch(q, m)
def create_frame(self): self.frame = Plasma.Frame() self.frame_layout = QGraphicsLinearLayout(Qt.Vertical) self.frame.setEnabledBorders(Plasma.FrameSvg.NoBorder) self.frame.setFrameShadow(Plasma.Frame.Plain) self.frame_layout.setContentsMargins(0, 0, 0, 0) self.frame.setLayout(self.frame_layout)
def setSvg(self, path, name): svg = Plasma.Svg() svg.setImagePath("icons/audio") if svg.isValid(): Plasma.IconWidget.setSvg(self, path, name) else: self.setIcon(KIcon(name))
def init(self): """ Const method for initializing the applet """ # Try to connect dbus mkZpInterface() # Configuration interface support comes with plasma self.setHasConfigurationInterface(False) # Aspect ratio defined in Plasma self.setAspectRatioMode(Plasma.IgnoreAspectRatio) # Theme is a const variable holds Applet Theme self.theme = Plasma.Svg(self) # It gets default plasma theme's background self.theme.setImagePath("widgets/background") # Resize current theme as applet size self.theme.resize(self.size()) self.layout = QGraphicsGridLayout(self.applet) self.layout.setContentsMargins(0,0,0,0) self.layout.setSpacing(0) self.layout.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) if not zpInterface: self.failWidget = FailedWidget(self.applet) self.layout.addItem(self.failWidget,0,0) link.listenSignals("System.Service", self.handler) else: self.initPlasmoid()
def __init__(self, parent): QGraphicsWidget.__init__(self, parent) self.layout = QGraphicsLinearLayout(Qt.Vertical, self) self.layout.setContentsMargins(0,0,0,0) self.layout.setSpacing(0) self.layout.setSizePolicy(QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) label = Plasma.Label(self) label.setText("Zemberek-server doesn't work..") self.layout.addItem(label) button = Plasma.PushButton(self) button.setText("Click to start service") self.layout.addItem(button) self.connect(button, SIGNAL("clicked()"), self.startService)
def initPlasmoid(self): # Layout if not self.layout: self.layout = QGraphicsLinearLayout(Qt.Vertical, self.applet) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.layout.setSizePolicy( QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)) self.setLayout(self.layout) self.constraintsEvent(Plasma.SizeConstraint) if self.mainWidget: self.mainWidget.hide() self.layout.removeAt(0) del self.mainWidget self.mainWidget = WidgetStack(self.applet) self.layout.addItem(self.mainWidget) hotspots = self.getWifi() if hotspots[0] == False: label = Plasma.Label() label.setText(hotspots[1]) self.mainWidget.addItem(label) else: for spot in hotspots[1]: self.mainWidget.addItem(WifiItem_Plasma(self.mainWidget, spot)) # Update the size of Plasmoid self.constraintsEvent(Plasma.SizeConstraint)
def init(self): self.setImmutability(Plasma.Mutable) self.layout = QGraphicsLinearLayout(self.applet) self.layout.setSpacing(0) multiplier = self.config().readEntry('Multiplier', QString('5')).toInt()[0] if self.formFactor() == Plasma.Horizontal: self.layout.setOrientation(Qt.Horizontal) self.size_ = self.config().readEntry('Width', QString('20')).toInt()[0], 20 val = (self.size_[0] - 20) / multiplier self.Control = ControlWidget(Qt.Horizontal, self, multiplier, val) else: self.layout.setOrientation(Qt.Vertical) self.size_ = 20, self.config().readEntry('Height', QString('20')).toInt()[0] val = (self.size_[1] - 20) / multiplier self.Control = ControlWidget(Qt.Vertical, self, multiplier, val) self.setLayout(self.layout) self.setMinimumSize(self.size_[0], self.size_[1]) self.resize(self.size_[0], self.size_[1]) Plasma.ToolTipManager.self().setContent( self.applet, Plasma.ToolTipContent( \ self.Control.slider.toolTip(), \ QString(''), self.icon.icon() ) )
def setLayout(self): global label self.layout = QGraphicsLinearLayout(Qt.Vertical, self.applet) label = Plasma.Label(self.applet) setLabel() self.layout.addItem(label) self.applet.setLayout(self.layout)
def init(self): """ Const method for initializing the applet """ # Configuration interface support comes with plasma self.setHasConfigurationInterface(True) # Aspect ratio defined in Plasma self.setAspectRatioMode(Plasma.IgnoreAspectRatio) # Theme is a const variable holds Applet Theme self.theme = Plasma.Svg(self) # It gets default plasma theme's background self.theme.setImagePath("widgets/background") # Resize current theme as applet size self.theme.resize(self.size()) self.mainWidget = None self.layout = None # Create config dialog if self.prepareConfigDialog(): self.initPlasmoid() # It listens System.Service signals and route them to handler method link.listenSignals("System.Service", self.handler)
def __init__(self, parent=None): plasmascript.Applet.__init__(self, parent) self.kdehome = unicode(KGlobal.dirs().localkdedir()) self.iconPath = '/usr/share/kde4/apps/plasma/plasmoids/kde-plasma-spacer/contents/icons/Spacer.png' self.icon = Plasma.IconWidget() self.icon.setIcon(self.iconPath)
def init(self): #TODO: have a configuration interface to set keybroad shortcut #self.setHasConfigurationInterface(True) self.setAspectRatioMode(Plasma.ConstrainedSquare) self.setBackgroundHints(self.NoBackground) self.sessionBus = dbus.SessionBus() self.powerdevil = self.sessionBus.get_object( 'org.freedesktop.PowerManagement', '/modules/powerdevil') self.icon = Plasma.IconWidget(KIcon('preferences-desktop-screensaver'), '', self.applet) if KGlobalSettings.singleClick(): self.connect(self.icon, SIGNAL('clicked()'), self.turn_off_screen) else: self.connect(self.icon, SIGNAL('doubleClicked()'), self.turn_off_screen) self.connect(self, SIGNAL('active()'), self.turn_off_screen) self.layout = QGraphicsLinearLayout(self.applet) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setSpacing(0) self.layout.addItem(self.icon) self.setLayout(self.layout) self.resize(25, 25)
def create_meter(self): self.meter = Plasma.Meter(self) self.meter.setMeterType(Plasma.Meter.BarMeterHorizontal) self.meter.setSizePolicy( QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed, True)) self.meter.setZValue(0) if self.event_filter: self.meter.installEventFilter(self.event_filter)
def initTooltip(self): if (self.formFactor() != Plasma.Planar): self.tooltip = Plasma.ToolTipContent() self.tooltip.setImage(pixmapFromSVG("audio-volume-high")) self.tooltip.setMainText(i18n("Main Volume")) #self.tooltip.setSubText("") Plasma.ToolTipManager.self().setContent(self.applet, self.tooltip) Plasma.ToolTipManager.self().registerWidget(self.applet)
def create_expander(self): self.expander = Plasma.IconWidget(self.panel) self.expander.setZValue(10) self.connect(self, SIGNAL("geometryChanged()"), self._resize_widgets) self.expander.setSizePolicy( QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)) self.expander.clicked.connect(self.on_expander_clicked) self.expander.setSvg("widgets/arrows", "left-arrow")
def showModalWidget(self, mainWidget): #mainWidget.widgetClose.connect(self.destroyMessageOverlay) if self.messageOverlay: return if self.messageDialog: return corona = self.scene() mainWidget.adjustSize() hint = mainWidget.preferredSize() if (hint.height() > self.widget.size().height()) or ( hint.width() > self.widget.size().width()): ## either a collapsed popup in h/v form factor or just too small, ## so show it in a dialog associated with ourselves #pass if (corona): corona.addOffscreenWidget(mainWidget) if (self.messageDialog): pass else: self.messageDialog = Plasma.Dialog() self.messageDialog.setGraphicsWidget(mainWidget) mainWidget.setParentItem(self.messageDialog.graphicsWidget()) else: self.messageOverlay = self.createMessageOverlay() self.formatOverlay() self.messageOverlay.opacity = 0.8 mainWidget.setParentItem(self.messageOverlay) l = QGraphicsLinearLayout(self.messageOverlay) l.addItem(mainWidget) if self.messageDialog: pos = self.geometry().topLeft().toPoint() if (corona): pos = corona.popupPosition(self.applet, self.messageDialog.size()) self.messageDialog.move(pos) #self.locationToDirection(self.location()) self.messageDialog.animatedShow(Plasma.Direction(0)) self.hidePopup() else: self.messageOverlay.show()
def init_arrangement(self): self.layout = QGraphicsLinearLayout(Qt.Vertical) self.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed, True)) self.layout.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed, True)) self.setLayout(self.layout) self.label = Plasma.Label() self.label.setPreferredHeight(self.sink.mute.size().height()) self.label.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed, True))
def pixmapFromSVG(name): from PyKDE4.plasma import Plasma from PyKDE4.kdeui import KIcon svg = Plasma.Svg() svg.setImagePath("icons/audio") if not svg.isValid(): return KIcon(name).pixmap(22, 22) svg.setContainsMultipleImages(False) return svg.pixmap(name)