PyGobject(十五)布局容器之Button篇——Gtk.ScaleButton
2016-07-26 15:33
591 查看
GtkScaleButton
继承关系
Methods
Virtual Methods
Properties
Signals
例子
代码:
分析主要代码
定义显示的图片名称列表,默认显示的放在第一个,最后显示的图片放第二个,其余依次排放
定义一个ScaleButton,指定其icons属性
绑定”value_changed”信号
代码下载地址:http://download.csdn.net/detail/a87b01c14/9594728
继承关系
Methods
Virtual Methods
Properties
Signals
例子
Gtk.ScaleButton
继承关系
Gtk.ScaleButton根据滑块位置,显示不同的图片。Gtk.ScaleButton是Gtk.Button的直接子类Methods
方法修饰词 | 方法名及参数 |
---|---|
static | new (size, min, max, step, icons) |
get_adjustment () | |
get_minus_button () | |
get_plus_button () | |
get_popup () | |
get_value () | |
set_adjustment (adjustment) | |
set_icons (icons) | |
set_value (value) |
Virtual Methods
do_value_changed (value) |
Properties
Name | Type | Flags | Short Description |
---|---|---|---|
adjustment | Gtk.Adjustment | r/w | ScaleButton值的范围 |
icons | [str] | r/w | List of icon names |
size | Gtk.IconSize | r/w/en | The icon size |
value | float | r/w/en | The value of the scale |
Signals
Name | Short Description |
---|---|
popdown | The ::popdown signal is a keybinding signal which gets emitted to popdown the scale widget. |
popup | The ::popup signal is a keybinding signal which gets emitted to popup the scale widget. |
value-changed | The ::value-changed signal is emitted when the value field has changed. |
例子
代码:
#!/usr/bin/env python3 # Created by xiaosanyu at 16/6/27 # section 016 TITLE = "ScaleButton" DESCRIPTION = """ Gtk.ScaleButton provides a button which pops up a scale widget. This kind of widget is commonly used for volume controls in multimedia applications, and GTK+ provides a Gtk.VolumeButton subclass that is tailored for this use case. """ import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk # 最高的图标要放在第二位 icons = ["microphone-sensitivity-muted-symbolic.symbolic", "microphone-sensitivity-high-symbolic.symbolic", "microphone-sensitivity-low-symbolic.symbolic", "microphone-sensitivity-medium-symbolic.symbolic"] class ScaleButtonWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="ScaleButton Demo") self.set_border_width(10) self.set_default_size(200, 300) box = Gtk.Box() sbtn = Gtk.ScaleButton(icons=icons) sbtn.connect("value_changed", self.change) box.add(sbtn) self.add(box) def change(self, btn, value): # print(value) pass def main(): win = ScaleButtonWindow() win.connect("delete-event", Gtk.main_quit) win.show_all() Gtk.main() if __name__ == "__main__": main()
分析主要代码
定义显示的图片名称列表,默认显示的放在第一个,最后显示的图片放第二个,其余依次排放
icons = ["microphone-sensitivity-muted-symbolic.symbolic", "microphone-sensitivity-high-symbolic.symbolic", "microphone-sensitivity-low-symbolic.symbolic", "microphone-sensitivity-medium-symbolic.symbolic"]
定义一个ScaleButton,指定其icons属性
sbtn = Gtk.ScaleButton(icons=icons)
绑定”value_changed”信号
sbtn.connect("value_changed", self.change)
代码下载地址:http://download.csdn.net/detail/a87b01c14/9594728
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python将excel导入到mysql中
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例
- Python 七步捉虫法