Active Topics

 


Reply
Thread Tools
HangLoose's Avatar
Posts: 319 | Thanked: 289 times | Joined on Sep 2009 @ Lisboa, Portugal
#1
So I am trying to put a button as a home widget but I cant seem to set it size. Always shows it very small, even though image is quite big.

What am I doing wrong?
------
Code:
 def __init__(self):
     button = hildon.Button(gtk.HILDON_SIZE_THUMB_HEIGHT |
gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
     image = gtk.Image()
     image.set_from_file("/usr/lib/hildon-desktop/image.jpg")
     image.show()
     button.set_image(image)
     button.show_all()
     self.add(button)
 
HangLoose's Avatar
Posts: 319 | Thanked: 289 times | Joined on Sep 2009 @ Lisboa, Portugal
#2
sorry for it but... bump.
 
pelago's Avatar
Posts: 2,121 | Thanked: 1,540 times | Joined on Mar 2008 @ Oxford, UK
#3
No idea, but maybe if you post the full source code (or even better, cut down to a minimal version that shows the problem), someone might be able to help.
 
HangLoose's Avatar
Posts: 319 | Thanked: 289 times | Joined on Sep 2009 @ Lisboa, Portugal
#4
Originally Posted by pelago View Post
No idea, but maybe if you post the full source code (or even better, cut down to a minimal version that shows the problem), someone might be able to help.
Well... thats pretty much it
I am not that advanced on it yet...

Code:
imports....

def hello(widget, data):
    print "Hello World!"

class HelloHomePlugin(hildondesktop.HomePluginItem):
 def __init__(self):
     button = hildon.Button(gtk.HILDON_SIZE_THUMB_HEIGHT | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
     image = gtk.Image()
     image.set_from_file("/usr/lib/hildon-desktop/image.jpg")
     image.show()
     button.set_image(image)
     button.show_all()
     self.add(button)

hd_plugin_type = HelloHomePlugin
 
Posts: 432 | Thanked: 645 times | Joined on Mar 2009
#5
Hi,

why aren't you using a gtk button, and set the size like:

Code:
     button = gtk.Button()
     button.set_size_request(200,200)
if you don't specify the size, then it will be set automatically. Or try HILDON_SIZE_AUTO?

Daniel
 

The Following User Says Thank You to danielwilms For This Useful Post:
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#6
Originally Posted by danielwilms View Post
why aren't you using a gtk button, and set the size like:

Code:
     button = gtk.Button()
     button.set_size_request(200,200)
if you don't specify the size, then it will be set automatically. Or try HILDON_SIZE_AUTO?
For that button, the themeing would be wrong (it would look "flat").

HangLoose: Try having a VBox as "container" and set its size to a bigger value than the button using set_size_request, and then add the container to the widget (self.add(container)) and after that add the button (with the same constructor as in your initial post) to the VBox with "pack_start" and expand set to False. Here are two examples using a normal window (the first is the "bad" one, and the second is the "good" one):

Code:
import gtk
import hildon

w = hildon.StackableWindow()
w.connect('destroy', gtk.main_quit)

b = hildon.Button(gtk.HILDON_SIZE_THUMB_HEIGHT,
                  hildon.BUTTON_ARRANGEMENT_VERTICAL)
b.set_title('Bla')
b.set_value('Blubb')
w.add(b)
w.show_all()
gtk.main()
Adding the VBox:

Code:
import gtk
import hildon

w = hildon.StackableWindow()
w.connect('destroy', gtk.main_quit)

b = hildon.Button(gtk.HILDON_SIZE_THUMB_HEIGHT,
                  hildon.BUTTON_ARRANGEMENT_VERTICAL)
b.set_title('Bla')
b.set_value('Blubb')
vb = gtk.VBox()
w.add(vb)
vb.pack_start(b, expand=False)
w.show_all()
gtk.main()
By the way, you should specify either HILDON_SIZE_THUMB_HEIGHT or HILDON_SIZE_FINGER_HEIGHT, but not both (the thumb height is a little bigger than the finger height).
 

The Following 4 Users Say Thank You to thp For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 01:07.