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.
#!/usr/bin/env python
from __future__ import print_function, absolute_import
import pygtk
pygtk.require('2.0')
import gtk
class Control(object):
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
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, False)
vbox.pack_start(self.make_button_box(), False)
vbox.pack_start(self.make_textarea(), True, True)
self.window.add(vbox)
self.window.show_all()
def make_shot_box(self):
box = gtk.HBox(False, 10)
box.pack_start(gtk.Label(''), True, True, 0)
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,
step_incr=1)
button = gtk.SpinButton(adjustment=self.shotno, digits=0)
button.set_numeric(True)
box.pack_start(button, False, False, 0)
box.pack_start(gtk.Label(''), True, True, 0)
return box
def make_button_box(self):
box = gtk.HBox(True, 10)
button = gtk.Button("INIT")
button.connect('clicked', self.blub, 1)
box.pack_start(button, True, True, 0)
button = gtk.Button("PULSE ON")
button.connect('clicked', self.blub, 2)
box.pack_start(button, True, True, 0)
button = gtk.Button("STORE")
button.connect('clicked', self.blub, 3)
box.pack_start(button, True, True, 0)
button = gtk.Button("ANALYSIS")
button.connect('clicked', self.blub, 4)
box.pack_start(button, True, True, 0)
vbox = gtk.VBox(True, 10)
vbox.pack_start(box, False, False)
box = gtk.HBox()
vbox.pack_start(box, False, False)
box.pack_start(gtk.Label(''), True, True)
button = gtk.Button("Full Cycle")
button.connect('clicked', self.blub, 5)
box.pack_start(button, False, False)
box.pack_start(gtk.Label(''), True, True)
return vbox
def make_textarea(self):
textview = gtk.TextView()
textview.set_editable(True)
textview.set_wrap_mode(gtk.WRAP_WORD)
self.comment = textview.get_buffer()
sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sw.set_border_width(5)
sw.add(textview)
frame = gtk.Frame('Shot Comment')
frame.add(sw)
return frame
def blub(self, widget, number):
print('Click! %d' % (number))
if __name__ == '__main__':
control = Control()
gtk.main()
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/