[gnome-devel-docs] tutorials python: simpler example of menubar
- From: Marta Maria Casetti <mmcasetti src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] tutorials python: simpler example of menubar
- Date: Sat, 4 Aug 2012 09:50:20 +0000 (UTC)
commit d61fb3ddc193343e778fcdabd4cbbd968fb89d86
Author: Marta Maria Casetti <mmcasetti gmail com>
Date: Fri Aug 3 12:42:11 2012 +0100
tutorials python: simpler example of menubar
platform-demos/C/samples/menubar_basis.py | 35 +++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/samples/menubar_basis.py b/platform-demos/C/samples/menubar_basis.py
new file mode 100644
index 0000000..1394854
--- /dev/null
+++ b/platform-demos/C/samples/menubar_basis.py
@@ -0,0 +1,35 @@
+from gi.repository import Gtk
+import sys
+
+class MyWindow(Gtk.ApplicationWindow):
+ def __init__(self, app):
+ Gtk.Window.__init__(self, title="MenuBar Example", application=app)
+ self.set_default_size(200, 200)
+
+class MyApplication(Gtk.Application):
+ def __init__(self):
+ Gtk.Application.__init__(self)
+
+ def do_activate(self):
+ win = MyWindow(self)
+ win.show_all()
+
+ def do_startup(self):
+ Gtk.Application.do_startup(self)
+
+ # a builder to add the UI designed with Glade to the grid:
+ builder = Gtk.Builder()
+ # get the file (if it is there)
+ try:
+ builder.add_from_file("menubar_basis.ui")
+ except:
+ print "file not found"
+ sys.exit()
+
+ # we use the method Gtk.Application.set_menubar(menubar) to add the menubar
+ # to the application (Note: NOT the window!)
+ self.set_menubar(builder.get_object("menubar"))
+
+app = MyApplication()
+exit_status = app.run(sys.argv)
+sys.exit(exit_status)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]