You cant call
Also note that insert parameters of a
All the code you posted is overwhelming and not necessary to show the problem you are having, strip out the the unnecessary parts like below.
https://python-forum.io/Thread-Namespace...th-imports
insert
on a StringVar
it does not have this method.Entry
widgets have an insert method maybe that what you are trying to do, you will need to keep a reference to the entry widget in the class to access it.Also note that insert parameters of a
Entry
are an index and a string you have used an index and a int.https://effbot.org/tkinterbook/entry.htm...ert-method Wrote:insert(index, string)
Inserts text at the given index. Use insert(INSERT, text) to insert text at the cursor, insert(END, text) to append text to the widget.
- index
Where to insert the text.
- string
The text to insert.
All the code you posted is overwhelming and not necessary to show the problem you are having, strip out the the unnecessary parts like below.
# imports from tkinter import * from tkinter import messagebox as ms # main Class class main: def __init__(self, master): # Window self.master = master # Some Usefull variables self.level1 = StringVar() # lets self.monitor() def monitor(self): self.disp1 = Frame(self.master, padx=10, pady=10) Label(self.disp1, text='Level 1: ', font=( '', 20), pady=5, padx=5).grid(sticky=W) Entry(self.disp1, textvariable=self.level1, bd=5, font=('', 15)).grid(row=0, column=1) Button(self.disp1, text=' Display Counts ', bd=3, bg="green", font=( '', 15), padx=5, pady=5, command=self.level).grid() # comand delet inm sqlite3 self.disp1.pack() def level(self): lv = int(4) self.level1.insert(0, 4) print("Hello World") root = Tk() root.title("Bearing Current Program") main(root) root.mainloop()When you get an error post the error traceback
Error:Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Dave\Anaconda3\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "c:/Users/Dave/Documents/VS Code WorkSpaces/Python Forum/general/forumpost.py", line 34, in level
self.level1.insert(0, 4)
AttributeError: 'StringVar' object has no attribute 'insert'
It is advisable not to use star importshttps://python-forum.io/Thread-Namespace...th-imports