本文整理汇总了Python中gtk.ListStore.connect方法的典型用法代码示例。如果您正苦于以下问题:Python ListStore.connect方法的具体用法?Python ListStore.connect怎么用?Python ListStore.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk.ListStore
的用法示例。
在下文中一共展示了ListStore.connect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_editable_type_defined_listview_and_model
# 需要导入模块: from gtk import ListStore [as 别名]
# 或者: from gtk.ListStore import connect [as 别名]
def create_editable_type_defined_listview_and_model(
field_list, new_row_func, parralell_list, change_register,
readonly=False,
insert_pre_hook=null_function, insert_post_hook=null_function,
change_pre_hook=null_function, change_post_hook=null_function,
del_pre_hook=null_function, del_post_hook=null_function):
vbox = VBox()
tv = TreeView()
model = ListStore( * chain((display_fieldtype_transform(fieldtype)
for fieldname, fieldtype in field_list),
(store_fieldtype_transform(fieldtype)
for fieldname, fieldtype in field_list)
) # chain
) # ListStore
# it is important to do this fill of the liststore
# with the existing items first prior to adding event handlers
# (row-changed, row-inserted, row-deleted) that
# look for changes and keep the two lists in sync
for list_row in parralell_list:
model.append(
tuple(transform_list_row_into_twice_repeated_row_for_model(
list_row, field_list) )
) # append
if not readonly:
model.connect("row-changed",
row_changed_handler,
parralell_list, change_register, field_list,
change_pre_hook, change_post_hook,
)
model.connect("row-inserted",
row_inserted_handler,
parralell_list, change_register,
insert_pre_hook, insert_post_hook )
model.connect("row-deleted",
row_deleted_handler, parralell_list, change_register,
del_pre_hook, del_post_hook)
for i, (fieldname, fieldtype) in enumerate(field_list):
def setup_edited_handler_for_renderer_to_original_model(cell_renderer):
cell_renderer.connect(
'edited',
cell_edited_update_original_modelhandler, model, i,
field_list[i][FIELD_TYPE])
return cell_renderer
if fieldtype == date:
cell_renderer = \
setup_edited_handler_for_renderer_to_original_model(
CellRendererDate() )
elif type(fieldtype) == tuple:
cell_renderer = CellRendererCombo()
cell_renderer.set_property("has-entry",
fieldtype[COMBO_TYPE_HAS_ENTRY_FIELD])
combo_liststore = ListStore(
str, store_fieldtype_transform(fieldtype) )
for combo_string, combo_value in \
combobox_list_strings_and_values_iteration(fieldtype):
combo_liststore.append( (combo_string, combo_value) )
cell_renderer.set_property("model", combo_liststore)
cell_renderer.set_property("text-column", 0)
if fieldtype[COMBO_TYPE_HAS_ENTRY_FIELD]:
setup_edited_handler_for_renderer_to_original_model(
cell_renderer)
else:
lookup_dict = dict(
combobox_list_strings_and_values_iteration(fieldtype) )
cell_renderer.connect(
'edited',
combo_cell_edited_update_original_modelhandler, model, i,
lookup_dict)
elif type(fieldtype) == dict and fieldtype['type'] == file:
cell_renderer = CellRendererFile(
fieldtype['file_type'] if 'file_type' in fieldtype
else FILE_CHOOSER_ACTION_OPEN
)
setup_edited_handler_for_renderer_to_original_model(cell_renderer)
else:
cell_renderer = \
setup_edited_handler_for_renderer_to_original_model(
CellRendererText() )
if not readonly:
cell_renderer.set_property("editable", True)
cell_renderer.set_property("editable-set", True)
tvc = TreeViewColumn(fieldname, cell_renderer, text=i)
tv.append_column(tvc)
vbox.pack_start(tv)
tv.set_model(model)
hbox = HBox()
buttons = [ pack_in_stock_but_and_ret(start_stock_button(code), hbox)
for code in (STOCK_ADD, STOCK_DELETE) ]
if readonly:
for button in buttons:
button.set_property("sensitive", False)
else:
buttons[0].connect(
"clicked",
editable_listview_add_button_clicked_handler,
model, new_row_func, field_list )
buttons[1].connect(
#.........这里部分代码省略.........