Pygobject (42) Buttonbox of layout container

Source: Internet
Author: User
Tags gtk
Gtk.buttonbox

Gtk.buttonbox can control the arrangement of sub parts, such as centering, left, and right. You can also control the primary and secondary relationships of subassemblies, see examples. Inheritance Relationship

Gtk.buttonbox is a direct subclass of Gtk.box
Methods

method Modifier method name and parameter
Static New (orientation)
Get_child_non_homogeneous (Child)
Get_child_secondary (Child)
Get_layout ()
Set_child_non_homogeneous (Child, Non_homogeneous)
Set_child_secondary (Child, Is_secondary)
Set_layout (Layout_style)
Virtual Methods
Properties Short
Name Type FlagsDescription
Layout-style Gtk.buttonboxstyle r/w/en How to lay out of the buttons in the box. Possible values Are:spread, Edge, start and end
Signals Short
NameDescription
Example


Code:

#!/usr/bin/env Python3 # Created by Xiaosanyu in 16/6/28 # section 059 TITLE = "Buttonbox" DESCRIPTION = "" Import gi gi.
        Require_version ("GTK", "3.0") from Gi.repository Import GTK class Buttonboxwindow (Gtk.window): def __init__ (self):
        Gtk.window.__init__ (self, title= "Buttonbox Demo") self.set_border_width Main_vbox = Gtk.vbox () Self.add (main_vbox) box = Gtk.buttonbox (Layout_style=gtk.buttonboxstyle.edge) Main_vbox.pack_start (box, False, False, ten) Child1 = Gtk.button (label= "button1") child1.set_size_request D2 = Gtk.button (label= "Button2") child3 = Gtk.button (label= "Button3") Box.add (child1) Box.add (chil D2) Box.add (child3) # Set_child_non_homogeneous set false, other child size is equal to it, set true, other children size is not the same as it Box.set_chil
        D_non_homogeneous (Child1, True) # Set_child_secondary sets the child to display in a secondary position. If Buttonbox from left to right. Then the child appears on the far right. Box.set_child_secondary (Child2, True) Frame_horz = Gtk.Frame.new ("horizontal button Boxes") Main_vbox.pack_start (Frame_horz, True, true, 10) VBox = Gtk.vbox () vbox.set_border_width (a) frame_horz.add (VBox) Vbox.pack_start (self.cr
        Eate_bbox (Gtk.Orientation.HORIZONTAL, "spread", Gtk.ButtonBoxStyle.SPREAD), True, True, 0)
                        Vbox.pack_start (Gtk.Orientation.HORIZONTAL, "Edge", Self.create_bbox, Gtk.ButtonBoxStyle.EDGE), True, true, 5 Vbox.pack_start (Gtk.Orientation.HORIZONTAL, "Start", Self.create_bbox, Gtk.buttonboxstyle).  START), True, True, 5 Vbox.pack_start (Self.create_bbox (Gtk.Orientation.HORIZONTAL, "End"), (Gtk.ButtonBoxStyle.END), True, True, 5) Vbox.pack_start (Self.create_bbox (Gtk.Orientation.HORIZONTAL, Center) , Gtk.ButtonBoxStyle.CENTER), True, True, 5) Vbox.pack_start (Self.create_bbox (Gtk.orie Ntation. Horizontal, "ExpAnd ", 0, Gtk.ButtonBoxStyle.EXPAND), True, True, 5) Frame_vert = Gtk.Frame.new (" Vertical Button Boxes ") Main_vbox.pack_start (Frame_vert, True, True, ten) Hbox = Gtk.hbox () hbox.set_border _width (Frame_vert.add) (Hbox) Hbox.pack_start (Self.create_bbox (Gtk.Orientation.VERTICAL, "spread", 10, Gtk.ButtonBoxStyle.SPREAD), True, True, 0) Hbox.pack_start (Self.create_bbox (gtk.orientatio N.vertical, "Edge", ten, Gtk.ButtonBoxStyle.EDGE), True, True, 5 Hbox.pack_start (Self.create_bbox (gtk.orientation. VERTICAL, "Start", "Gtk.ButtonBoxStyle.START", True, True, 5) Hbox.pack_start (Self.crea Te_bbox (Gtk.Orientation.VERTICAL, "End", ten, Gtk.ButtonBoxStyle.END), True, True, 5) Hbox.pack_start (self.create_b Box (Gtk.Orientation.VERTICAL, "Center", Gtk.ButtonBoxStyle.CENTER), True, True, 5) HBO X.pack_start (self.create_bbox (Gtk.Orientation.VERTICAL, "Expand", 0, Gtk.ButtonBoxStyle.EXPAND), True, True, 5) @stat ICMethod def create_bbox (horizontal, title, spacing, layout): frame = Gtk.Frame.new (title) Bbox = Gtk. Buttonbox.new (Orientation=horizontal) bbox.set_border_width (5) Frame.add (bbox) bbox.set_layout (LA
        yout) bbox.set_spacing (spacing) button = Gtk.Button.new_with_label ("OK") bbox.add (Button)
        button = Gtk.Button.new_with_label ("Cancel") Bbox.add (button) button = Gtk.Button.new_with_label ("Help") Bbox.add (Button) return frame def main (): win = Buttonboxwindow () win.connect ("Delete-event", G
 Tk.main_quit) Win.show_all () Gtk.main () if __name__ = = "__main__": Main ()

Code resolution

Child1 = Gtk.button (label= "button1") Child1.set_size_request = child2 (
Gtk.button "label=")
child3 = Gtk.button (label= "Button3")
Box.add (child1)
box.add (child2)
Box.add (child3)

The first group of three button groups to explain the Set_child_non_homogeneous method and Set_child_secondary

# Set_child_non_homogeneous Set False (default), the other child size is equal to it, set true, other children size is not the same as it
box.set_child_non_homogeneous (Child1, True)
# Set_child_secondary Sets the child to display in a secondary position. If the buttonbox from left to right. Then the child appears on the far right.
Box.set_child_secondary (Child2, True)

Next, the main introduction of the use of Gtk.buttonboxstyle, code combined with the example map to see, more clearly, not long-winded ~





Code Download Address: http://download.csdn.net/detail/a87b01c14/9594728

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.