Я делаю глупый «антикоронавирус» для P C. Это код:
import tkinter as tk
from tkinter import *
from tkinter import ttk
import random
window=Tk()
window.geometry('500x500')
window.resizable(False, False)
window.title('Anti Corona')
window.config(bg='light blue')
anti=tk.Label(text='Anti Corona')
anti.config(bg='light blue', font=('Arial black', 50))
anti.pack()
anti2=tk.Label(text='')
anti2.config(bg='light blue', font=('Arial black', 100))
anti2.pack()
def scaner(self):
self.f1=tk.Frame()
self.f1.pack()
self.progress=ttk.Progressbar(f1)
self.progress.length(50)
self.progress.pack()
scan=tk.Button(window, text='Scan!')
scan.config(height=1, width=10, font=('Century gothic', 30, 'bold'), bg='green', disabledforeground='', command=scaner())
scan.pack()
window.mainloop()
Проблема в том, что он выдает ошибку:
Traceback (most recent call last):
File "C:\Users\cicle.EAAULAINF1W-008\Desktop\Anticorona.py", line 23, in <module>
scan.config(height=1, width=10, font=('Century gothic', 30, 'bold'), bg='green', disabledforeground='', command=scaner())
TypeError: scaner() missing 1 required positional argument: 'self'
Но когда я завершаю все self
в def, вывод:
Traceback (most recent call last):
File "C:\Users\cicle.EAAULAINF1W-008\Desktop\Anticorona.py", line 23, in <module>
scan.config(height=1, width=10, font=('Century gothic', 30, 'bold'), bg='green', disabledforeground='', command=scaner())
File "C:\Users\cicle.EAAULAINF1W-008\Desktop\Anticorona.py", line 20, in scaner
progress.length(50)
AttributeError: 'Progressbar' object has no attribute 'length'
Я не знаю, что делать! Помогите мне, пожалуйста!