#!/usr/bin/env python
# example images.py
import pygtk
pygtk.require('2.0')
import gtk
class ImagesExample:
# when invoked (via signal delete_event), terminates the application.
def close_application(self, widget, event, data=None):
gtk.main_quit()
return False
# is invoked when the button is clicked. It just prints a message.
def button_clicked(self, widget, data=None):
print "button %s clicked" % data
def __init__(self):
# create the main window, and attach delete_event signal to terminating
# the application
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("delete_event", self.close_application)
window.set_border_width(10)
window.show()
# a horizontal box to hold the buttons
hbox = gtk.HBox()
hbox.show()
window.add(hbox)
pixbufanim = gtk.gdk.PixbufAnimation("1.gif")
image = gtk.Image()
image.set_from_animation(pixbufanim)
image.show()
# a button to contain the image widget
button = gtk.Button()
button.add(image)
button.show()
hbox.pack_start(button)
button.connect("clicked", self.button_clicked, "1")
# create several images with data from files and load images int
# buttons
image = gtk.Image()
image.set_from_file("1.png")
image.show()
# a button to contain the image widget
button = gtk.Button()
button.add(image)
button.show()
hbox.pack_start(button)
button.connect("clicked", self.button_clicked, "2")
image = gtk.Image()
image.set_from_file("3.jpg")
image.show()
# a button to contain the image widget
button = gtk.Button()
button.add(image)
button.show()
hbox.pack_start(button)
button.connect("clicked", self.button_clicked, "3")
image = gtk.Image()
image.set_from_file("4.tif")
image.show()
# a button to contain the image widget
button = gtk.Button()
button.add(image)
button.show()
hbox.pack_start(button)
button.connect("clicked", self.button_clicked, "4")
image = gtk.Image()
image.set_from_file("5.gif")
image.show()
# a button to contain the image widget
button = gtk.Button()
button.add(image)
button.show()
hbox.pack_start(button)
button.connect("clicked", self.button_clicked, "5")
def main():
gtk.main()
return 0
if __name__ == "__main__":
ImagesExample()
main()


- 大小: 25.6 KB
分享到:
相关推荐
它是 usb-imagewriter 的一个分支。 我们还添加了格式化功能和 USB 设备内容备份。要求核心工具盘果波尔基特procps(或 procps-ng) pygtk2.0-libglade Python python-dbus Python分离磁盘终端执照本软件根据的条款...
阴囊( ) 受scrot启发Linux屏幕捕获和屏幕录制程序。 为什么? 因为在刷新窗口中使用选择时scrot会出现故障 特征 全屏截图 屏幕录像 部分(选择)屏幕截图 ... FILENAME image filename, default is %Y-%m-%d-%H
它最初是为图像处理软件GIMP(GNU Image Manipulation Program)开发的,但随着时间的发展,GTK已经成为一个功能强大的跨平台GUI工具包,支持Windows、macOS等操作系统。 GTK的核心设计理念是模块化和可扩展性。它...
GTK最初是为图像处理软件GIMP(GNU Image Manipulation Program)设计的,后来发展成为一种通用的GUI工具包。它遵循GNU General Public License(GPL),确保了代码的自由分享和改进。GTK的核心特性包括组件丰富、可...
GTK最初是为图像编辑软件GIMP(GNU Image Manipulation Program)设计的,但随着时间的发展,它已经成为一个功能强大的跨平台GUI构建框架。GTK使用C语言编写,并提供了多语言绑定,包括Python(PyGTK或GTK+ for ...
Python虽然不是专门用于图形用户界面(GUI)设计的语言,但它可以通过各种库和框架来实现这一目标,比如PyGTK、PyQt、wxPython或者Pyside等。 以PyQt为例,它是一个功能强大的Python GUI库,支持Qt框架的所有特性,...
Cicm,全称为"Collection Image Manager",是一款基于Python(PyGTK+)开发的轻量级图像管理工具。它为用户提供了便捷的方式来浏览、组织和管理个人的图像集合。由于是开源软件,用户可以根据自己的需求对软件进行...
GTK最初是为了支持图像处理软件GIMP(GNU Image Manipulation Program)而开发的,但现在它已经成为了一个功能强大的跨平台GUI框架。GTK使用C语言编写,同时也提供了多种语言的绑定,如Python(PyGTK)、Java(JGTK...
在Python3中,我们可以使用PyGTK或者PyGObject库来接入GTK+3.0的功能。 这个压缩包包含了一系列的示例代码,这些代码展示了如何使用Python3和GTK+3.0创建GUI界面的各种控件。虽然没有中文注释,但通过理解英文注释...