Apr-04-2020, 09:12 PM
Hi, trying to learn python and have stuck with entry fields.
I am trying to create a button so the user can add an entry field and write the number in it.
So far I made some progress, but can't figure out how to declare InitVar() for every EntryField so I can summarize user's input.
Or am I doing it totally wrong...
I'll be grateful for any guidance
Heres the code:
I am trying to create a button so the user can add an entry field and write the number in it.
So far I made some progress, but can't figure out how to declare InitVar() for every EntryField so I can summarize user's input.
Or am I doing it totally wrong...
I'll be grateful for any guidance
Heres the code:
import tkinter as tk from tkinter import * root = tk.Tk() root.configure(bg = "#282930") class Stavka: all_entries = [1] user_ent = IntVar() def __init__(self, master): self.addboxButton = Button(master, text='Add +', bg="#282930", fg="white", command=self.addBox) self.addboxButton.grid(row=0, column=0, sticky="E") def addBox(self): nextcolumn = len(self.all_entries) # add entry in second row self.ent = Entry(root, textvariable=self.user_ent, width=80) self.ent.grid(row=nextcolumn, column=1) self.all_entries.append( ent ) pred_ent = IntVar() ent = Entry(root, textvariable=pred_ent, width=80) ent.grid(row=0, column=1) s = Stavka(root) root.mainloop()