/usr/share/pygtk/2.0/demos/infobar.py is in python-gtk2-doc 2.24.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | #!/usr/bin/env python
'''Info Bar
is a widget that can be used to show messages to the user without showing a
dialog. It is often temporarily shown at the top or bottom of a document.
'''
# pygtk version: John Stowers <john.stowers@gmail.com>
import pygtk
pygtk.require('2.0')
import gtk
class InfoBarDemo(gtk.Window):
def __init__(self, parent=None):
gtk.Window.__init__(self)
try:
self.set_screen(parent.get_screen())
except AttributeError:
self.connect('destroy', lambda *w: gtk.main_quit())
self.set_title(self.__class__.__name__)
self.set_border_width(8)
vb = gtk.VBox()
self.add(vb)
bar = gtk.InfoBar()
vb.pack_start(bar, False, False)
bar.set_message_type(gtk.MESSAGE_INFO)
bar.get_content_area().pack_start(
gtk.Label("This is an info bar with message type GTK_MESSAGE_INFO"),
False, False)
bar = gtk.InfoBar()
vb.pack_start(bar, False, False)
bar.set_message_type(gtk.MESSAGE_WARNING)
bar.get_content_area().pack_start(
gtk.Label("This is an info bar with message type GTK_MESSAGE_WARNING"),
False, False)
bar = gtk.InfoBar()
bar.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
bar.connect("response", self._on_bar_response)
vb.pack_start(bar, False, False)
bar.set_message_type(gtk.MESSAGE_QUESTION)
bar.get_content_area().pack_start(
gtk.Label("This is an info bar with message type GTK_MESSAGE_QUESTION"),
False, False)
bar = gtk.InfoBar()
vb.pack_start(bar, False, False)
bar.set_message_type(gtk.MESSAGE_ERROR)
bar.get_content_area().pack_start(
gtk.Label("This is an info bar with message type GTK_MESSAGE_ERROR"),
False, False)
bar = gtk.InfoBar()
vb.pack_start(bar, False, False)
bar.set_message_type(gtk.MESSAGE_OTHER)
bar.get_content_area().pack_start(
gtk.Label("This is an info bar with message type GTK_MESSAGE_OTHER"),
False, False)
frame = gtk.Frame("Info bars")
vb.pack_start(frame, False, False, 8)
vb2 = gtk.VBox(spacing=8)
vb2.set_border_width(8)
frame.add(vb2)
vb2.pack_start(gtk.Label("An example of different info bars"), False, False)
self.show_all()
def _on_bar_response(self, button, response_id):
dialog = gtk.MessageDialog(
self,
gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_INFO,
gtk.BUTTONS_OK,
"You clicked a button on an info bar")
dialog.format_secondary_text("Your response has id %d" % response_id)
dialog.run()
dialog.destroy()
def main():
InfoBarDemo()
gtk.main()
if __name__ == '__main__':
main()
|