set font dimension in plasmoid using python or qml

I would like to create a plasmoid, I started with a hello world plasmoid, but I cannot set the dimensions of the content and the font, how can I get big font in the plasmoid??

first I used this for qml:

metadata.desktop file

[Desktop Entry]
Name=Hello QML
Comment=A hello world widget in QML
Icon=chronometer
 
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml
X-Plasma-DefaultSize=200,100
 
X-KDE-PluginInfo-Author=Frederik Gladhorn
X-KDE-PluginInfo-Email=gladhorn@kde.org
X-KDE-PluginInfo-Website=http://plasma.kde.org/
X-KDE-PluginInfo-Category=Examples
X-KDE-PluginInfo-Name=org.kde.hello-qml
X-KDE-PluginInfo-Version=0.0
 
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
X-KDE-ServiceTypes=Plasma/Applet
Type=Service

and main.qml file

import QtQuick 1.0
 
Text {
    text: "Hello world!";
}

and with python, where I succeed to change the color only:
main.py

# -*- coding: utf-8 -*-
# <Copyright and license information goes here.>
from PyQt4.QtCore import Qt
from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript
 
class HelloPython(plasmascript.Applet):
    def __init__(self,parent,args=None):
        plasmascript.Applet.__init__(self,parent)
 
    def init(self):
        self.setHasConfigurationInterface(False)
        self.resize(125, 125)
        self.setAspectRatioMode(Plasma.Square)
 
    def paintInterface(self, painter, option, rect):
        painter.save()
        painter.setPen(Qt.red)
        painter.setFont(Qt.arial)
        painter.drawText(rect, Qt.AlignVCenter | Qt.AlignHCenter, "procustecassio")
        painter.restore()
 
def CreateApplet(parent):
    return HelloPython(parent) 


and metadata.desktop file

[Desktop Entry]
Encoding=UTF-8
Name=Procuste user
Name[nl]=Hallo Python
Type=Service
ServiceTypes=Plasma/Applet
Icon=chronometer
X-Plasma-API=python
X-Plasma-MainScript=code/main.py
X-KDE-PluginInfo-Author=Simon Edwards
X-KDE-PluginInfo-Email=simon@simonzone.com
X-KDE-PluginInfo-Name=hello-python
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 


one way is:

import QtQuick 1.0
 
Text {
    font.pointSize : 80
    color: "steelblue"
    text: "procuste";
}

thnx, :slight_smile: ciao :slight_smile: pier

LOL, I’ve been busy on the same thing, re. your previous post. With the help of some G+ KDE member I’ve come up with this:

Install Plasmate, open it, pick Plasma Widget, and it comes up with a “Hello World” widget. Change the code to


import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents


Item {
    width: 150
    height: 300
    id: mainitem
    property string userName


    PlasmaComponents.Label {
    
        text: i18n(userName)
    }


    PlasmaCore.DataSource {
        id: whoamisource
        engine: "executable"
       
        connectedSources: "whoami"]
       
        onNewData:{
            mainitem.userName = data.stdout
        }
    }
}

And you have a basic plasmoid stating the active username. The layout is far from perfect, but it works, getting the font OK should be easy to find through Google, or example/tutorial scripts.

:):)maaaanythanks…, it works perfectly for my needs…:slight_smile:
I only added this to the code to have something easily redable for my week eyes :slight_smile:

    PlasmaComponents.Label {
    
        text: i18n(userName)
    font.pointSize : 100
    color: "red"
    }

thnx :slight_smile: ciao :slight_smile: pier…