Python, Tkinter, versucht, Zufallsnummern aus einer Liste der Benutzereingaben für die Nummer zu ziehen und im MEW -Fens
Posted: 01 Feb 2025, 07:40
Titel fasst es so ziemlich zusammen und fällt das Drehbuch unten auf. Jedes Mal, wenn es ausgeführt wird, wird der folgende Fehler erstellt < /p>
Code: Select all
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.496.0_x64__qbz5n2kfra8p0\Lib\tkinter\__init__.py", line 2068, in __call__
return self.func(*args)
~~~~~~~~~^^^^^^^
File "C:\Users\falso\Desktop\Development\Software\1.py", line 10, in generate_random_value
result_label.config(text=random_values)
^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'result_label' where it is not associated with a value
< /code>
Hier ist das aktuelle Skript < /p>
import tkinter as tk
import random
def generate_random_value():
try:
num_values = int(entry.get())
if num_values > 0 and num_values