You are defining two classes with the same name, 'PasswordGenerator' and the second class definition is overwriting the first one. Combine the two class definitions into one and remove the duplicate class -
from kivy.app import App
from kivy.uix.widget import Widget
import random
class PasswordGenerator(Widget):
def generate_password(self, password_length):
chars = 'abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*'
password = ''
for x in range(password_length):
password += random.choice(chars)
return password
class PasswordGeneratorApp(App):
def build(self):
return PasswordGenerator()
if __name__ == '__main__':
print('Podaj liczbę znaków, które chcesz mieć w haśle: ')
password_length = int(input())
print('Twoje hasło: ')
generator_app = PasswordGeneratorApp()
password = generator_app.root.generate_password(password_length)
print(password)
generator_app.run()
I renamed the one class that extends 'App' to 'PasswordGeneratorApp' to avoid the name conflict, should run now without the error.