I have made a database and added some random details. I have pulled this data from the database and I need to output this in a Tkinter GUI window. When using the Label to output the contents I usually put text.
example = Label(self.frame, text='Example')
Is there something else I should use instead of a Label?
def create_records():
c.execute('CREATE TABLE IF NOT EXISTS MemberRecordsTable(surname TEXT,
firstname TEXT, membertype TEXT, datejoined TEXT)')
def readrecords(self):
c.execute('SELECT * FROM MemberRecordsTable')
for row in c.fetchall():
memberprint2 = Label(self.frame, text = row)
def memberprint(self):
self.clearframe()
readrecords()
You create one new label for each row. Use a Text widget if you want all of the data in one container http://effbot.org/tkinterbook/text.htm . Note that create_records() is missing a self, so is not part of the class like the other 2 functions,
text_w = Text(self.frame, height=20, width=10, wrap="none")
text_w.grid(row=0, column=0)
......
text_w.insert(END, any_string)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.