There wasn't a way to adjust the text in the kv file on the net, so a sample of kivy's original site (https://pyky.github.io/kivy-doc-ja/examples/gen__demo__showcase__main__py.html#file) -demo-showcase-showcase-kv) I made the following script while referring to (almost plagiarism).
main.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from kivy.app import App
from kivy.config import Config
from kivy.uix.widget import Widget
from kivy.uix.popup import Popup
from kivy.properties import ObjectProperty
#force size of your window
Config.set('graphics','width','800')
Config.set('graphics','height','800')
class A_Button(Widget):
popup = ObjectProperty()
class Example(App):
def build(self):
return A_Button()
if __name__ == '__main__':
Example().run()
example.kv
<A_Button>:
popup: pop
BoxLayout:
id: top
Popup:
id: pop
title: "Hello World"
on_parent:
if self.parent == top: self.parent.remove_widget(self)
Button:
text: 'press to dismiss'
on_release: pop.dismiss()
Button:
text: 'press to show Popup'
on_release: root.popup.open()
Most of the kv files came from the showcase sample. As for the layout, I am not particular about the operation because I focused on the operation. Somehow I could do it with an image that uses ObjectProperty and passes it to a kv file.
I thought that I still have to study Object Property and so on.
Recommended Posts