Учись сынок)
from kivy.config import Config
from kivy.uix.gridlayout import GridLayout
from kivy.animation import Animation
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput
# размеры окна
Config.set('graphics', 'fullscreen', '0')
Config.set('graphics', 'width', 400)
Config.set('graphics', 'height', 200)
Config.set('graphics', 'multisamples', '0')
class TestApp(App):
def build(self):
self.my_dictionary = None
layout = GridLayout(cols=1, row_force_default=True,
row_default_height=40)
self.key = TextInput(multiline=False, text='Введите ключ')
self.key.bind(text=self.create_dictionary)
self.value = TextInput(multiline=False, text='Введите значение')
self.value.bind(text=self.create_dictionary)
self.button = Button(text='Распечатать значения словаря', on_press =
self.print)
self.button.disabled = True
layout.add_widget(Label(text='Создание словаря в Python 3'))
layout.add_widget(self.key)
layout.add_widget(self.value)
layout.add_widget(self.button)
return layout
def create_dictionary(self, instance, value):
self.button.disabled = False
print(self.key.text, self.value.text)
self.my_dictionary = {self.key.text: self.value.text}
def print(self, instance):
print(self.my_dictionary.items())
if __name__ == '__main__':
TestApp().run()