Почему .get дает мне PY_VAR0 вместо строки - PullRequest
0 голосов
/ 19 сентября 2019

Класс Two_players():

def __init__(self):
    self.player1=StringVar()
    self.player2=StringVar()
    self.window1=Tk()
    self.window1.title("Spieler Eingabe")
    self.window1.geometry("500x600")
    self.label_01=Label(self.window1, text="Spieler eingabe",width=25, relief="solid", font=("arial",12,"bold")).pack()
    self.entry_1 = Entry(self.window1,text=self.player1).place(x=170, y=153)
    self.label_03=Label(self.window1, text="Spieler 1 : ", font=("arial",12,"bold")).place(x=80,y=150)
    self.label_04=Label(self.window1, text="Spieler 2 : ", font=("arial",12,"bold")).place(x=80,y=180)
    self.entry_2 = Entry(self.window1,text=self.player2).place(x=170, y=183)
    self.but_01=Button(self.window1,text="wörter eingeben",width=15,bg="black",fg="green", command= lambda :  self.two_players_words()).place(x=200,y=500)

Проблема в label_21 - я хочу, чтобы вывод был entry_1, но он показывает только py_var0.

Я ужепопробовал с .get, но это тоже не помогло:

def two_players_words(self):

    window1=Tk()
    window1.title("Wörter Eingabe")
    window1.geometry("500x600")
    label_20=Label(window1, text="Wörter eingabe",width=25, relief="solid", font=("arial",12,"bold")).pack()
    label_21=Label(window1,text=self.player1, font=("arial",12,"bold")).place(x=80,y=150)
    entry_15 = Entry(window1,textvar=word1).place(x=170, y=153)
    label_22=Label(window1, text="{player2} : ", font=("arial",12,"bold")).place(x=80,y=180)
    entry_16 = Entry(window1,textvar=word2).place(x=170, y=183)

1 Ответ

0 голосов
/ 19 сентября 2019

Используйте параметр textvariable вместо текста

label_21=Label(window1,textvariable=self.player1, font=("arial",12,"bold")).place(x=80,y=150)
...