Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
granite-demo in python
import sys
from gi.repository import Gtk, Gdk, GdkPixbuf
from gi.repository import Granite
class DemoApp(Granite.Application):
application_id="demo.granite.org"
program_name="Granite Demo"
app_years= "2012"
build_version="1.0"
main_url = "https://launchpad.net/granite";
bug_url = "https://bugs.launchpad.net/granite";
help_url = "https://answers.launchpad.net/granite";
translate_url = "https://translations.launchpad.net/granite";
about_authors = {"Kekun",
None
};
about_documenters = {"Valadoc",
None
};
about_artists = {"Daniel P. Fore",
None
};
about_authors = {"Maxwell Barvian <mbarvian@gmail.com>",
"Daniel Fore <bunny@go-docky.com>",
"Avi Romanoff <aviromanoff@gmail.com>",
None
};
about_comments = "A demo of the Granite toolkit";
about_translators = "Launchpad Translators";
about_license_type = Gtk.License.GPL_3_0;
def do_activate(self):
win = Gtk.Window(application = self )
notebook = Gtk.Notebook()
#/* welcome */
#// These strings will be automatically corrected by the widget
win.add(notebook)
welcome = Granite.WidgetsWelcome()
welcome = welcome.new("Granite's Welcome Screen", "This is Granite's Welcome widget.")
notebook.append_page(welcome, Gtk.Label("Welcome"))
pixbuf = Gtk.IconTheme.get_default().load_icon("document-new",48, Gtk.IconLookupFlags.GENERIC_FALLBACK)
image = Gtk.Image.new_from_icon_name("document-open", Gtk.IconSize.DIALOG)
#Adding elements. Use the most convenient function to add an icon
welcome.append_with_pixbuf(pixbuf,"create", "Write a new document")
welcome.append_with_image(image, "open","select a file")
welcome.append("help-info", "Discover", "learn more about this app")
#modebutton
mode_button = Granite.WidgetsModeButton()
mode_button.valing = Gtk.Align.CENTER
mode_button.haling = Gtk.Align.CENTER
mode_button.append(Gtk.Label("Hardware"))
mode_button.append(Gtk.Label("Input"))
mode_button.append(Gtk.Label("Output"))
mode_button.append(Gtk.Label("Output"))
mode_button.append(Gtk.Label("Quite long"))
mode_button.append(Gtk.Label("Very Very long \n with line break"))
vbox = Gtk.Grid()
toolbar = Gtk.Toolbar()
toolbar.get_style_context().add_class("primary-toolbar")
toolbutton = Gtk.ToolItem()
tool_mode = Granite.WidgetsModeButton()
tool_mode.append_icon("view-list-column-symbolic", Gtk.IconSize.MENU)
tool_mode.append_icon("view-list-details-symbolic", Gtk.IconSize.MENU)
tool_mode.append_icon("view-list-icons-symbolic", Gtk.IconSize.MENU)
tool_mode.append_icon("view-list-video-symbolic", Gtk.IconSize.MENU)
toolbutton.add(tool_mode)
toolbar.insert(toolbutton,-1)
#Granite.Application.create_appmenu missing
menu = Gtk.Menu()
app_menu = Granite.WidgetsAppMenu.new_with_app(self,menu)
toolbar.insert(app_menu,-1)
vbox.attach(toolbar,0, 0, 1,1)
vbox.attach(mode_button,0,2,1,1)
notebook.append_page(vbox, Gtk.Label("ModeButton"))
win.resize(800,600)
win.show_all()
app= DemoApp()
app.run("",1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.