[Python Kivy] How to create a simple pop up window

I want to adjust the size etc. with the Kv file

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

[Python Kivy] How to create a simple pop up window
I want to create a window in Python
How to create a JSON file in Python
How to create a Kivy 1-line input box
How to create a multi-platform app with kivy
How to set up a Python environment using pyenv
How to create a simple TCP server / client script
[Python] How to create a 2D histogram with Matplotlib
How to create a kubernetes pod from python code
How to write a Python class
How to specify a public directory Python simple HTTP server
How to create a virtual bridge
How to create a Dockerfile (basic)
How to speed up Python calculations
5 Ways to Create a Python Chatbot
[Python Kivy] How to create an exe file with pyinstaller
How to create a config file
How to set up a simple SMTP server that can be tested locally in Python
How to create a heatmap with an arbitrary domain in Python
How to create a clone from Github
[Python] How to make a class iterable
[Kivy] How to install Kivy on Windows [Python]
[Python] How to convert a 2D list to a 1D list
[Python] How to invert a character string
How to get a stacktrace in python
How to create a repository from media
How to run a Maya Python script
[Python / Tkinter] Search for Pandas DataFrame → Create a simple search form to display
3. Natural language processing with Python 1-2. How to create a corpus: Aozora Bunko
Set up a simple HTTPS server in Python 3
[Python] List Comprehension Various ways to create a list
Edit Excel from Python to create a PivotTable
A simple example of how to use ArgumentParser
How to open a web browser from python
How to clear tuples in a list (Python)
How to create a function object from a string
How to use Python Kivy ④ ~ Execution on Android ~
How to generate a Python object from JSON
How to add a Python module search path
Steps to create a Twitter bot with python
Create a simple momentum investment model in Python
How to notify a Discord channel in Python
How to create a shortcut command for LINUX
[Note] How to create a Ruby development environment
How to set up a local development server
Set up a simple SMTP server in Python
[Python] How to draw a histogram in Matplotlib
How to create a Rest Api in Django
[Note] How to create a Mac development environment
[Python] How to create a local web server environment with SimpleHTTPServer and CGIHTTPServer
How to install Python
Create a Python environment
Read the Python-Markdown source: How to create a parser
How to convert / restore a string with [] in python
How to create a submenu with the [Blender] plugin
[Python] How to expand variables in a character string
Create a plugin to run Python Doctest in Vim (2)
[Go] How to create a custom error for Sentry
How to write a list / dictionary type of Python3
Create a plugin to run Python Doctest in Vim (1)
How to build a Django (python) environment on docker