Results 1 to 4 of 4

Thread: set font dimension in plasmoid using python or qml

  1. #1

    Default 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
    PHP Code:
    [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
    PHP Code:
    import QtQuick 1.0
     
    Text 
    {
        
    text"Hello world!";

    and with python, where I succeed to change the color only:
    main.py
    PHP Code:
    # -*- 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(125125)
            
    self.setAspectRatioMode(Plasma.Square)
     
        
    def paintInterface(selfpainteroptionrect):
            
    painter.save()
            
    painter.setPen(Qt.red)
            
    painter.setFont(Qt.arial)
            
    painter.drawText(rectQt.AlignVCenter Qt.AlignHCenter"procustecassio")
            
    painter.restore()
     
    def CreateApplet(parent):
        return 
    HelloPython(parent
    and metadata.desktop file
    PHP Code:
    [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 

  2. #2

    Default Re: set font dimension in plasmoid using python or qml[solved withqml]

    one way is:
    PHP Code:
    import QtQuick 1.0
     
    Text 
    {
        
    font.pointSize 80
        color
    "steelblue"
        
    text"procuste";

    thnx, :-) ciao :-) pier

  3. #3
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,671
    Blog Entries
    14

    Default Re: set font dimension in plasmoid using python or qml

    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
    Code:
    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.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  4. #4

    Default Re: set font dimension in plasmoid using python or qml[veerygood]

    maaaanythanks...., it works perfectly for my needs...
    I only added this to the code to have something easily redable for my week eyes :-)
    PHP Code:
        PlasmaComponents.Label {
        
            
    texti18n(userName)
        
    font.pointSize 100
        color
    "red"
        

    thnx :-) ciao :-) pier..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •