und zwar stehe ich vor der Aufgabe, dass ich eine Liste, die nur in einem Entry entgegen genommen wird, mit selection sort in tkinter ausgeben möchte und zwar soll der User diverse Zahlen eingeben können und die Ausgabe soll dann eine geordnete Reihenfolge ergeben, soweit auch okay.
Allerdings bekomme ich es nicht hin, dass er output stattfindet, die Eingabe erfolgt, aber die Ausgabe erfolgt nicht. Ich weiß, dass ihr echt besseres vielleicht zu tun habt, aber ich würde dem schon gerne auf den Grund gehen...
da sind bestimmt viele Fehler drin, ich erwarte keine nieder geschriebene Lösung, sondern lediglich ein wenig Hilfe.
Ich wäre sehr dankbar drum:))
liebe Grüße
Code: Alles auswählen
import tkinter as tk
field = "slctn_srt"
class Surface:
def __init__(self):
self.root = tk.Tk() # creating window
self.root.title("Selection Sort")
self.root.geometry("400x200")
self.root.config(bg="red")
label1 = tk.Label(self.root, text="Bitte geben Sie mehrere Zahlen ein ")
label1.config(bg="skyblue", fg="green")
label1.pack() # add the label to the window
self.entry1 = tk.Entry(self.root, text="") # creating an entry
self.entry1.config(bg="#0f0")
self.entry1.pack() # add the entry to the window
self.label2 = tk.Label(self.root, text="") # creating a label
self.label2.pack() # add the label to the window
button1 = tk.Button(self.root, text="Hilfe", command=self.clicked_button_help) # creating a button
# command is the method that will calles by presed on the button
button1.pack() # add the button to the window
self.label2 = tk.Label(self.root, text="") # creating a label
self.label2.pack() # add the label to the window
clicked_button_slctn_sort = tk.Button(self.root, text="alle ausgeben", command=self.clicked_button_slctn_sort) # creating a button
# command is the method that will calles by presed on the button
clicked_button_slctn_sort.pack() # add the button to the window
self.root.mainloop() # need to "repaint" the window
def clicked_button_help(self):
print("Bitte geben Sie mehrere Zahlen \n"
"durcheinander ein und trennen Sie diese \n"
"mit einem Komma")
def clicked_button_slctn_sort(self):
select_sort =self.entry1[""].get()
for i in range(len(slctn_srt)):
select_sort = str(i)
min_index = i
for j in range(i + 1, len(slctn_srt)):
if slctn_srt[min_index] > slctn_srt[j]:
min_index = j
slctn_srt[i], slctn_srt[min_index] = slctn_srt[min_index], slctn_srt[i]
print(select_sort)
if __name__ == "__main__":
Surface()
#print ("Sorted array")
#print(A)