[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: Creating a rectangular icon
From: Antony Loebs <barefootedjournalist () gmail ! com>
Date: 2010-02-25 21:29:10
Message-ID: 469a3d631002251329r7097846el7ed066a7e04fa211 () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
I have been trying to figure out how to display a rectangular image in the
panel to use as a button. The image itself is 30x120, but I can't get it to
display to my satisfaction. If I use IconWidget, the image is squashed into
a square. If I use PushButton, the image is likewise squashed by the
button's borders. I tried changing the stylesheet for the button, setting
margin and padding to 0, but with no success. Below is the sample code (the
PushButton code is commented out).
---
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyKDE4.plasma import Plasma
from PyKDE4 import plasmascript
class PanelButton(plasmascript.Applet):
def __init__(self,parent,args=None):
plasmascript.Applet.__init__(self,parent)
def init(self):
self.setAspectRatioMode(Plasma.KeepAspectRatio)
# No configuration interface supported
self.setHasConfigurationInterface(False)
self.theme = Plasma.Svg(self)
self.theme.setImagePath("widgets/background")
self.setBackgroundHints(Plasma.Applet.DefaultBackground)
self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
#self.button = Plasma.PushButton(self.applet)
#self.button.setImage(self.package().path() +
"contents/images/image.png")
#self.button.setStyleSheet = ("margin: 0px; padding: 0px;")
#self.connect(self.button, SIGNAL("clicked()"), self.notify)
self.button = Plasma.IconWidget(self.applet)
self.button.setIcon(self.package().path() +
"contents/images/image.png")
self.connect(self.button, SIGNAL("clicked()"), self.notify)
self.layout.addItem(self.button)
self.applet.setLayout(self.layout)
self.resize(120, 30)
def notify(self):
pass
def CreateApplet(parent):
return PanelButton(parent)
---
[Attachment #5 (text/html)]
I have been trying to figure out how to display a rectangular image in the panel to \
use as a button. The image itself is 30x120, but I can't get it to display to my \
satisfaction. If I use IconWidget, the image is squashed into a square. If I use \
PushButton, the image is likewise squashed by the button's borders. I tried \
changing the stylesheet for the button, setting margin and padding to 0, but with no \
success. Below is the sample code (the PushButton code is commented out). <br> \
<br>---<br>from PyQt4.QtCore import *<br>from PyQt4.QtGui import *<br>from \
PyKDE4.plasma import Plasma<br>from PyKDE4 import plasmascript<br><br>class \
PanelButton(plasmascript.Applet):<br> def __init__(self,parent,args=None):<br> \
plasmascript.Applet.__init__(self,parent)<br><br> def init(self):<br> \
self.setAspectRatioMode(Plasma.KeepAspectRatio)<br> # No configuration \
interface supported<br> self.setHasConfigurationInterface(False)<br> \
self.theme = Plasma.Svg(self)<br> \
self.theme.setImagePath("widgets/background")<br> \
self.setBackgroundHints(Plasma.Applet.DefaultBackground)<br><br> self.layout = \
QGraphicsLinearLayout(Qt.Horizontal, self.applet)<br> <br> #self.button = \
Plasma.PushButton(self.applet)<br> #self.button.setImage(self.package().path() \
+ "contents/images/image.png")<br> #self.button.setStyleSheet = \
("margin: 0px; padding: 0px;")<br> #self.connect(self.button, \
SIGNAL("clicked()"), self.notify)<br><br> self.button = \
Plasma.IconWidget(self.applet)<br> self.button.setIcon(self.package().path() + \
"contents/images/image.png")<br> self.connect(self.button, \
SIGNAL("clicked()"), self.notify)<br><br> \
self.layout.addItem(self.button)<br> self.applet.setLayout(self.layout)<br> \
self.resize(120, 30)<br><br> def notify(self):<br>
pass<br><br>def CreateApplet(parent):<br> return \
PanelButton(parent)<br>---<br>
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic