# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
#!/usr/bin/python
import kivy
from kivy.app import App
from kivy.uix.textinput import TextInput
from kivy.uix.gridlayout import GridLayout
from kivy.uix.button import Button
class RootWidget(GridLayout):
def __init__(self, **kwargs):
super(RootWidget, self).__init__(**kwargs)
self.cols = 2
self.add_widget(CreateInput(multiline=False))
class CreateInput(TextInput):
def on_text_validate(self):
for i in range(int(self.text)):
self.parent.add_widget(Button(text=str(i)))
class MyApp(App):
def build(self):
return RootWidget()
if __name__ == "__main__":
MyApp().run()
from kivy.uix.button import Button
from kivy.core.window import Window
class HLButton(Button):
def __init__(self, *args, **kwargs):
super(HLButton, self).__init__(*args, **kwargs)
Window.bind(mouse_pos=self.pos_check)
def pos_check(self, inst, pos):
if self.collide_point(*pos):
self.background_color = (1, 0, 0, 1)
else:
self.background_color = (.52, .43, .57, 1)
from kivy.config import Config
Config.set('graphics', 'fullscreen', 0)
#Config.set('graphics', 'resizable', 1)#Может быть понадобится
Config.set('graphics', 'height', 100)
Config.set('graphics', 'width', 100)
Config.write()
In order to avoid situations where the config settings do not work or are not applied before window creation (like setting an initial window size), Config.set should be used before importing any other Kivy modules. Ideally, this means setting them right at the start of your main.py script.
Kivy supports only one window per application: please don’t try to create more than one.
gl.add_widget( Button(text="AC", font_size=18, on_press=self.clear) )
, может быть?