Python Forum

Full Version: how is the new row selected automatically in treeview
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
firstly, I would like to apologize for my bad English.

I'm new to Python.

how is the new row selected automatically in this code?

def add_students():
    con = sqlite3.connect("data.db")
    cur = con.cursor()
    cur.execute("INSERT INTO students VALUES (NULL, ?, ?)", (name_var.get(), class_var.get()))
    con.commit()
    cur.execute("select * from students ORDER BY class ASC ,name ASC")
    rows = cur.fetchall()
    if len(rows) != 0:

        my_treeview.delete(*my_treeview.get_children())
        for row in rows:

            my_treeview.insert('', END, values = row)
        con.commit()
    con.close()
why did you edit out line 9? for row in rows:
that is the code which got the next row, not automatically, but by value of row.

You're changing code while a response is in the works, makes it very difficult
explain me more , please