您的位置:首页 > 移动开发 > Objective-C

PyGobject(十八)布局容器之ActionBar

2016-07-26 16:21 489 查看
GtkActionBar
继承关系

Methods

Virtual Methods

Properties

Signals

例子

Gtk.ActionBar

继承关系

Gtk.ActionBar被设计为呈现上下文动作。

通常水平放置在主要内容的下方

Gtk.ActionBar是Gtk.Bin的直接子类



Methods

方法修饰词方法名及参数
staticnew ()
get_center_widget ()
pack_end (child)
pack_start (child)
set_center_widget (center_widget)

Virtual Methods

Properties

NameTypeFlagsShort Description

Signals

NameShort Description

例子



代码:

#!/usr/bin/env python3
# Created by xiaosanyu at 16/7/7
# section 019
TITLE = "ActionBar"
DESCRIPTION = """
Gtk.ActionBar is designed to present contextual actions.
It is expected to be displayed below the content and expand horizontally to fill the area
"""
import gi

gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

icons = ["edit-cut", "edit-paste", "edit-copy"]

class ActionBarWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="ActionBar Example")
self.set_size_request(250, 200)
box = Gtk.VBox()
ab = Gtk.ActionBar()
theme = Gtk.IconTheme.get_default()
for i, icon in enumerate(icons):
if theme.has_icon(icon):
image = Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.MENU)
button = Gtk.Button()
button.add(image)
if i == 0:
ab.pack_start(button)
elif i == 1:
ab.set_center_widget(button)
elif i == 2:
ab.pack_end(button)
box.pack_end(ab, False, False, 0)
box.pack_start(Gtk.TextView(), True, True, 0)
self.add(box)

def main():
win = ActionBarWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()

if __name__ == "__main__":
main()


分析主要代码

创建Gtk.ActionBar

ab = Gtk.ActionBar()


创建三个图片按钮,第一个放在最左边,第二个放在中间,第三个放在最末尾

icons = ["edit-cut", "edit-paste", "edit-copy"]
theme = Gtk.IconTheme.get_default()
for i, icon in enumerate(icons):
if theme.has_icon(icon):
image = Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.MENU)
button = Gtk.Button()
button.add(image)
if i == 0:
ab.pack_start(button)
elif i == 1:
ab.set_center_widget(button)
elif i == 2:
ab.pack_end(button)


代码下载地址:http://download.csdn.net/detail/a87b01c14/9594728
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息