Applet resizing (Python)

Thomas Olsen tanghus at gmail.com
Mon Jun 28 11:50:41 CEST 2010


Hi

OK - now I'm stuck again.
I have this simple Plasmoid which has a collapse/expand button that hides
some controls and then rebuilds the layout based on saved settings.

This worked perfectly in earlier KDE SC 4.X versions but now resize() is
somehow getting changed to wrong values.
This is probably a case of not seeing the forest for the trees but here goes:

I connect to the Applets geometryChanged to save the users preference:

  self.applet.geometryChanged.connect(self.new_geometry)

here's the skot I use:

  def new_geometry(self):
    if self.collapsed:
      self.collapsed_height = self.applet.geometry().height()
      print "New collapsed height: %i" % self.collapsed_height
    else:
      self.full_height = self.applet.geometry().height()
      print "New full height: %i" % self.full_height

Then I have a collapse/expand button connected to a slot:

    self.collapse_button = Plasma.ToolButton()
    if self.collapsed:
      self.collapse_button.nativeWidget().setIcon(KIcon("arrow-down"))
    else:
      self.collapse_button.nativeWidget().setIcon(KIcon("arrow-up"))
    self.collapse_button.clicked.connect(self.collapse_or_expand)

  def collapse_or_expand(self):
    if not self.collapsed:
      # snippet for brevity - hiding controls
      self.collapsed = True
      self.collapse_button.nativeWidget().setIcon(KIcon("arrow-down"))
      print "Resizing to: %i" % self.collapsed_height
      self.applet.resize(self.applet.geometry().width(), self.collapsed_height)
    else:
      # snippet for brevity - showing controls
      self.collapsed = False
      self.collapse_button.nativeWidget().setIcon(KIcon("arrow-up"))
      self.applet.resize(self.applet.geometry().width(), self.full_height)
    self.cfg.writeEntry("collapsed", self.collapsed)
    self.layout_widgets()

When collapsing resize() is called with the correct values but straight after
that new_geometry get's triggered again with a height value of ~60 pixels
more...

I'm baffled.

The code is in:

http://code.google.com/p/currency-converter-plasmoid/source/browse/trunk/currency-converter/contents/code/main.py

-- 
Best Regards / Med venlig hilsen

Thomas Olsen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 230 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/plasma-devel/attachments/20100628/465f35b5/attachment.sig 


More information about the Plasma-devel mailing list