Reply
Thread Tools
ammyt's Avatar
Posts: 1,918 | Thanked: 3,118 times | Joined on Oct 2010 @ My pants
#1
Seems that I have a little problem with python-hildon button layout:
PHP Code:
import gtk
import hildon

def show_new_window
(widget):
  
win hildon.StackableWindow()
  
# ... configure new window
  
win.show_all()

def main():
  
program hildon.Program.get_instance()

  
win hildon.StackableWindow()
  
win.set_title("Main window")

  
# ... add some widgets to the window
  
button hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH gtk.HILDON_SIZE_FINGER_HEIGHT,
                           
hildon.BUTTON_ARRANGEMENT_VERTICAL)
  
button.set_text("Some title""some value")

  
image gtk.image_new_from_stock(gtk.STOCK_INFOgtk.ICON_SIZE_BUTTON)
  
button.set_image(image)
  
button.set_image_position(gtk.POS_RIGHT)
  
button.connect("clicked"show_new_window)
  
win.add(button)
  
win.connect("destroy"gtk.main_quitNone)

  
# This call show the window and also add the window to the stack
  
win.show_all()
  
gtk.main()

if 
__name__ == "__main__":
  
main() 
I researched for a week but just couldn't get it. Why is the button appearing as many buttons? When you click any where on the buttons, all of them flash at once as if they're all one button. Any help would be greatly appreciated.
Attached Images
 
 
Posts: 324 | Thanked: 371 times | Joined on Dec 2009 @ Vancouver, BC
#2
It is just one button. The theme is tiling the background image instead of stretching it across the whole button (could be because of the flag gtk.HILDON_SIZE_FINGER_HEIGHT which tells it the button is only that finger height high).
 

The Following User Says Thank You to Slocan For This Useful Post:
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#3
Put your button into a container, which does not stretch the
child widgets, gtk.VBox for example:

Code:
import gtk
import hildon


def main():
        program = hildon.Program.get_instance()
        win = hildon.StackableWindow()
        win.set_title("test")
        button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
        button.set_text("some text", "some value")
        box = gtk.VBox(False, 0)
        box.pack_start(button, False, False, 0)
        win.add(box)
        win.show_all()
        gtk.main()

if __name__ == "__main__":
        main()
 

The Following User Says Thank You to nicolai For This Useful Post:
ammyt's Avatar
Posts: 1,918 | Thanked: 3,118 times | Joined on Oct 2010 @ My pants
#4
Originally Posted by nicolai View Post
Put your button into a container, which does not stretch the
child widgets, gtk.VBox for example:

Code:
import gtk
import hildon


def main():
        program = hildon.Program.get_instance()
        win = hildon.StackableWindow()
        win.set_title("test")
        button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT, hildon.BUTTON_ARRANGEMENT_VERTICAL)
        button.set_text("some text", "some value")
        box = gtk.VBox(False, 0)
        box.pack_start(button, False, False, 0)
        win.add(box)
        win.show_all()
        gtk.main()

if __name__ == "__main__":
        main()
Uhhh, thanks a lot!
It really made me go nuts! Will try that right now and report.
 
ammyt's Avatar
Posts: 1,918 | Thanked: 3,118 times | Joined on Oct 2010 @ My pants
#5
Works like a treat, thanks!
Attached Images
 
 
Reply


 
Forum Jump


All times are GMT. The time now is 22:51.