Answer the question
In order to leave comments, you need to log in
Why is tkinter not updating screen text?
It is necessary that the text in the text window changes to the one that will be in the TextR variable, but this does not happen.
from random import choice
from tkinter import *
import keyword
root = Tk()
TextR = 'Вас приветсвует программа по созданию паролей созданный DanOK17 \nYou are welcomed by the password creation program created by DanOK17\n\nНапишите russian если хотите продолжить на русском \nWrite english if you want to continue in English\n'
TextY = 'Yes'
TextN = 'No'
txt = StringVar()
def click():
txt.get()
global TextR
print('1')
if txt == 'russian':
TextR='Введите длинну пароля'
title.config(text=TextR)
elif txt == 'english':
TextR='Enter password length'
title.config(text=TextR)
root['bg'] = '#fafafa'
root.title('PGen')
root.wm_attributes('-alpha', 0.9)
root.geometry('700x500')
frametxt = Frame(root, bg='grey')
frametxt.place(relheight=0.6, relwidth=1)
frame_btn = Frame(root, bg='grey', bd=5)
frame_btn.place(relheight=0.4, relwidth=1, rely=0.60)
title = Label(frametxt, text=TextR, bg='white', font=40)
title.pack(fill=BOTH, expand=True, side=TOP)
ent = Entry(frame_btn, bg='white', font=100, bd=2, textvariable=txt)
ent.pack(fill=BOTH, pady=2)
btn_ent = Button(frame_btn, text='Ввести', font=100, bd=2, height=5, command=click())
btn_ent.pack(side=RIGHT, pady=2,padx=2)
btnY = Button(frame_btn, text=TextY, font=100, bd=2, width=30, height=5)
btnY.pack(pady=2, side=LEFT)
btnN = Button(frame_btn, text=TextN, font=100, bd=2, width=30, height=5)
btnN.pack(pady=2, side=RIGHT)
if txt == 'russian':
TextR = 'Введите длинну пароля: '
root.mainloop()
Answer the question
In order to leave comments, you need to log in
Because you don't know what you're doing.
btn_ent = Button(frame_btn, text='Enter', font=100, bd=2, height=5, command= click() )
command=click
txt == 'something'incorrect, since StringVar() and str are different data types and they won't be equal. Use
txt.get() == 'whatever'. A lone call to txt.get() at the beginning of click() is useless because you're ignoring the return value of get() .
1) A function must be passed to the command argument, not the result of its execution
# Не так
btn_ent = Button(command=click())
# А так
btn_ent = Button(command=click)
# Не так
def click():
txt.get()
global TextR
print('1')
if txt == 'russian':
TextR='Введите длинну пароля'
title.config(text=TextR)
elif txt == 'english':
TextR='Enter password length'
title.config(text=TextR)
# А так
def click():
text = txt.get()
global TextR
if text == 'russian':
TextR='Введите длину пароля'
elif text == 'english':
TextR='Enter password length'
title.config(text=TextR)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question