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:
#!/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: 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_button_box(), False)
vbox.pack_start(self.make_textarea(), True, True)
vbox.show()
self.window.add(vbox)
self.window.show()
def make_shot_box(self):
box = gtk.HBox(True, 10)
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)
button.show()
box.pack_start(button, False, False, 0)
box.show()
return box
def make_button_box(self):
box = gtk.HBox(True, 10)
button = gtk.Button("INIT")
button.connect('clicked', self.blub, None)
button.show()
box.pack_start(button, True, False, 0)
button = gtk.Button("PULSE ON")
button.connect('clicked', self.blub, None)
button.show()
box.pack_start(button, True, False, 0)
button = gtk.Button("STORE")
button.connect('clicked', self.blub, None)
button.show()
box.pack_start(button, True, False, 0)
button = gtk.Button("ANALYSIS")
button.connect('clicked', self.blub, None)
button.show()
box.pack_start(button, True, False, 0)
box.show()
vbox = gtk.VBox(True, 10)
vbox.pack_start(box, False, False)
button = gtk.Button("Full Cycle")
button.connect('clicked', self.blub, None)
button.show()
vbox.pack_start(button, False, False)
vbox.show()
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()
textview.show()
sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
sw.set_border_width(5)
sw.add(textview)
sw.show()
frame = gtk.Frame('Shot Comment')
frame.add(sw)
frame.show()
return frame
def blub(self):
print('Click!')
if __name__ == '__main__':
control = Control()
gtk.main()
Best,
-Nikolaus
--
»Time flies like an arrow, fruit flies like a Banana.«
PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/