Creating a rectangular icon

Aaron J. Seigo aseigo at kde.org
Sat Feb 27 00:57:18 CET 2010


On February 26, 2010, Antony Loebs wrote:
> On Fri, Feb 26, 2010 at 11:40 AM, Marco Martin <notmart at gmail.com> wrote:
> > On Thu, Feb 25, 2010 at 10:29 PM, Antony Loebs
> > 
> > <barefootedjournalist at gmail.com> wrote:
> > >  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).
> > 
> > to just display an image you probably want to use Label (yes, it can
> > display images and a click signaliirc)
> > 
> >  Two problems: one, I don't see how to make a click on a label register,
> 
> and two, while it looks fine on the desktop, if it is started in the panel
> it is squashed horizontally (so the image looks like a vertical line about
> four or five pixels wide). Additionally, when I rescale the panel, the
> image scales vertically, but not horizontally.

sounds like a layouting issue; you probably need to set a preferred and/or 
minimum size in your widget.

remember that panels can be very small, however. it's never fun when a widget 
enforces a minimum size that's overly large. :)

> ---
> import subprocess
> 
> self.button = Plasma.Label(self.applet)
> self.button.setImage(self.package().path() + "contents/images/image.png")

that should be: self.package().filePath("images", "image.png")


-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Development Frameworks


More information about the Plasma-devel mailing list