Pygobject (48) Headerbar of layout container

Source: Internet
Author: User
Tags gtk

Gtkheaderbar inheritance Relationship Methods Virtual Methods Properties Signals Example

Gtk.headerbar

Gtk.headerbar title bar inheritance Relationship

Gtk.headerbar is a direct subclass of Gtk.container
Methods

method Modifier method name and parameter
Static New ()
Get_custom_title ()
Get_decoration_layout ()
Get_has_subtitle ()
Get_show_close_button ()
Get_subtitle ()
Get_title ()
Pack_end (Child)
Pack_start (Child)
Set_custom_title (Title_widget)
Set_decoration_layout (Layout)
Set_has_subtitle (setting)
Set_show_close_button (setting)
Set_subtitle (subtitle)
Set_title (title)
Virtual Methods
Properties Short
Name Type FlagsDescription
Custom-title Gtk.widget r/w Custom Title widget to display
Decoration-layout Str r/w Define the layout method, see example
Decoration-layout-set bool r/w Whether the Decoration-layout property has been set
Has-subtitle bool r/w/en Do you want to place the subheadings in space?
Show-close-button bool r/w/en Whether to show the Close button
Spacing Int r/w/en Child part Spacing
Subtitle Str r/w Sub headings
Title Str r/w Title
Signals Short
NameDescription
Example


Code:

#!/usr/bin/env Python3 # Created by Xiaosanyu in 16/6/13 # section 065 TITLE = "Headerbar" DESCRIPTION = "" "Gtk.headerbar is similar to a horizontal gtk.box.
It allows children to is placed at the start or the end.
In addition, it allows a title and subtitle to be displayed. "" "Import os Import gi gi.require_version (' Gtk ', ' 3.0 ') from gi.repository import Gtk, Gio, Gdkpixbuf class Headerbarw Indow (Gtk.window): def __init__ (self): gtk.window.__init__ (Self, title= "Headerbar Demo") Self.set_bord Er_width (self.set_default_size) # Set logo icon = GdkPixbuf.Pixbuf.new_from_file (OS). Path.join (Os.path.dirname (__file__), ". /data/gtk-logo-rgb.gif ")] # Transparent icon = Icon.add_alpha (True, 0xFF, 0xFF, 0xff) self.set_de
        Fault_icon (icon) HB = Gtk.headerbar () hb.set_decoration_layout ("Icon,menu:minimize,maximize,close") Hb.set_show_close_button (True) hb.props.title = "Headerbar ExaMple "Hb.set_subtitle (subtitle)") Self.set_titlebar (HB) button = Gtk.button () icon = Gi
        O.themedicon (name= "mail-send-receive-symbolic") image = Gtk.Image.new_from_gicon (icon, Gtk.IconSize.BUTTON) Button.add (image) Hb.pack_end (button) box = Gtk.box (orientation=gtk.orientation.horizontal) GTK . Stylecontext.add_class (Box.get_style_context (), "linked") button = Gtk.button () button.add (Gtk.arrow (Arro
        W_type=gtk.arrowtype.left, Shadow_type=gtk.shadowtype.none)) Box.add (button) button = Gtk.button ()

        Button.add (Gtk.arrow (Arrow_type=gtk.arrowtype.right, Shadow_type=gtk.shadowtype.none)) Box.add (button) Hb.pack_start (Box) Self.add (Gtk.textview ()) def main (): win = Headerbarwindow () win.connect ("Delete-eve
 NT ", Gtk.main_quit) Win.show_all () Gtk.main () if __name__ = =" __main__ ": Main ()

Code resolution
Set window default icon

# set logo
icon = GdkPixbuf.Pixbuf.new_from_file (Os.path.join os.path.dirname (__file__), ". /data/gtk-logo-rgb.gif ")]
# transparent
icon = Icon.add_alpha (True, 0xFF, 0xFF, 0xff)
Self.set_default_ Icon (icon)
HB = Gtk.headerbar ()

Create Gtk.headerbar

Hb.set_decoration_layout ("Icon,menu:minimize,maximize,close")

Set the layout by separating the names with commas and colons to separate the left and right parts
On the left is the icon, the middle is a custom area (menu), followed by the minimized Maximize and Close button (minimize,maximize,close "), the order can be changed arbitrarily

The remaining piece of code mainly explains the following two sentences

box = Gtk.box (orientation=gtk.orientation.horizontal)
Gtk.StyleContext.add_class (Box.get_style_context (), " Linked ")

The box is styled "linked" so that the child parts in box are spaced between 0 and the child parts are not in contact with fillet radians.





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.