`
deepfuture
  • 浏览: 4425483 次
  • 性别: Icon_minigender_1
  • 来自: 湛江
博客专栏
073ec2a9-85b7-3ebf-a3bb-c6361e6c6f64
SQLite源码剖析
浏览量:80283
1591c4b8-62f1-3d3e-9551-25c77465da96
WIN32汇编语言学习应用...
浏览量:70701
F5390db6-59dd-338f-ba18-4e93943ff06a
神奇的perl
浏览量:103894
Dac44363-8a80-3836-99aa-f7b7780fa6e2
lucene等搜索引擎解析...
浏览量:287166
Ec49a563-4109-3c69-9c83-8f6d068ba113
深入lucene3.5源码...
浏览量:15109
9b99bfc2-19c2-3346-9100-7f8879c731ce
VB.NET并行与分布式编...
浏览量:68193
B1db2af3-06b3-35bb-ac08-59ff2d1324b4
silverlight 5...
浏览量:32456
4a56b548-ab3d-35af-a984-e0781d142c23
算法下午茶系列
浏览量:46217
社区版块
存档分类
最新评论

pygtk-Fixed Container

 
阅读更多
固定容器 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()


  • 大小: 16.1 KB
0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics