固定容器 Fixed Container
固定容器(The Fixed container)允许将构件放在窗口的固定位置,这个位置是相对于固定容器的左上角的。构件的位置可以动态改变。
只有少数几个与固定容器构件相关的函数:
GtkWidget* gtk_fixed_new( void );
void gtk_fixed_put( GtkFixed *fixed,
GtkWidget *widget,
gint x,
gint y );
void gtk_fixed_move( GtkFixed *fixed,
GtkWidget *widget,
gint x,
gint y );
gtk_fixed_new() 函数用于创建新的固定容器。
gtk_fixed_put() 函数将widget放在fixed的由x和y指定的位置。
gtk_fixed_move() 函数将指定构件移动到新位置。
#!/usr/bin/env python
# example fixed.py
import pygtk
pygtk.require('2.0')
import gtk
class FixedExample:
# This callback method moves the button to a new position
# in the Fixed container.
def move_button(self, widget):
self.x = (self.x+30)%300
self.y = (self.y+50)%300
self.fixed.move(widget, self.x, self.y)
def __init__(self):
self.x = 50
self.y = 50
# Create a new window
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title("Fixed Container")
# Here we connect the "destroy" event to a signal handler
window.connect("destroy", lambda w: gtk.main_quit())
# Sets the border width of the window.
window.set_border_width(10)
# Create a Fixed Container
self.fixed = gtk.Fixed()
window.add(self.fixed)
self.fixed.show()
for i in range(1, 4):
# Creates a new button with the label "Press me"
button = gtk.Button("Press me")
# When the button receives the "clicked" signal, it will call the
# method move_button().
button.connect("clicked", self.move_button)
# This packs the button into the fixed containers window.
self.fixed.put(button, i*50, i*50)
# The final step is to display this newly created widget.
button.show()
# Display the window
window.show()
def main():
# Enter the event loop
gtk.main()
return 0
if __name__ == "__main__":
FixedExample()
main()
![点击查看原始大小图片](http://dl2.iteye.com/upload/attachment/0055/7521/73415127-d84c-3743-b78f-1283b5af63bc-thumb.png)
- 大小: 16.1 KB
分享到:
相关推荐
pygtk-all-in-one-2.24.0.win32-py2.7.part2
pygtk-all-in-one-2.24.0.win32-py2.7.part1.rar
标题中的"pygtk-all-in-one-2.24.1.win32-py2.7.rar"表明这是一个针对Python 2.7版本的PyGTK库的集成包,版本号为2.24.1,且是Windows 32位系统的版本。PyGTK是一个用于创建图形用户界面(GUI)的Python绑定库,它...
带pyobject,cario\gtk+底层库,三合一
pygtk-2.17.0 参考手册英文版,由快乐叶子(http://www.yeezi.org)根据官方文档整理
在"pygtk-examples.tar.gz"这个压缩包中,包含了一系列的PyGTK编程示例,这些例子是学习PyGTK和Python GUI编程的宝贵资源。通过这些实例,你可以了解如何利用PyGTK的各种组件和功能来构建交互式的应用程序。 1. **...
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
文件放服务器下载,请务必到电脑端资源预览或者资源详情查看然后下载
python whl离线安装包 pip安装失败可以尝试使用whl离线安装包安装 第一步 下载whl文件,注意需要与python版本配套 python版本号、32位64位、arm或amd64均有区别 第二步 使用pip install XXXXX.whl 命令安装,如果whl...
官方离线安装包,亲测可用
pygtk-2.15.2 最新 PyGTK lets you to easily create programs with a graphical user interface using the Python programming language. The underlying GTK+ library provides all kind of visual elements and ...
文件放服务器下载,请务必到电脑端资源预览或者资源详情查看然后下载
python whl离线安装包 pip安装失败可以尝试使用whl离线安装包安装 第一步 下载whl文件,注意需要与python版本配套 python版本号、32位64位、arm或amd64均有区别 第二步 使用pip install XXXXX.whl 命令安装,如果whl...
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
pygtk-webui 介绍 这是一个检查 Gtk 和 webkit 之间交互的示例。 webkit 端显示一个带有 d3.js 生成的随机值的条形图,Gtk 部分显示一个带有这些值的树视图。 功能 本例提供的功能如下: 随机数据按钮:当点击随机...
然后,可以下载sane-pyGTK的源码包(如`sane-pygtk-0.1.1`),解压后按照README文件的指示进行编译和安装。安装完成后,通过命令行或者桌面快捷方式启动应用,开始使用扫描功能。 **社区参与与持续发展** 作为开源...
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
1、文件内容:pygtk2-doc-2.24.0-9.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/pygtk2-doc-2.24.0-9.el7.tar.gz #Step2、进入解压后的目录,执行安装 ...
1、文件内容:pygtk2-devel-2.24.0-9.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/pygtk2-devel-2.24.0-9.el7.tar.gz #Step2、进入解压后的目录,执行...
1、文件内容:pygtk2-codegen-2.24.0-9.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/pygtk2-codegen-2.24.0-9.el7.tar.gz #Step2、进入解压后的目录,...