tree_iter始终为无。 我试图更改代码,但仍然没有得到值。
def on_treeclients_cursor_changed(self, widget):
try:
(model, tree_iter) = variables.client_tree.get_selection().get_selected()
if tree_iter is not None:
dni = model.get_value(tree_iter, 0)
sec_name = model.get_value(tree_iter, 1)
name = model.get_value(tree_iter, 2)
date = model.get_value(tree_iter, 3)
client_id = client_functions.select_client(dni)
variables.dni_message[1].modify_fg(Gtk.StateFlags.NORMAL, Gdk.color_parse('blue'))
variables.dni_message[1].set_text(str(client_id[0]))
variables.client_row[0].set_text(dni)
variables.client_row[1].set_text(sec_name)
variables.client_row[2].set_text(name)
if date is not None:
variables.client_row[3].set_text(str(date))
else:
variables.client_row[3].set_text('-')
except Exception as e:
print('[ERROR]\tCannot select client\n', e) ```