On 13/03/10 21:25, Nikolaus Rath wrote:
Neil Dugan <py...@butterflystitches.com.au> writes:
  
Nikolaus Rath wrote:
    
Hello,

For some reason I'm just not able to figure out how use the packing
parameters in the right way to get the layout that I want.

Can someone help me out? What I want is this:

  - In the first row, the label and spin button should be centered and
    right next to each other (no space in between).

  - In the second row, all buttons should have the same size with 10px
    spacing between them. The set of buttons should again be centered.

  - In the third line, the one button should be just as large as the 4
    buttons in the previous line (and also centered).

  - The text area should fill the rest of the window

Here is the code that I am using right now:


      
I don't know if this is the most effect way of doing what you want.
fixed a couple of minor other problems the lambda for the 
'delete_event' need arguments and the Control.blub() function need 
some as well.
    
That already looks almost perfect, thank you so much!

(The only problem left is that the buttons grow when the window is
resized and that the last button is not as wide as the buttons in the
next-to-last line all together).


But could you comment on a couple of your changes? I'd very much like to
understand what I was doing wrong, so that next time I don't have to ask
but can create the layout myself...

,----
| $ diff -u -w box.py box_new.py 
| --- box.py	2010-03-13 14:06:12.020104562 -0500
| +++ blub.py	2010-03-13 10:36:00.940105089 -0500
| @@ -10,70 +10,69 @@
|  
|      def __init__(self):
|          self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
| -        self.window.connect("delete_event", lambda: False)
| +         self.window.connect("delete_event", lambda x,y: False)
|          self.window.connect("destroy", gtk.main_quit)
|          self.window.set_border_width(10)
|          self.window.set_title('Dispatch Control')
|  
|          vbox = gtk.VBox(False, 10)
| -        vbox.pack_start(self.make_shot_box(), False)
| +         vbox.pack_start(self.make_shot_box(), False, False)

Isn't the third parameter to pack_start ignored anyway if the second one
is False?

|          vbox.pack_start(self.make_button_box(), False)
|          vbox.pack_start(self.make_textarea(), True, True)
| -        vbox.show()
|          self.window.add(vbox)
| -        self.window.show()
| +         self.window.show_all()
|  

I guess the removal of the .show() calls in favor of the
window.show_all() call does not have an effect on the layout, right?

   
|      def make_shot_box(self):
| -        box = gtk.HBox(True, 10)
| +         box = gtk.HBox(False, 10)


This seems to get rid of the spacing between the label and spin
button -- but why?

|  
| +         box.pack_start(gtk.Label(''), True, True, 0)

What is this for?

|          label = gtk.Label("Create shot:")
|          label.set_justify(gtk.JUSTIFY_RIGHT)
|          label.show()
|          box.pack_start(label, False, False, 0)
|  
|          cur_shot = 42
| -        self.shotno = gtk.Adjustment(value=cur_shot+1, lower=1, upper=cur_shot+1,
| +         self.shotno = gtk.Adjustment(value=cur_shot+1, lower=1,
| +                                      upper=cur_shot+1,
|                                       step_incr=1)
|          button = gtk.SpinButton(adjustment=self.shotno, digits=0)
|          button.set_numeric(True)
| -        button.show()
|          box.pack_start(button, False, False, 0)
| +         box.pack_start(gtk.Label(''), True, True, 0)

Again, why the empty label?


     
Thanks!

   -Nikolaus
  
#box.pack_start(gtk.Label(''), True, True)
button = gtk.Button("Full Cycle")
button.connect('clicked', self.blub, 5)
box.pack_start(button, True, True)
#box.pack_start(gtk.Label(''), True, True)

Should give you what you want :-)
--

Regards

Paul Malherbe

+27 (0) 21 6711866
+27 (0) 82 9005260


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to