Слияние кода завершено, страница обновится автоматически
from tkinter import *
import random
# Определение функции, которая генерирует 6-значный случайный код авторизации, содержащий заглавные и строчные буквы, а также цифры
def createAuthCode():
res1 = ""
res2 = ""
res3 = ""
for i in range(2):
num = random.randint(0, 9)
res1 += str(num)
num = random.randint(65, 90)
res2 += str(chr(num))
num = random.randint(97, 122)
res3 += str(chr(num))
string = str(res1 + res2 + res3)
txt.set(string)
# Создание главного окна
root = Tk()
root.title("Вход")
#root.resizable(False, False)
root.geometry("300x200")
# Установка поля ввода для имени пользователя
ID = Label(root, text="Имя пользователя:")
ID.place(relx=0.2, rely=0.2, anchor=CENTER)
text1 = Entry(root)
text1.place(relx=0.5, rely=0.2, anchor=CENTER, width=150, height=25)
# Установка поля ввода для пароля
password = Label(root, text="Пароль:")
password.place(relx=0.2, rely=0.4, anchor=CENTER)
text2 = Entry(root)
text2.place(relx=0.5, rely=0.4, anchor=CENTER, width=150, height=25)
# Установка поля ввода для кода авторизации
code = Label(root, text="Код авторизации:")
code.place(relx=0.22, rely=0.6, anchor=CENTER)
code = Entry(root)
code.place(relx=0.4, rely=0.6, anchor=CENTER, width=70, height=25)
# Установка кнопки для получения кода авторизации
txt = StringVar()
txt.set("Получить код авторизации")
codestr = Button(root, textvariable=txt, command=createAuthCode, fg="red", bg="blue")
codestr.place(relx=0.8, rely=0.6, anchor=CENTER)
# Установка кнопки для входа
enter = Button(root, text="Войти")
enter.place(relx=0.5, rely=0.8, anchor=CENTER)
root.mainloop()