資源簡(jiǎn)介
Python gui的不二選擇——PyGobject
辛苦幾個(gè)月的成果,供各位學(xué)習(xí)和參考
具體內(nèi)容參見博文http://blog.csdn.net/a87b01c14/article/category/6329777

代碼片段和文件信息
#!/usr/bin/env?python3
#?-*-?Mode:?Python;?py-indent-offset:?4?-*-
#?vim:?tabstop=4?shiftwidth=4?expandtab
#
#?Copyright?(C)?2010?Red?Hat?Inc.?John?(J5)?Palmieri?
#
#?This?library?is?free?software;?you?can?redistribute?it?and/or
#?modify?it?under?the?terms?of?the?GNU?Lesser?General?Public
#?License?as?published?by?the?Free?Software?Foundation;?either
#?version?2.1?of?the?License?or?(at?your?option)?any?later?version.
#
#?This?library?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
#?Lesser?General?Public?License?for?more?details.
#
#?You?should?have?received?a?copy?of?the?GNU?Lesser?General?Public
#?License?along?with?this?library;?if?not?write?to?the?Free?Software
#?Foundation?Inc.?51?Franklin?St?Fifth?Floor?Boston?MA??02110-1301
#?USA
import?codecs
import?os
import?sys
import?textwrap
import?glob
import?gi
gi.require_version(‘Pango‘?‘1.0‘)
gi.require_version(‘GdkPixbuf‘?‘2.0‘)
gi.require_version(‘Gtk‘?‘3.0‘)
from?gi.repository?import?GLib?Gobject?Pango?GdkPixbuf?Gtk?Gio
try:
????gi.require_version(‘GtkSource‘?‘3.0‘)
????from?gi.repository?import?GtkSource??#?PyFlakes
except?Exception:
????print(“error“)
????GtkSource?=?None
DEMOROOTDIR?=?os.path.abspath(os.path.dirname(__file__))
DEMOCODEDIR?=?os.path.join(DEMOROOTDIR?‘demos‘)
sys.path.insert(0?DEMOROOTDIR)
class?Demo(Gobject.Gobject):
????__gtype_name__?=?‘GtkDemo‘
????def?__init__(self?title?module?filename):
????????super(Demo?self).__init__()
????????self.title?=?title
????????self.module?=?module
????????self.filename?=?filename
????@classmethod
????def?new_from_file(cls?path):
????????relpath?=?os.path.relpath(path?DEMOROOTDIR)
????????packagename?=?os.path.dirname(relpath).replace(os.sep?‘.‘)
????????modulename?=?os.path.splitext(os.path.basename(relpath))[0]
????????try:
????????????package?=?__import__(packagename?globals()?locals()?[modulename]?0)
????????????module?=?getattr(package?modulename)
????????????return?cls(module.title?module?path)
????????except?AttributeError?as?e:
????????????raise?AttributeError(‘(%s):?%s‘?%?(path?e))
class?DemoTreeStore(Gtk.TreeStore):
????__gtype_name__?=?‘GtkDemoTreeStore‘
????def?__init__(self?*args):
????????super(DemoTreeStore?self).__init__(str?Demo?Pango.style)
????????self._parent_nodes?=?{}
????????self._list_dir(DEMOCODEDIR)
????def?_list_dir(self?path):
????????for?filename?in?glob.glob(path?+?“/[!__]*“):
????????????if?os.path.isdir(filename):
????????????????self._list_dir(filename)
????????????elif?os.path.isfile(filename)?and?filename.endswith(“.py“):
????????????????parentname?=?os.path.dirname(os.path.relpath(filename?DEMOCODEDIR))
????????????????if?parentname:
????????????????????parent?=?self._get_parent_node(parentname)
????????????????else:
????????????????????parent?=?None
????????????????demo?=?Demo.new_from_file(filen
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-08-04?12:43??pygtk3\
?????文件???????????0??2016-07-11?08:28??pygtk3\__init__.py
?????目錄???????????0??2016-07-22?08:00??pygtk3\__pycache__\
?????目錄???????????0??2016-08-02?17:01??pygtk3\demos\
?????文件???????????0??2016-07-22?08:17??pygtk3\demos\__init__.py
?????目錄???????????0??2016-08-03?13:08??pygtk3\demos\__pycache__\
?????文件?????????150??2016-07-22?08:17??pygtk3\demos\__pycache__\__init__.cpython-34.pyc
?????文件????????2086??2016-07-23?16:38??pygtk3\demos\__pycache__\BlockSignal.cpython-34.pyc
?????文件????????1514??2016-08-03?13:08??pygtk3\demos\__pycache__\centerwindow.cpython-34.pyc
?????文件????????3822??2016-08-03?13:08??pygtk3\demos\__pycache__\Clipboard.cpython-34.pyc
?????文件????????4203??2016-08-03?13:08??pygtk3\demos\__pycache__\Cursor.cpython-34.pyc
?????文件????????6015??2016-08-03?13:08??pygtk3\demos\__pycache__\DragAndDrop.cpython-34.pyc
?????文件????????1735??2016-08-03?13:08??pygtk3\demos\__pycache__\Gob
?????文件????????1268??2016-07-25?19:52??pygtk3\demos\__pycache__\helloworld.cpython-34.pyc
?????文件????????4614??2016-08-03?13:08??pygtk3\demos\__pycache__\Pixbufs.cpython-34.pyc
?????文件????????1333??2016-07-25?19:52??pygtk3\demos\__pycache__\Properties.cpython-34.pyc
?????文件?????????598??2016-07-25?19:52??pygtk3\demos\__pycache__\simple_example.cpython-34.pyc
?????文件????????3740??2016-08-03?13:08??pygtk3\demos\__pycache__\SizeGroup.cpython-34.pyc
?????文件????????1074??2016-07-25?19:52??pygtk3\demos\__pycache__\VitualMethod.cpython-34.pyc
?????目錄???????????0??2016-08-02?19:58??pygtk3\demos\Application\
?????文件???????????0??2016-07-22?08:17??pygtk3\demos\Application\__init__.py
?????目錄???????????0??2016-08-03?13:08??pygtk3\demos\Application\__pycache__\
?????文件?????????162??2016-07-22?08:17??pygtk3\demos\Application\__pycache__\__init__.cpython-34.pyc
?????文件????????6104??2016-08-03?13:08??pygtk3\demos\Application\__pycache__\Application.cpython-34.pyc
?????文件???????10154??2016-08-03?13:08??pygtk3\demos\Application\__pycache__\appwindow.cpython-34.pyc
?????文件????????5920??2016-08-02?19:58??pygtk3\demos\Application\Application.py
?????文件???????12855??2016-08-02?19:58??pygtk3\demos\Application\appwindow.py
?????文件????????1569??2016-07-23?16:37??pygtk3\demos\BlockSignal.py
?????目錄???????????0??2016-08-03?13:05??pygtk3\demos\Builder\
?????文件?????????760??2016-07-08?15:33??pygtk3\demos\Builder\1.glade
?????文件?????????889??2016-08-03?13:05??pygtk3\demos\Builder\1.py
............此處省略480個(gè)文件信息
評(píng)論
共有 條評(píng)論