Package peggy :: Module gtkgui
[hide private]
[frames] | no frames]

Source Code for Module peggy.gtkgui

 1  #-*- coding: utf-8 -*- 
 2  ## 
 3  ## 
 4  ##    peggy - tools for working with PyGtk and setuptools 
 5  ##                    <http://www.florian-diesch.de/software/peggy/> 
 6  ##    Copyright (C) 2009  Florian Diesch <devel@florian-diesch.de> 
 7  ## 
 8  ##    This program is free software; you can redistribute it and/or modify 
 9  ##    it under the terms of the GNU General Public License as published by 
10  ##    the Free Software Foundation; either version 2 of the License, or 
11  ##    (at your option) any later version. 
12  ## 
13  ##    This program is distributed in the hope that it will be useful, 
14  ##    but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  ##    GNU General Public License for more details. 
17  ## 
18  ##    You should have received a copy of the GNU General Public License along 
19  ##    with this program; if not, write to the Free Software Foundation, Inc., 
20  ##    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
21  ## 
22  ## 
23   
24  import base 
25  import gtk 
26  import gtk.glade as glade 
27   
28 -class PeggyGtk(base.PeggyBase):
29 """ Peggy with support for Gtk""" 30
31 - def get_glade(self, name, *args, **kwargs):
32 """ 33 get ressource ``name`` as a ``gtk.glade.XML`` 34 instance 35 36 :Parameters: 37 name 38 ressource name of the .glade file 39 40 args, kwargs 41 additional arguments for ``glade.xml_new_from_buffer()`` 42 43 """ 44 xml = self.get_string(name) 45 return glade.xml_new_from_buffer(xml, len(xml), *args, **kwargs)
46
47 - def get_pixbuf(self, name):
48 """ 49 get ressource ``name`` as a ``gtk.gdk.pixbuf`` instance 50 51 :Parameters: 52 name 53 ressource name of the .glade file 54 55 """ 56 fname = self.get_filename(name) 57 return gtk.gdk.pixbuf_new_from_file(fname)
58
59 - def setup_locales(self, domain=None, dir=None, use_unicode=1):
60 """ 61 setup everything to use locales. 62 63 :Parameters: 64 domain 65 defaults to the ``package`` used with `__init__()` 66 67 dir 68 is used by `get_locale_dir()` 69 """ 70 71 super(PeggyGtk, self).setup_locales(domain, dir, use_unicode) 72 domain, dir = self._init_locale_variables(domain, dir) 73 74 gtk.glade.bindtextdomain(domain, dir) 75 gtk.glade.textdomain(domain)
76