Vielen Dank, das funktioniert fürs erste in der gleichen Methode.
Habe jetzt nur noch ein zusätzliches Problem:
ich will den Text des Labels per Knopfdruck ändern. Habe die Variable als global deklariert und trotzdem kommt diese Fehlermeldung:
File "C:\Users\mpern\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1892, in __call__
return self.func(*args)
File "F:\Projekt Sattelstütze\Auswertung_Neu\Auswertung_Python\Auswertung_Neu.py", line 396, in <lambda>
tk.Button(momentum_calc_window, text="1", width=8, height=3, command=lambda m="1": which_button(m)).grid(row=2, column=1, padx='5', pady='5', sticky='ew')
File "F:\Projekt Sattelstütze\Auswertung_Neu\Auswertung_Python\Auswertung_Neu.py", line 437, in which_button
Ausgabe["Text"] = button_press
File "C:\Users\mpern\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1657, in __setitem__
self.configure({key: value})
File "C:\Users\mpern\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1646, in configure
return self._configure('configure', cnf, kw)
File "C:\Users\mpern\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1636, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: unknown option "-Text"
Hier der Programmteil:
Code: Alles auswählen
Button = tk.Button(momentum_calc_window, text="ENTER", width=8, height=3, command=lambda m="enter": which_button(m)).grid(row=1, column=0, padx='5', pady='5',
sticky='ew')
global Ausgabe
Ausgabe = tk.Label(momentum_calc_window, text="Berechnung", width=8, height=3)
Ausgabe.grid(row=1, column=2, padx='5', pady='5', sticky='ew')
Ausgabe['text'] = "42"
def which_button(button_press):
Ausgabe["Text"] = button_press
Es tut mir lübrigens leid, falls ich gerade bei grundlegenden Dingen scheitere.