Помогите сделать так, чтобы получилось вывести результат умножения. И если получится убрать чтобы не появлялось новое окно после нажатия кнопки multiplication буду очень признателен.
Python:
from tkinter import *
import random
from random import randint
from tkinter import messagebox
from time import *
from time import sleep
import bs4
from bs4 import BeautifulSoup
import requests
def get_data():
try:
res = requests.get('https://calend.online/holiday/').content
html=BeautifulSoup(res,"lxml")
return(random.choice(html.find_all(class_="holidays-list"))).text
except Exception as e:
return ("Error", e)
def holiday_button_press():
wind=Tk()
wind.geometry("570x320")
wind.config(bg="black")
tx=Text(wind,bg="black", fg="white")
tx.place(x=2,y=2)
tx.insert(1.0,get_data())
def get_anekdot():
try:
res=requests.get("https://www.anekdot.ru/random/anekdot/").content
html=BeautifulSoup(res,"lxml")
return(random.choice(html.find_all(class_="text"))).text
except Exception as e:
return ("Error",e)
def calc():
tor=Tk()
tor.geometry("700x450")
tor.config(bg="black")
hi_calc=Label(tor,text="Welcome to calculator",bg="black",fg="white",font=('Courier New', 24) )
hi_calc.place(x=150,y=30,width=400,height=50)
calc_b_1=Button(tor,text="multiplication", command=multi)
calc_b_1.place(x=150,y=300,width=200,height=50)
num_1=Entry(tor,bg="light grey", fg="red")
num_1.place(x=150,y=80,width=100,height=20)
text_1=Label(tor,text="1st:",bg="black", fg="white", font=('Courier New', 20) )
text_1.place(x=100,y=80,width=50,height=20)
num_2=Entry(tor,bg="light grey", fg="red")
num_2.place(x=450,y=80,width=100,height=20)
text_2=Label(tor,text="2nd:",bg="black", fg="white", font=('Courier New', 20) )
text_2.place(x=400,y=80,width=50,height=20)
tor.update()
return num_1,num_2
def multi():
num1,num2=calc()
st=num1.get()
nd=num2.get()
result_multi=st*nd
print(result_multi)
def anecdot_button_press():
root=Tk()
root.geometry("570x320")
root.config(bg="black")
txt = Text(root,bg="black", fg="white")
txt.place(x=2,y=2)
txt.insert(1.0,get_anekdot())
def answer():
result = client.get()
if result == password:
window.destroy()
main = Tk()
main.title("Симулятор компа")
main.geometry("700x450")
main.config(bg="black")
komp = Label(main,text="Desktop", bg="black",fg="white",font=('Courier New', 24))
komp.place(x=250,y=30,width=200,height=50)
matrix_button=Button(main,text="matrix",command=matrix)
matrix_button.place(x=150,y=300,width=200,height=50)
calc_button=Button(main,text="calculator",command=calc)
calc_button.place(x=150,y=200,width=200,height=50)
anekdot_button=Button(main,text="anecdot", command=anecdot_button_press)
anekdot_button.place(x=400,y=200,width=200,height=50)
holiday_button=Button(main,text="holidays", command=holiday_button_press)
holiday_button.place(x=400,y=300,width=200,height=50)
main.update()
else:
messagebox.showinfo('Неверно', "Неправильно введен пароль, попробуйте еще раз")
def matrix():
win=Tk()
win.geometry("450x300")
win.title('Hacking....')
win.attributes('-alpha', 0.85)
win.config(bg="black")
a='\n'.join([str_gen() for i in range(20)])
text = Label(win,text=a,bg='black',fg="green", font=('Courier New', 12))
text.place(x=0,y=0, width=450, height=300)
while True:
win.update()
a=a.split("\n")
a.append(str_gen())
a="\n".join(a[1:21])
text["text"]=a
def str_gen():
s=""
for i in range(65):
a=randint(0,2)
if a<2:s+=str(a)
else:s+=" "
return s
def clear():
client.delete(0, END)
window = Tk()
window.geometry("750x450")
window.title('Пароль')
window.config(bg='black')
password = "admin"
btn = Button(window, text = "Готово", command = answer)
btn.place(x=340, y=325, width=100, height=50)
txt = Label(text='Введите пароль:', bg='black', fg='white', font=('Courier New', 20)) # тут поле ввода и что в вашем коде
txt.place(x=300, y= 75, width=200, height=50)
client = Entry(bg='black', fg='white', font=('Courier New', 20))
client.place(x=300, y=200, width=200, height=50)
cbtn = Button(window, text="Стереть", command = clear)
cbtn.place(x=600, y=200, width=100, height=50)
window.mainloop()