PyGobject(四十八)布局容器之HeaderBar
来源:互联网 发布:淘宝贷款怎么联系客服 编辑:程序博客网 时间:2024/05/17 10:06
- GtkHeaderBar
- 继承关系
- Methods
- Virtual Methods
- Properties
- Signals
- 例子
Gtk.HeaderBar
Gtk.HeaderBar标题栏
继承关系
Gtk.HeaderBar是Gtk.Container的直接子类
Methods
Virtual Methods
Properties
Signals
例子
代码:
#!/usr/bin/env python3# Created by xiaosanyu at 16/6/13# section 065TITLE = "HeaderBar"DESCRIPTION = """Gtk.HeaderBar is similar to a horizontal Gtk.Box. It allows children to be placed at the start or the end.In addition, it allows a title and subtitle to be displayed."""import osimport gigi.require_version('Gtk', '3.0')from gi.repository import Gtk, Gio, GdkPixbufclass HeaderBarWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="HeaderBar Demo") self.set_border_width(10) self.set_default_size(400, 200) # set logo
icon = GdkPixbuf.Pixbuf.new_from_file(os.path.join(os.path.dirname(__file__), "../Data/gtk-logo-rgb.gif")) # transparent
icon = icon.add_alpha(True, 0xff, 0xff, 0xff) self.set_default_icon(icon) hb = Gtk.HeaderBar() hb.set_decoration_layout("icon,menu:minimize,maximize,close") hb.set_show_close_button(True) hb.props.title = "HeaderBar example" hb.set_subtitle("(subtitle)") self.set_titlebar(hb) button = Gtk.Button() icon = Gio.ThemedIcon(name="mail-send-receive-symbolic") image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON) button.add(image) hb.pack_end(button) box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class(box.get_style_context(), "linked") button = Gtk.Button() button.add(Gtk.Arrow(arrow_type=Gtk.ArrowType.LEFT, shadow_type=Gtk.ShadowType.NONE)) box.add(button) button = Gtk.Button() button.add(Gtk.Arrow(arrow_type=Gtk.ArrowType.RIGHT, shadow_type=Gtk.ShadowType.NONE)) box.add(button) hb.pack_start(box) self.add(Gtk.TextView())def main(): win = HeaderBarWindow() win.connect("delete-event", Gtk.main_quit) win.show_all() Gtk.main()if __name__ == "__main__": main()
代码解析
设置窗口默认图标
# set logo
icon = GdkPixbuf.Pixbuf.new_from_file(os.path.join(os.path.dirname(__file__), "../Data/gtk-logo-rgb.gif"))# transparent
icon = icon.add_alpha(True, 0xff, 0xff, 0xff)self.set_default_icon(icon)
hb = Gtk.HeaderBar()
创建Gtk.HeaderBar
hb.set_decoration_layout("icon,menu:minimize,maximize,close")
设置布局方式,名称中间用逗号分隔,冒号用来分隔左右两部分
最左边是图标(icon),中间是自定义的区域(menu),后面是最小化最大化和关闭按钮(minimize,maximize,close”),顺序可以任意调换
剩下一段代码主要讲解一下以下两句
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)Gtk.StyleContext.add_class(box.get_style_context(), "linked")
设置Box的样式为”linked”,这样,box中的子部件之间间距为0,而且子部件接触的地方没有圆角弧度之类的。
代码下载地址:http://download.csdn.net/detail/a87b01c14/9594728
0 0
- PyGobject(四十八)布局容器之HeaderBar
- PyGobject(十八)布局容器之ActionBar
- PyGobject(十九)布局容器之Alignment
- PyGobject(三十)布局容器之StackSidebar
- PyGobject(三十一)布局容器之EventBox
- PyGobject(三十二)布局容器之Window
- PyGobject(三十三)布局容器之ApplicationWindow
- PyGobject(三十四)布局容器之Assistant
- PyGobject(三十五)布局容器之ShortcutsWindow
- PyGobject(三十六)布局容器之OffscreenWindow
- PyGobject(三十七)布局容器之Dialog
- PyGobject(三十八)布局容器之ScrolledWindow
- PyGobject(三十九)布局容器之PlacesSidebar
- PyGobject(四十)布局容器之Viewport
- PyGobject(四十一)布局容器之Box
- PyGobject(四十二)布局容器之ButtonBox
- PyGobject(四十五)布局容器之Grid
- PyGobject(四十六)布局容器之Fixed
- leetcode 368. Largest Divisible Subset
- 简单算法学习笔记一
- Apache [error] server reached MaxClients setting, consider raising the MaxClients setting
- 电影<一个都不能少>观后感 ---记码神实训第四天
- Java同步锁问题
- PyGobject(四十八)布局容器之HeaderBar
- (NYoj 284)坦克大战--裸BFS ,优先队列
- 小飞鱼通达数码微信二维码
- iOS : 判断两个控件是否重合.(可用于判断某一个控件是否显示在window上)
- Mac系统终端命令行不执行命令 总出现command not found解决方法
- 抽象类与接口
- HDU 5763 Another Meaning
- 分布式基础通信协议:paxos,totem和gossip
- 开机启动遇到grub rescue 无法启动系统