PyGobject(八十三)Gtk.SizeGroup
来源:互联网 发布:陈百祥多隆 知乎 编辑:程序博客网 时间:2024/06/16 16:41
- GtkSizeGroup
- Methods
- Virtual Methods
- Properties
- Signals
- 例子
Gtk.SizeGroup
将一组小部件组织到一起,使它们拥有相同的高度或者宽度,由set_mode(Gtk.SizeGroupMode)来设置
Methods
Virtual Methods
Properties
Signals
例子
代码:
#!/usr/bin/env python3# Created by xiaosanyu at 16/7/21# section 131# # author: xiaosanyu# website: yuxiaosan.tk \# http://blog.csdn.net/a87b01c14# created: 16/7/21TITLE = "SizeGroup"DESCRIPTION = """GtkSizeGroup provides a mechanism for grouping a number ofwidgets together so they all request the same amount of space.This is typically useful when you want a column of widgets tohave the same size, but you can't use a GtkTable widget.Note that size groups only affect the amount of space requested,not the size that the widgets finally receive. If you want thewidgets in a GtkSizeGroup to actually be the same size, you needto pack them in such a way that they get the size they requestand not more. For example, if you are packing your widgetsinto a table, you would not include the GTK_FILL flag."""import gigi.require_version("Gtk", "3.0")from gi.repository import Gtk, Gdk, GdkPixbuf, GLibcolor_options = ["Red", "Green", "Blue"]dash_options = ["Solid", "Dashed", "Dotted"]end_options = ["Square", "Round", "Double Arrow"]class SizeGroupWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="SizeGroup demo") self.set_resizable(False) vbox = Gtk.VBox(spacing=5) self.add(vbox) vbox.set_border_width(5) size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL) # Create one frame holding color options frame = Gtk.Frame.new("Color Options") vbox.pack_start(frame, True, True, 0) grid = Gtk.Grid() grid.set_border_width(5) grid.set_row_spacing(5) grid.set_column_spacing(10) frame.add(grid) self.add_row(grid, 0, size_group, "_Foreground", color_options) self.add_row(grid, 1, size_group, "_Background", color_options) # And another frame holding line style options frame = Gtk.Frame.new("Line Options") vbox.pack_start(frame, False, False, 0) grid = Gtk.Grid() grid.set_border_width(5) grid.set_row_spacing(5) grid.set_column_spacing(10) frame.add(grid) self.add_row(grid, 0, size_group, "_Dashing", dash_options) self.add_row(grid, 1, size_group, "_Line ends", end_options) # And a check button to turn grouping on and off check_button = Gtk.CheckButton.new_with_mnemonic("_Enable grouping") vbox.pack_start(check_button, False, False, 0) check_button.set_active(True) check_button.connect("toggled", self.toggle_grouping, size_group) @staticmethod def create_combo_box(strings): combo_box = Gtk.ComboBoxText() for s in strings: combo_box.append_text(s) combo_box.set_active(0) return combo_box def add_row(self, grid, row, size_group, label_text, options): label = Gtk.Label.new_with_mnemonic(label_text) label.set_halign(Gtk.Align.START) label.set_valign(Gtk.Align.BASELINE) label.set_hexpand(True) grid.attach(label, 0, row, 1, 1) combo_box = self.create_combo_box(options) label.set_mnemonic_widget(combo_box) combo_box.set_halign(Gtk.Align.END) combo_box.set_valign(Gtk.Align.BASELINE) size_group.add_widget(combo_box) grid.attach(combo_box, 1, row, 1, 1) @staticmethod def toggle_grouping(check_button, size_group): # GTK_SIZE_GROUP_NONE is not generally useful, but is useful # here to show the effect of GTK_SIZE_GROUP_HORIZONTAL by # contrast. if check_button.get_active(): new_mode = Gtk.SizeGroupMode.HORIZONTAL else: new_mode = Gtk.SizeGroupMode.NONE size_group.set_mode(new_mode)def main(): win = SizeGroupWindow() win.connect("delete-event", Gtk.main_quit) win.show_all() Gtk.main()if __name__ == "__main__": main()
代码下载地址:http://download.csdn.net/detail/a87b01c14/9594728
0 0
- PyGobject(八十三)Gtk.SizeGroup
- PyGobject(六十一)Gtk.Widget
- PyGobject(八十)Gtk.Clipboard
- PyGobject(八十六)Gtk.Application
- PyGobject(八十七)Gtk.PrintOperation
- PyGobject(七十八)Gtk.Builder篇
- PyGobject(六十二)Gtk.Widget之Gtk.Label
- PyGobject(六十三)Gtk.Widget之Gtk.AccelLabel
- PyGobject(六十四)Gtk.Widget之Gtk.Arrow
- PyGobject(六十五)Gtk.Widget之Gtk.Image
- PyGobject(六十六)Gtk.Widget之Gtk.Calendar
- PyGobject(六十七)Gtk.Widget之Gtk.CellView
- PyGobject(六十八)Gtk.Widget之Gtk.DrawingArea
- PyGobject(六十九)Gtk.Widget之Gtk.LevelBar
- PyGobject(七十)Gtk.Widget之Gtk.ProgressBar
- PyGobject(七十一)Gtk.Widget之Gtk.Entry
- PyGobject(七十二)Gtk.Widget之Gtk.SearchEntry
- PyGobject(七十三)Gtk.Widget之Gtk.SpinButton
- 对于项目中路径的认识
- 利用Multi-LBP和PCA、LDA进行人脸识别
- ora-12547问题的解决方案之一
- 数据结构实验之栈一:进制转换
- Cordova4.0后的自定义插件
- PyGobject(八十三)Gtk.SizeGroup
- 【翻译】Kinect v1和Kinect v2的彻底比较
- Aizu 0513 Paint Color【离散化+BFS】
- NYOJ499 迷宫 DFS
- 快速幂取模(当数很大时,相乘long long也会超出的解决办法)
- cmake编译opencv3.1+contribute模块,并提供编译后的dll、lib等文件下载
- HDU 1242 BFS-Rescue
- tabLeview的静态分组使用
- 封锁机制以及读锁和写锁的区别