S
S
Simple Ian2020-08-13 05:25:56
Python
Simple Ian, 2020-08-13 05:25:56

How to display print value in label?

import random
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button

class MyGrid(GridLayout):
    def __init__(self, **kwargs):
        super(MyGrid, self).__init__(**kwargs)
        self.cols = 1

        self.monitor = Label(text='')
        self.monitor.bind()
        self.add_widget(self.monitor)

        self.submit = Button(text="Generate!", font_size=40)
        self.submit.bind(on_press=self.pressed)
        self.add_widget(self.submit)

    def pressed(self, instance):
        chars = '+-/*!&$#[email protected]<>%^:;()abcdefghijklnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
        number = 1
        length = 5
        for n in range(number):
            password = ''
            for i in range(length):
                password += random.choice(chars)
        print("YourPassword:", password)




class MyApp(App):
    def build(self):
        return MyGrid()


if __name__ == "__main__":
    MyApp().run()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question