Gtkinfobar inheritance Relationship Methods Virtual Methods Properties Signals Example
Gtk.infobar
Gtk.infobar is used to display information to the user without displaying a dialog box dialog. It is often at the top or bottom of the document. Its API is very much like an inheritance relationship with Dialog
Gtk.infobar is a direct subclass of Gtk.box
Methods
method modifier |
method name and parameter |
static |
New () |
|
add_action_widget (Child, response_id) |
|
Add_button (Button_text, response_id) |
|
get_act Ion_area () |
|
get_content_area () |
|
ge T_message_type () |
|
Get_show_close_button () |
|
response (response_id) |
|
set_default_response (response_id) |
|
set_message_type (message_type) |
|
set_response_sensitive (response_id, setting) |
|
Set_show_close_button (setting) |
Virtual Methods
|
Do_close () |
Do_response (response_id) |
Properties
Name |
Type |
Flags | Short
Description |
Message-type |
Gtk.messagetype |
r/w/c/en |
The type of message |
Show-close-button |
bool |
r/w/c/en |
Whether to include a standard close button |
Signals
Name | Short
Description |
Close |
The:: Close signal are a keybinding signal which gets emitted when the user uses a keybinding to dismiss the info bar. |
Response |
Emitted when a action widget is clicked or the application programmer calls Gtk.Dialog.response (). |
Example
Code:
#!/usr/bin/env Python3 # section 060 #-*-Mode:python; Py-indent-offset:4-*-# vim:tabstop=4 shiftwidth=4 expandtab # Copyright (C) Red Hat, Inc., John (J5) Palmieri & Lt;johnp@redhat.com> # This library are free software; Can redistribute it and/or # modify it under the terms of the GNU Lesser General public # License as published by the Free Software Foundation;
Either # version 2.1 of the License, or (at your option) any later version. # This library is distributed in the hope that it'll be useful, # but without any WARRANTY; Without even the implied warranty of # merchantability or FITNESS for A particular purpose.
The GNU # Lesser general public License for more details. # You are should have received a copy of the GNU Lesser General public # License along and this library; If not, write to the free Software # Foundation, INC, Wuyi Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA TITLE = "Info Bars" DESCRIPTION = "" "Info Bar widgets are used to rePort important messages to the user.
"" "Import gi gi.require_version (' Gtk ', ' 3.0 ') from Gi.repository import GTK class Infobarapp:def __init__ (self):
Self.window = Gtk.window () self.window.set_title (' Info Bars ') self.window.set_border_width (8)
Self.window.connect (' Destroy ', gtk.main_quit) VBox = Gtk.vbox (spacing=0) self.window.add (VBox) Bar = Gtk.infobar () bar.connect (' response ', self.on_bar_response) Vbox.pack_start (bar, False, False, 5 ) Bar.set_message_type (Gtk.MessageType.INFO) button = Gtk.Button.new_from_icon_name ("Help-about", Gtk.icon Size.button) Bar.add_action_widget (BUTTON, Gtk.ButtonsType.OK) label = Gtk.label (label= ' This are an info ba R with message type Gtk.MessageType.INFO ') Bar.get_content_area (). Pack_start (label, False, False, 5) bar = Gtk.infobar () Vbox.pack_start (bar, False, False, 5) Bar.set_message_type (Gtk.MessageType.WArning) label = Gtk.label (Label= ' This is a info bar with message type Gtk.MessageType.WARNING ') Bar.get_co Ntent_area (). Pack_start (label, False, False, 5) bar = Gtk.infobar () Bar.add_button (GTK.STOCK_OK, Gtk.resp Onsetype.ok) Bar.add_button (Gtk.stock_cancel, Gtk.ResponseType.CANCEL) bar.connect (' response ', Self.on_bar _response) Vbox.pack_start (bar, False, False, 5) bar.set_message_type (Gtk.MessageType.QUESTION) LA Bel = Gtk.label (label= ' This is a info bar with message type Gtk.MessageType.QUESTION ') Bar.get_content_area (). pac K_start (label, False, False, 5) bar = Gtk.infobar () Vbox.pack_start (bar, False, False, 5) Bar.set _message_type (Gtk.MessageType.ERROR) label = Gtk.label (Label= ' This is a info bar with message type Gtk.messagetyp E.error ') Bar.get_content_area (). Pack_start (label, False, False, 5) bar = Gtk.infobar () vbox.pack _start (bar, False, False, 5) Bar.set_message_type (Gtk.MessageType.OTHER) label = Gtk.label (Label= ' This is a info bar with message Type Gtk.MessageType.OTHER ') Bar.get_content_area (). Pack_start (label, False, False, 5) frame = Gtk.frame (label= "Info bars") Vbox.pack_start (frame, False, false, 8) Vbox2 = Gtk.vbox (spacing=8) vbox2.set _border_width (8) Frame.add (vbox2) # Standard message Dialog label = Gtk.label (label= ' A example O F different Info bars ') Vbox2.pack_start (label, False, False, 0) Self.window.show_all () def on_bar_r
Esponse (self, Info_bar, response_id): Dialog = Gtk.messagedialog (Transient_for=self.window, Modal=true, Destroy_with_parent=true, M
Essage_type=gtk.messagetype.info, Buttons=gtk.buttonstype.ok, text= ' You clicked on a Info Bar ') dialog.format_secondary_text (' Your response has ID%d '% response_id) Dialog.run () Dialog.destroy () def main (): Infobarapp () Gtk.main () if __name__ = = ' __main__ ': Main ()
Code resolution
Several InfoBar are used in the same, here only the first
Bar = Gtk.infobar ()
Create a InfoBar
Bar.connect (' response ', self.on_bar_response)
Connect to Response signal
Vbox.pack_start (bar, False, false, 5)
Add bar to the box layout container
Bar.set_message_type (Gtk.MessageType.INFO)
Set InfoBar type
button = Gtk.Button.new_from_icon_name ("Help-about", Gtk.IconSize.BUTTON)
Create a Picture button
Bar.add_action_widget (button, Gtk.ButtonsType.OK)
Add a button to the InfoBar action area
Label = Gtk.label (Label= ' This is a info bar with message type Gtk.MessageType.INFO ')
Create a label
Bar.get_content_area (). Pack_start (label, False, False, 5)
Add a label to the content area of InfoBar
Code Download Address: http://download.csdn.net/detail/a87b01c14/9594728