资源简介
Python gui的不二选择——PyGobject
辛苦几个月的成果,供各位学习和参考
具体内容参见博文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
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 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个文件信息
相关资源
- Python数据分析与机器学习-贝叶斯实现
- matlab转python的教程
- Python37ForDelphi7.zip221420
- knn算法识别mnist图片-python3
- Python for Data Analysis(2nd )中文带书签
- python 截图 抓图 源码
- Python3实现多图拼接
- 量化交易之路用Python做股票量化分析
- 用Python写网络爬虫.pdf 高清带书签
- 基于OpenCV 的回转体零件表面缺陷检测
- Django-ERP-for-python3.6-django2.1.2
- 原生python ctp
- UHD+GNURadio安装工具 Python脚本以及安装
- Python 数据分析之金融欺诈行为检测
- Python 学习笔记 第二版.pdf
- python 2.7 pip安装
- TBCNN 源码
- 车牌号码识别python+opencv
- python for information
- Ubuntu18.04LTS下安装 Caffe-GPU版本及 Ana
- 精通Python设计模式.pdf 清晰中文完整版
- learn-python-the-hard-way中文版
- Python3官方手册中文版
- XGBoost with Python (book + complete code fo
- 基于Python的微信自动回复机器人
- 500 line or less最新版
- Python Odoo企业级开发实战
- python学生管理系统.zip
- 根据关键字爬虫谷歌、百度、必应图
- PCA 算法实验代码python
评论
共有 条评论