android 来电监听 kivy,android – 简单的kivy标签示例

我是使用Kivy进行

Android开发的新手.我创建了一个如下所示的标签结构:

from kivy.app import App

from kivy.uix.tabbedpanel import TabbedPanel

from kivy.uix.tabbedpanel import TabbedPanelHeader

from kivy.uix.button import Button

from kivy.uix.label import Label

from kivy.uix.image import Image

class TabbedPanelApp(App):

def build(self):

tb_panel= TabbedPanel()

# Create text tab

th_text_head = TabbedPanelHeader(text='Text tab')

th_text_head.content= Label(text='This is my text content')

# Create image tab

th_img_head= TabbedPanelHeader(text='Image tab')

th_img_head.content= Image(source='sample.jpg',pos=(400, 100), size=(400, 400))

# Create button tab

th_btn_head = TabbedPanelHeader(text='Button tab')

th_btn_head.content= Button(text='This is my button',font_size=20)

tb_panel.add_widget(th_text_head)

tb_panel.add_widget(th_img_head)

tb_panel.add_widget(th_btn_head)

return tb_panel

if __name__ == '__main__':

TabbedPanelApp().run()

我想将登录小部件添加到默认选项卡.登录小部件的代码是:

import kivy

kivy.require('1.0.5')

from kivy.uix.gridlayout import GridLayout

from kivy.uix.boxlayout import BoxLayout

from kivy.uix.button import Button

from kivy.app import App

from kivy.lang import Builder

from kivy.uix.widget import Widget

from kivy.properties import ObjectProperty, StringProperty

class loginView(Widget):

status=ObjectProperty(None)

def validate(self,username,password):

print "user - ", username

print "pwd - ", password

if username == password:

print "in if - ", username,password

self.status.text="Login sucess"

#mainClass().run()

else:

self.status.text="Login failed"

class afterLogin(Widget):

def dumb(self):

l = BoxLayout(cols="2")

btn = Button(text="ad")

l.add_widget(btn)

print "flag"

class mainClass(App):

def build(self):

return loginView()

if __name__ == '__main__':

mainClass().run()

和kv文件是:

#:kivy 1.0.5

:

status:result

Label:

text:"Contacts Manager"

pos:600,600

font_size:40

Label:

text:"Username"

pos:450,400

Label:

text:"Password"

pos:450,300

TextInput:

multiline:False

pos:600,425

size:200,45

font_size:20

id:username

TextInput:

multiline:False

pos:600,325

password:True

size:200,45

font_size:20

id:password

Button:

text:"Login"

size:100,50

pos:600,250

on_press:root.validate(username.text,password.text)

Label:

text:""

pos:600,100

id:result

:

Label:

text:"Welcome"

如何将此代码添加到默认选项卡中?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值