如何在 pygtk2 中更改 "style property"
How to change "style property" in pygtk2
GTK ComboBox 的样式为 属性 "arrow-size" (link)。我想将它设置为 0.
遗憾的是,下一个代码段不起作用。未报告错误消息,箭头显示为默认大小 (=15)
import pygtk
pygtk.require('2.0')
import gtk
def the_dialog():
dialog = gtk.Dialog("Title", None, gtk.DIALOG_MODAL)
liststore = gtk.ListStore(str)
for a in ["one","two","three"]:
liststore.append([a])
rc_str = """
style 'no_arrow_style' {
GtkComboBox::arrow-size = 0
}
widget_class '*' style 'no_arrow_style'
"""
gtk.rc_parse_string(rc_str)
combo_box = gtk.ComboBox()
cell = gtk.CellRendererText()
combo_box.pack_start(cell)
combo_box.add_attribute(cell, 'text', 0)
combo_box.set_model(liststore)
combo_box.get_cells()
dialog.vbox.pack_start(combo_box)
dialog.show_all()
dialog.run()
the_dialog()
带有默认 "v" 形箭头的组合框:
GtkComboBox::arrow-size
其实就是"minimum arrow size"。要查看差异,请将其设置为 100
。示例片段确实有效。
GTK ComboBox 的样式为 属性 "arrow-size" (link)。我想将它设置为 0.
遗憾的是,下一个代码段不起作用。未报告错误消息,箭头显示为默认大小 (=15)
import pygtk
pygtk.require('2.0')
import gtk
def the_dialog():
dialog = gtk.Dialog("Title", None, gtk.DIALOG_MODAL)
liststore = gtk.ListStore(str)
for a in ["one","two","three"]:
liststore.append([a])
rc_str = """
style 'no_arrow_style' {
GtkComboBox::arrow-size = 0
}
widget_class '*' style 'no_arrow_style'
"""
gtk.rc_parse_string(rc_str)
combo_box = gtk.ComboBox()
cell = gtk.CellRendererText()
combo_box.pack_start(cell)
combo_box.add_attribute(cell, 'text', 0)
combo_box.set_model(liststore)
combo_box.get_cells()
dialog.vbox.pack_start(combo_box)
dialog.show_all()
dialog.run()
the_dialog()
带有默认 "v" 形箭头的组合框:
GtkComboBox::arrow-size
其实就是"minimum arrow size"。要查看差异,请将其设置为 100
。示例片段确实有效。