I apologize if this question has been asked before but i have been trying to solve this problem by myself and with the help of my classmates. They seem to have no problem but i just cant get to the Value of an Entry. I always get strange strings like <function StringVar.get at 0x0358E970> or similar. I have spent full 5 hours now trying to solve this with the help of the internet too. I hope there is someone out there who can help me understand this.
So I have this class with a function in which i create a Tkinter window with one simple entry and one simple button. But when i try to get the value of the textvariable i dont get a string but some kind of code i cant work with at all. What am i doing wrong? Or is there something i am not doing?
import tkinter as tk from tkinter import ttk from tkinter import * class StrWnd: def __init__(self): self.firstname = StringVar def Register(self): self.register = Toplevel(self.scr) self.register.geometry("300x300") self.register.title("Register") Label(self.register, text="Vorname(Keine Nummern)").pack() ttk.Entry(self.register, textvariable=self.firstname).pack() ttk.Button(self.register, text="Submit", command=lambda: self.printValues()).pack() def printValues(self): print(self.firstname.get) Any tips are welcome.
.get(), not.get.print(self.firstname.get()) TypeError: get() missing 1 required positional argument: 'self'value = self._tk.globalgetvar(self._name) AttributeError: 'StrWnd' object has no attribute '_tk'StringVaralso has to beStringVar().self._root = master._root() AttributeError: 'NoneType' object has no attribute '_root'