Kivy

K i v y Kivy Kivy

Kivy - Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.

Kivy runs on Linux, Windows, OS X, Android, iOS, and Raspberry Pi. You can run the same code on all supported platforms.


官网:https://kivy.org/#home


官方文档


Windows 下安装 kivy

pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install kivy.deps.gstreamer -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install kivy -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
pip install kivy_examples -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

验证 kivy 安装

from kivy.app import App
from kivy.uix.button import Button

class TestApp(App):
    def build(self):
        return Button(text='Major')
        
TestApp().run()

在这里插入图片描述

from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import Color,Ellipse,Line
from random import random
from kivy.uix.button import Button

class MyWidgetWidget(Widget):
    def on_touch_down(self, touch):
        color=(random(),random(),random())
        with self.canvas:
            Color(*color)
            touch.ud['Line']=Line(points=(touch.x,touch.y),width=5)

    def on_touch_move(self, touch):
        touch.ud['Line'].points=touch.ud['Line'].points+[touch.x,touch.y]

class MyPaintApp(App):
    def build(self):
        parent=Widget()
        self.painter=MyWidgetWidget()
        clearbtn=Button(text="Clear")
        clearbtn.bind(on_release=self.clear_canvas)
        parent.add_widget(self.painter)
        parent.add_widget(clearbtn)
        return parent

    def clear_canvas(self,obj):
        self.painter.canvas.clear()

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

在这里插入图片描述

打包成apk安卓应用

https://blog.csdn.net/qq_43551034/article/details/104873485

https://blog.csdn.net/qq_37030400/article/details/107620264

https://blog.csdn.net/qq_29027865/article/details/79191775

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值