Created
April 13, 2014 15:43
-
-
Save anatooly/10589275 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
# -*- coding: utf-8 -*- | |
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) | |
# Button click | |
def button_click_event(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() | |
# Main window | |
window = Gtk.Window.new(Gtk.WindowType.TOPLEVEL) | |
window.set_title("Example window header") | |
window.set_position(Gtk.WindowPosition.CENTER) | |
window.set_default_size(400, 400) | |
box = Gtk.VBox() | |
toolbar = Gtk.Toolbar.new() | |
# Page switcher | |
pager = Granite.WidgetsStaticNotebook.new(0) | |
pager.connect('page-changed', page_changed) | |
page1 = Granite.WidgetsWelcome.new('Just example', 'Simple example for testing') | |
page2 = Gtk.Label("Page 2") | |
page3 = Granite.WidgetsDatePicker.new() | |
pager.append_page(page1, Gtk.Label("Welcome")) | |
pager.append_page(page2, Gtk.Label("pg2")) | |
pager.append_page(page3, Gtk.Label("Date/Time")) | |
# Button on bottom page | |
button = Gtk.Button("Button click event") | |
button.connect('clicked', button_click_event) | |
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) | |
search_bar = Granite.WidgetsSearchBar.new("Hint search") | |
toolbar.insert(appmenu, -1) | |
toolbar.insert(search_bar, 0) | |
window.add(box) | |
window.connect("delete-event", Gtk.main_quit) | |
window.show_all() | |
Gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment