Kivy是Python中与平台无关的GUI工具。由于它可以在Android, IOS, Linux和Windows等操作系统上运行。它基本上是用于开发Android应用程序, 但这并不意味着它不能在桌面应用程序上使用。
??Kivy教程–通过示例学习Kivy。
Accordion:
“Accordion”小部件是菜单的一种形式, 其中选项垂直或水平堆叠, 并且焦点对准的项目(触摸时)打开以显示其内容。
它可以包含许多项目实例, 每个实例都应包含一个根内容小部件。现在, 最终将像一棵树一样。
当前实现将AccordionItem分为两部分:
- 标题栏的一个容器(由kv Templet制造)
- 一个容纳内容的容器
Basic Approach:
1) import kivy
2) import kivyApp
3) import Accordian
4) Set minimum version(optional)
5) Create Accordion class
6) Create App class
7) create .kv file (name same as the app class)
8) return Layout/widget/Class(according to requirement)
9) Run an instance of the class
该方法的实施:
.py文件:
# How to use Accordion in kivy using .kv file
# Program to Show how to create a switch
# import kivy module
import kivy
# base Class of your App inherits from the App class.
# app:always refers to the instance of your application
from kivy.app import App
# this restrict the kivy version i.e
# below this kivy version you cannot
# use the app or software
kivy.require( '1.9.0' )
# The Accordion widget is a form of menu
# where the options are stacked either vertically
# or horizontally and the item in focus
# (when touched) opens up to display its content.
from kivy.uix.accordion import Accordion
# Create the Accordion class
# Whose work is done in .kv file
class Accor(Accordion):
pass
# Create App class
class AccorApp(App):
def build( self ):
return Accor()
# run the App
if __name__ = = '__main__' :
AccorApp().run()
.kv文件:
# .kv file of the Accordion App file
# Allow style to image
<MyImage@Image>:
keep_ratio: False
allow_stretch: True
# Use the different image to show usage of accordian
<Accor>:
orientation: 'vertical'
AccordionItem:
title: 'HTML 5'
MyImage:
source: 'html.png'
AccordionItem:
title: 'CSS 3'
MyImage:
source: 'css.png'
AccordionItem:
title: 'JAVASCRIPT'
MyImage:
source: 'javascript.png'
AccordionItem:
title: 'NODE-JS'
MyImage:
source: 'node-js.png'
AccordionItem:
title: 'BOOTSTRAP'
MyImage:
source: 'bootstrap.png'
输出如下:
首先, 你的面试准备可通过以下方式增强你的数据结构概念:Python DS课程。
评论前必须登录!
注册