Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

gi.repository Granite with Python

View app.py
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
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
#
# app.py
#
# Copyright 2012 Vladimir Kolev <vladi@elementos>
#
# This is a semple application using the Granite widgets
# from the ElementaryOS project
#
# The problem is how to make it more Object-orientated and
# wrapt the Application class as main class for the application
#
 
import sys
from gi.repository import Gtk, Gdk, GdkPixbuf
from gi.repository import Granite
 
def show_about(sender = None):
about = Granite.WidgetsAboutDialog.new()
about.set_program_name("gSharkDown")
about.set_comments("""A simple application for downloading\n
and listening to music from grooveshark.com""")
about.set_logo(GdkPixbuf.Pixbuf.new_from_file_at_size("gsharkdown_64.png", 64, 64))
about.set_website("http://gsharkdown.bultux.org")
about.set_website_label("http://gsharkdown.bultux.org")
about.set_version("1.0")
about.run()
about.destroy()
def page_changed(sender, info):
sender.set_page(info)
def show_window(sender):
light = Granite.WidgetsLightWindow.new("Example Window")
lightlabel = Granite.WidgetsWrapLabel.new("Just an example label for the window")
light.add(lightlabel)
light.set_default_size(300, 300)
light.set_position(Gtk.WindowPosition.CENTER)
light.show_all()
 
window = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
window.set_position(Gtk.WindowPosition.CENTER)
window.set_default_size(300, 400)
box = Gtk.VBox()
toolbar = Gtk.Toolbar.new()
pager = Granite.WidgetsStaticNotebook.new(0)
pager.connect('page-changed', page_changed)
welcome = Granite.WidgetsWelcome.new('Just example', 'Simple example for testing')
pager.append_page(welcome, Gtk.Label("Welcome"))
pager.append_page(Gtk.Label("Page 2"), Gtk.Label("pg2"))
date_picker = Granite.WidgetsDatePicker.new()
pager.append_page(date_picker, Gtk.Label("Date/Time"))
 
button = Gtk.Button("Test Window")
button.connect('clicked', show_window)
box.pack_start(toolbar, False, True, 0)
box.pack_start(pager, True, True, 0)
box.pack_end(button, False, False, 3)
 
menu = Gtk.Menu.new()
about_item = Gtk.MenuItem.new_with_label("About Dialog")
about_item.connect('activate', show_about)
menu_item = Gtk.MenuItem.new_with_label("Quit")
menu_item.connect('activate', Gtk.main_quit)
menu.append(about_item)
menu.append(menu_item)
 
appmenu = Granite.WidgetsAppMenu.new(menu)
toolbar.insert(appmenu, -1)
window.add(box)
window.connect("delete-event", Gtk.main_quit)
window.show_all()
Gtk.main()
 

gracias

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.