PyGobject(二十三)布局容器之AspectFrame

来源:互联网 发布:淘宝宝贝用手机拍照 编辑:程序博客网 时间:2024/06/02 03:43

  • GtkAspectFrame
    • 继承关系
    • Methods
    • Virtual Methods
    • Properties
    • Signals
    • 例子

Gtk.AspectFrame

Gtk.AspectFrame是一个长宽比例不变的Frame

继承关系

Gtk.AspectFrame是Gtk.Frame的直接子类
这里写图片描述

Methods

方法修饰词 方法名及参数 static new (label, xalign, yalign, ratio, obey_child) set (xalign, yalign, ratio, obey_child)

Virtual Methods

Properties

Name Type Flags Short Description obey-child bool r/w/en 是否强制改变长款比例以匹配子部件的布局 ratio float r/w/en 长宽比例,如果obey_child 为False xalign float r/w/en 0.0左对齐,1.0右对齐 yalign float r/w/en 0.0上对齐,1.0下对齐

Signals

Name Short Description

例子

这里写图片描述
代码:

#!/usr/bin/env python3# Created by xiaosanyu at 16/7/7# section 026TITLE = "AspectFrame"DESCRIPTION = """The Gtk.AspectFrame is useful when you want pack a widget so that it can resizebut always retains the same aspect ratio. For instance,one might be drawing a small preview of a larger image"""import gigi.require_version("Gtk", "3.0")from gi.repository import Gtkclass AspectFrameWindow(Gtk.Window):    def __init__(self):        Gtk.Window.__init__(self, title="AspectFrame Example")        self.set_border_width(10)        grid = Gtk.Grid()        grid.set_column_spacing(20)        grid.set_row_spacing(20)        grid.set_column_homogeneous(True)        grid.set_row_homogeneous(True)        for i in range(3):            for j in range(3):                frame = Gtk.Frame.new("xalign=%s,yalign=%s,ratio=%s" % (i * 0.5, j * 0.5, j + 1))                frame.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)                child = Gtk.AspectFrame.new(label="", xalign=i * 0.5, yalign=j * 0.5,                                            ratio=j + 1,                                            obey_child=False)                frame.set_size_request(200, 200)                child.add(Gtk.Button("button"))                frame.add(child)                grid.attach(frame, j, i, 1, 1)        self.add(grid)def main():    win = AspectFrameWindow()    win.connect("delete-event", Gtk.main_quit)    win.show_all()    Gtk.main()if __name__ == "__main__":    main()

例子比较简单,不做详述
第一列,长宽比为1:1
第二列,长宽比为2:1
第三例,长宽比为3:1




代码下载地址:http://download.csdn.net/detail/a87b01c14/9594728

0 0
原创粉丝点击