Python Forum
how is the new row selected automatically in treeview
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how is the new row selected automatically in treeview
#1
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()
Reply
#2
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
Reply
#3
explain me more , please
Reply
#4
Read this: https://docs.python.org/3/library/tkinter.ttk.html (section on treeview)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020