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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
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() |