~luca91/pyjg/main

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
#!/usr/bin/env python
#
#       PyJg.py
#       
#       Copyright 2009 Luca Livraghi <luca.91@hotmail.it>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

import pygtk
pygtk.require("2.0")
import gtk
import urllib
import gtkmozembed
        
class Gui:
    
    def __init__(self):
        self.builder = gtk.Builder()
        self.builder.add_from_file("Gui.glade")
        self.builder.connect_signals(self)
        self.window = self.builder.get_object("window")
        self.scrolledwindow = self.builder.get_object("scrolledwindow")
        self.chord_entry = self.builder.get_object("chord_entry")
        self.moz = gtkmozembed.MozEmbed()
        self.scrolledwindow.add_with_viewport(self.moz)
        self.window.show_all()
        
    def on_chord_btn_clicked(self, widget):
        self.moz.load_url('http://jguitar.com/chordsearch?chordsearch=' \
                          + self.chord_entry.get_text())
        
    def on_about_btn_clicked(self, widget):
        self.builder.add_from_file("Gui.glade")
        self.aboutdialog = self.builder.get_object("aboutdialog")
        self.aboutdialog.run()
        self.aboutdialog.destroy()
    
    def on_stop_btn_clicked(self, widget):
        self.moz.stop_load()
    
    def gtk_widget_destroy(self, widget):
        gtk.widget.destroy()
    
    def gtk_main_quit(self, widget):
        gtk.main_quit()

if __name__ == "__main__":
    Gui()
    gtk.main()