Ответ:
import tkinter as tk
class Programm(tk.Tk):
def __init__(self):
super().__init__()
self.title("Сумма квадратов")
self.lbl = tk.Label(self, text="Введите m",font=("Times New Roman", 25))
self.lbl.pack()
self.inputer=tk.Entry(self, width=10, font=("Times New Roman", 25))
self.inputer.pack()
self.lbl1 = tk.Label(self, text="Введите n", font=("Times New Roman", 25))
self.lbl1.pack()
self.inputer1=tk.Entry(self, width=10, font=("Times New Roman", 25))
self.inputer1.pack()
self.btn=tk.Button(self, text="Подсчитать", command=self.clicked, font=("Times New Roman", 25))
self.btn.pack()
self.txt = tk.Label(self, text="Ответ:", font=("Times New Roman", 25))
self.txt.pack()
def clicked(self):
m=int(self.inputer.get())
n=int(self.inputer1.get())
res=0
for i in range(m,n+1):
res+=i**2
self.txt.destroy()
self.txt = tk.Label(self, text="Ответ: "+str(res), font=("Times New Roman", 25))
if __name__ == "__main__":
app=Programm()
app.mainloop()
github: https://gist.github.com/Pyatii/c869dfd498ab0e6a3cb4968053ddf2c4
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
import tkinter as tk
class Programm(tk.Tk):
def __init__(self):
super().__init__()
self.title("Сумма квадратов")
self.lbl = tk.Label(self, text="Введите m",font=("Times New Roman", 25))
self.lbl.pack()
self.inputer=tk.Entry(self, width=10, font=("Times New Roman", 25))
self.inputer.pack()
self.lbl1 = tk.Label(self, text="Введите n", font=("Times New Roman", 25))
self.lbl1.pack()
self.inputer1=tk.Entry(self, width=10, font=("Times New Roman", 25))
self.inputer1.pack()
self.btn=tk.Button(self, text="Подсчитать", command=self.clicked, font=("Times New Roman", 25))
self.btn.pack()
self.txt = tk.Label(self, text="Ответ:", font=("Times New Roman", 25))
self.txt.pack()
def clicked(self):
m=int(self.inputer.get())
n=int(self.inputer1.get())
res=0
for i in range(m,n+1):
res+=i**2
self.txt.destroy()
self.txt = tk.Label(self, text="Ответ: "+str(res), font=("Times New Roman", 25))
self.txt.pack()
if __name__ == "__main__":
app=Programm()
app.mainloop()
github: https://gist.github.com/Pyatii/c869dfd498ab0e6a3cb4968053ddf2c4