num_counter = 0
def start_xd():
Label_1.pack_forget()
Startbutton.pack_forget()
Label_2.pack()
Entry_1.pack(pady = 70)
Button_1.pack()
def Enter_1():
global nums
nums = Entry_1.get()
Label_2.pack_forget()
Entry_1.pack_forget()
Button_1.pack_forget()
Label_3.pack(pady = 20)
Entry_2.pack(pady = 70)
Button_2.pack()
def Enter_2():
global counter, num, num_list, num_counter
num = Entry_2.get()
num_list.append(int(num))
print(num_list)
counter += 1
if int(counter) == int(nums):
Label_3.pack_forget()
Entry_2.pack_forget()
Button_2.pack_forget()
for i in num_list:
if i % 10 == 6:
num_counter += 1
Label_4.pack()
Button_3.pack()
import tkinter as tk
from win32api import GetSystemMetrics
counter = 0
num_list = []
h = (GetSystemMetrics(0))//2
w = (GetSystemMetrics(1))//2
x = (GetSystemMetrics(0))//4
y =(GetSystemMetrics(1))//5
win = tk.Tk()
win.title('lol am at the top of that window xd')
win.geometry(f'{h}x{w}+{x}+{y}')
win.resizable(True, True)
win.minsize(250,400)
win.config(bg = '#9AE4F3')
pic = tk.PhotoImage(file = "C:\\Users\\bukov\\OneDrive\\Рабочий стол\\live-music.png")
win.iconphoto(False, pic)
Label_1 = tk.Label(win,
text = 'Привет! это моя первая GUI программа :3'\
+'\nПриятного пользования! UwU',
bg = '#D7F6FC',
font = ('ComicSans', 14, 'bold'),
padx = 20,
pady = 40,
relief = tk.RAISED,
bd = 1,
justify = tk.CENTER)
Label_2 = tk.Label(win,
text = 'Введите количество чисел, которые вы хотите ввести',
bg = '#D7F6FC',
font = ('ComicSans', 10, 'bold'),
padx = 20,
pady = 20,
relief = tk.RAISED,
bd = 1,
justify = tk.CENTER)
Label_3 = tk.Label(win,
text = 'Введите число:',
bg = '#D7F6FC',
font = ('ComicSans', 10, 'bold'),
padx = 20,
pady = 20,
relief = tk.RAISED,
bd = 1,
justify = tk.CENTER)
Label_4 = tk.Label(win,
text = 'Количество чисел, введённых вами и оканчивающихся на 6 - ' + str(num_counter),
bg = '#D7F6FC',
font = ('ComicSans', 10, 'bold'),
padx = 20,
pady = 20,
relief = tk.RAISED,
bd = 1,
justify = tk.CENTER)
Entry_1 = tk.Entry(win, bd = 1)
Entry_2 = tk.Entry(win, bd = 1)
Startbutton = tk.Button(win,
text = 'Запустить ( ̄︶ ̄)↗',
bg = '#9DB9BF',
command = start_xd)
Button_1 = tk.Button(win,
text = 'Ввод',
bg = '#9DB9BF',
command = Enter_1)
Button_2 = tk.Button(win,
text = 'Ввод',
bg = '#9DB9BF',
command = Enter_2)
Button_3 = tk.Button(win,
text = 'Выход из программы',
bg = '#9DB9BF',
command = exit)
Label_1.pack()
Startbutton.pack(side = 'bottom', pady = 50)
win.mainloop()
Не могу найти ошибку. В целом, программа работает, переменная с окончательным результатом содержит правильное значение, но в конце выводится 0. Помогите пожалуйста