Exemple #1
0
    def build(self):
        # open the view
        Clock.schedule_once(self.load_loading, 1)

        return Builder.load_string("""
GridLayout:
    cols:3

#<LoadingModal>:

<LoadingModal>:
    background: './ButtonImages/transparent.png'
    size_hint: None, None
    width: self.height
    height: app.root.height* 0.5
    LoadingWdgt:
        auto_dismiss: False
        text: "Loading "
        canvas.after:
            Color:
                rgb: 1,1,1
            Line:
                circle:self.center_x, self.center_y, (self.width / 2) * 0.8, self.angle_1, self.angle_2
                width: 2
        size_hint_y: None
        height: self.width
""")
Exemple #2
0
Builder.load_string("""
<LoginScreen>:
    canvas:
        Color:
            rgba: .1, .5, .8, 1
        Rectangle:
            size: self.size
            pos: self.pos
    FloatLayout:
        GridLayout:  # 登陆系统
            size_hint: (.8, .6)
            pos_hint: {'x': .1, 'y': .4}
            cols: 1
            spacing: ti_user.minimum_height
            CHLabel:
            BoxLayout:
                size_hint_y: None
                height: ti_user.minimum_height
                CHLabel:
                    size_hint: .2, 1
                CHLabel:
                    text: '用户认证'                
            BoxLayout:
                size_hint_y: None
                height: self.minimum_height
                CHLabel:                    
                    text: '用户名'
                    size_hint: .2, 1
                CHTextInput:
                    id: ti_user
                    size_hint_y: None
                    text: ''
                    multiline: False
                    height: self.minimum_height
            BoxLayout:
                size_hint_y: None
                height: self.minimum_height
                CHLabel:
                    text: '密码'
                    size_hint: .2, 1
                CHTextInput:
                    size_hint_y: None
                    text: ''
                    password: True
                    multiline: False
                    height: self.minimum_height
            BoxLayout:
                size_hint_y: None
                height: ti_user.minimum_height
                CHLabel:
                    size_hint: .2, 1
                CHButton:
                    text: '登入系统'
                    on_press: l_tips.text = '登陆中'; l_login_bar.value += 5
            CHLabel:
        GridLayout:  # 登陆提示
            size_hint: (.8, .2)
            pos_hint: {'x': .1, 'y': .1}
            cols: 1
            CHLabel:
                id: l_tips
                text: '登陆成功'
            ProgressBar:
                id: l_login_bar
                max: 100
""")
Exemple #3
0
    def get_o_radius(self):
        o1x, o1y    = self.anchors.get('o1', (0, 0))
        o2x, o2y    = self.anchors.get('o2', (0, 0))
        print "anchor get_o_radius", o1x, o1y, o2x, o2y
        radius      = abs(o2x - o1x) * 0.363 * 0.5
        return radius

    o_center    = AliasProperty(get_o_center, None, bind = 'x y anchors'.split())
    o_radius    = AliasProperty(get_o_radius, None, bind = 'anchors'.split())

Builder.load_string(u"""
#:kivy 1.0

<NaubinoLabel>:
    # * space at the end is necessary because the anchor only has a position
    #   if a character follows it
    # * space at the beginning is necessary to center the text
    #   with a space at the end
    # * I can't use a U+200B zero width space because it prints in kivy
    text:           " naubin[anchor=o1]o[anchor=o2] " 

    markup:         True
    font_name:      "Comfortaa-Light.ttf"
    font_size:      self.size[1]
    color:          0, 0, 0, 1
    pos_hint:       {'center_x': 0.5, 'center_y': 0.66}
    size_hint:      0, 0.2
    size:           0, 0
""")
Exemple #4
0
Builder.load_string("""
<rootwi>:
    size: root.size
    width: root.width
    heigth: root.height
    canvas:
        Color:
            # #263238
            rgb: 0x26 / 255.0, 0x32 / 255.0, 0x38 / 255.0
        Rectangle:
            size: self.size
    Widget:
        canvas:
            Color: 
                rgba: 0, 0, 0, 1
            Rectangle:
                pos:  30, self.y + 220
                size: self.width - 60, self.height - 460

    PathButton:
        on_press: fichier.text = self.get_path_file()
        text: 'Sélectionner le fichier initial'
        size_hint: .30, .05
        pos: root.width/10, root.heigth/2
    # PathButton:
    #     on_press: dossier.text = self.get_path_folder()
    #     text: 'Sélectionner le dossier de destination'
    #     size_hint: .35, .05
    #     pos: root.width/10, root.heigth/2-50
    PathButton:
        on_press: resultat.text = self.clean(fichier.text)
        text: 'Nettoyer et sauvegarder'
        size_hint: .30, .05
        pos_hint:{'center_x':.5,'center_y':.3}

    Label:
        id: fichier
        size_hint: None, None
        pos_hint:{'x':.6,'y':.45}

    Label:
        id: resultat
        size_hint: None, None
        pos_hint:{'center_x':.5,'y':.37}


""")
Exemple #5
0
                              duration=0.5,
                              t='in_expo')
        self.anim.bind(on_complete=self.completed_progress)
        self.anim.start(self)

    def completed_progress(self, animation, widget):
        self.content = self.pop_cont_lay

    def progress_position(self, interval):
        if self.myprogress.value >= self.myprogress.max:
            self.dismiss()

        else:
            self.myprogress.value += 1

    def pop_dismiss(self):
        Clock.unschedule(self.progress_position)
        self.myprogress.value = 0
        self.anim = Animation(size=(200, 200), duration=0.5, t='in_expo')
        self.anim.start(self)
        self.content = self.pop_cont_lay


class MyProgressBar(ProgressBar):
    def __init__(self, **kwargs):
        super(MyProgressBar, self).__init__(**kwargs)


Builder.load_string("""
<MyProgressBar>:
""")
Exemple #6
0
Builder.load_string('''
<Start>:
	BoxLayout:
		Button:
			padding:.2,.2
			size_hint:.5,.2
			text: "Бытие"
			on_press:root.manager.current = "bib"
<Biblia>:
	BoxLayout:
		id:glav
		orientation: "vertical"
		ScrollView:
			canvas.before:
		        Color:
		            rgba: .46,.44,.44,1
		        Rectangle:
		            pos: self.pos
		            size: self.size
			bar_width:4
			id: lab
			size:self.width, 1
			do_scroll_y:True
			do_scroll_x:False
			Label:
				text:root.t
				font_size:25
				size_hint_y:None
				size_hint_x: 1
				text_size: self.width, None
				height:self.texture_size[1]
		BoxLayout:
			size_hint_y:.2
			BoxLayout:
				orientation:"vertical"
				size_hint_x:.2
				Button:
					text:"Назад"
					on_release:root.back()
				Button:
					id:loads
					text:"Загрузить"
					on_release:root.scrop()
			BoxLayout:
				ScrollView:
					do_scroll_y:False
					do_scroll_x:True
					size_hint_y:.3
					size_hint_x:.8
					GridLayout:
						id:box
						rows:1
						size:self.width, .4
						width: self.minimum_width
						size_hint_x:None
				



	''')
Builder.load_string("""
<RippleMusic>:
    Image:
        size:self.size
        pos:self.pos
        canvas.before:
            Color:
                rgba: 1,1,1,1
            BorderImage:
                source: 'Icons/shadow32.png'
                border: (50,50,50,50)
                size:self.size
                pos:self.pos

<MySlider>:
    size_hint_y:.15
    canvas:
        Clear
        Color:
            rgb: (0.2, 0.2, 0.2)
        Rectangle:
            pos: self.pos
            size: self.width, self.height
        Color:
            rgb: (1, 0, 0)
        Rectangle:
            pos: self.pos
            size: self.width * (self.value_normalized if self.orientation == 'horizontal' else 1),\
            self.height * (self.value_normalized if self.orientation == 'vertical' else 1)

<MyScrollBoxLay>:
    canvas:
        Color:
            rgba:get_color_from_hex('#F00B00')
        Line:
            points:self.x, self.y, self.width, self.y
        
<MyBubble>:
    id:bbl
    BubbleButton:
        id:bblbtn
        text: 'TEXT'

""")
Exemple #8
0
        def build(self):
            window = Builder.load_string(kv_file)
            Window.bind(on_keyboard=self.on_keyboard)
            self.tryout()

            return window
Builder.load_string("""
<MusicPlayerLayout>:
    
    BoxLayout:
        orientation:'vertical'
        spacing:20
        padding:15
        Carousel:
            id:mus_karuseli
            Button:
        Slider:
            size_hint_y:.20
            id:mus_slider

        BoxLayout:     
            size_hint_y:.30
            canvas.before:
                Line:
                    rectangle:self.x,self.y, self.width, self.height
            Label:
                text:str(int(mus_slider.value))
                text_size:self.size
                valign:'top'
            Label:
                text:'text1'
                text_size:self.size
                valign:'top'
                halign:'right'
        BoxLayout: 
            canvas.before:
                Line:
                    rectangle:self.x,self.y, self.width, self.height
            size_hint_y:.25
            spacing:10
            Button:
                text:'shuffle'
            Button:
                id:but
                text:'back'
            ToggleButton:
                text:'pause/play'
            Button:
                text:'next'
            Button:
                text:'rotation'
        BoxLayout:
            canvas.before:
                Line:
                    rectangle:self.x,self.y, self.width, self.height
            size_hint_y:.20
            Label:
                text:'vol_down'
            Slider:
                id:vol_slider
            Label:
                text:'max'
        BoxLayout:
            size_hint_y:.20
            Button:
                text:'Pla'
""")
Exemple #10
0
Builder.load_string("""
<NodeButton@Button>:  # 节点按钮 点击选择对话目标
    font_name: 'msyh.ttc'
    on_press: 
        app.client.ids.t_address.text = self.text
        app.sm.transition.direction = 'left'
        app.sm.current = 'client'
<MessageLabel@Label>:  # 信息标签
    text_size: self.size
    halign: 'left'
    valign: 'middle'
    font_name: 'msyh.ttc'
    
<ChatContact>:  # 联系人列表
    BoxLayout:
        orientation: 'vertical'
        BoxLayout:
            size_hint_y: None
            height: sp(52)
            Button:
                text: ' '
                size_hint_x: None
                width: self.height * 2
            Button:
                text: 'Contact List'
                on_press: app.open_help()
            Button:  # 进入客户端
                text: 'Client'
                size_hint_x: None
                width: self.height * 2
                on_press: app.to_client('left')
        BoxLayout:
            orientation: 'horizontal'
            size_hint_y: None
            height: sp(104)
            GridLayout:
                cols: 2            
                Label:
                    size_hint_x: None
                    width: self.height * 2
                    text: 'Start IP:'
                TextInput:  # 起始地址
                    id: start_ip
                    text: root.start_ip
                Label:
                    size_hint_x: None
                    width: self.height * 2
                    text: 'Range:'
                TextInput:  # 扫描范围
                    id: scan_range
                    text: str(root.scan_range)
            Button: # 扫描局域网
                text: 'Scan'
                size_hint_x: None
                width: self.height
                on_press: root.scan_local()
        BoxLayout:  # 手动添加一个地址
            orientation: 'horizontal'
            size_hint_y: None
            height: sp(52)
            Label:
                text: 'IP:'
                size_hint_x: None
                width: self.height * 2
            TextInput:  # 地址
                id: new_host
                text: root.new_host
            Button:
                text: 'Add'
                size_hint_x: None
                width: self.height * 2
                on_press: root.add_new_node()
        NodeButton:  # 所有节点(群聊)
            text: 'All Nodes'
            size_hint_y: None
            height: sp(52)
        RecycleView:  # 节点列表
            viewclass: 'NodeButton'
            id: rv
            RecycleGridLayout:
                default_size: None, sp(52)
                default_size_hint: 1, None
                size_hint_y: None
                height: self.minimum_height
                cols: 1    
        ProgressBar:
            id: progress_scan
            size_hint_y: None
            height: sp(10)    
            max: root.scan_range
            
<ChatClient>:  # 客户端
    BoxLayout:
        orientation: 'vertical'
        BoxLayout:
            size_hint_y: None
            height: sp(52)
            Button:  # 打开联系人节点列表
                size_hint_x: None
                width: self.height * 2
                text: 'Contact'
                on_press: app.to_contact('right')
            Button:  # 对话地址
                text: 'Client'
                on_press: app.open_help()
            Button: # 打开服务端
                text: 'Server'
                size_hint_x: None
                width: self.height * 2
                on_press: app.to_server('left') 
        BoxLayout:
            size_hint_y: None
            height: sp(36)
            Label:
                text: 'To '
                text_size: self.size
                halign: 'center'
                size_hint_x: None
                width: sp(104)
            Label:  # 对话地址
                id: t_address
                text_size: self.size
                halign: 'left'
                text: 'All Nodes'
                font_name: 'msyh.ttc'
        RecycleView:
            id: rv_messages
            viewclass: 'MessageLabel'
            RecycleGridLayout:
                default_size: None, sp(104)
                default_size_hint: 1, None
                size_hint_y: None
                height: self.minimum_height
                cols: 1
        Button:  # 占位
            size_hint_y: None
            height: sp(52)
    FloatLayout:  # 信息输入
        BoxLayout:
            id: input_layout
            size_hint:(1, None)
            pos_hint: {'x': 0, 'y': 0}
            orientation: 'horizontal'
            height: sp(52)
            TextInput:
                id: ti_message
                font_name: 'msyh.ttc'
                hint_text: 'Input message...'
                text_language: 'zh_CN'
                on_focus: root.edit_message()
            Button:
                size_hint_x: None
                width: self.height
                text: 'Send'
                on_press: app.send_message()

<ChatServer>:  # 服务端
    BoxLayout:
        orientation: 'vertical'
        BoxLayout:
            size_hint_y: None
            height: sp(52)
            Button:  # 返回客户端
                text: 'Client'
                size_hint_x: None
                width: self.height * 2
                on_press: app.to_client('right')
            Button:  # 本机地址信息
                text: 'Server'
                on_press: app.open_help()
            ToggleButton:
                size_hint_x: None
                width: self.height * 2
                text: 'Log On' if self.state=='normal' else 'Log Off'
                state: 'down'
                id: log_switch
                on_state: root.show_logs()
        Label:  # 本机地址信息
            size_hint_y: None
            height: sp(36)
            text: 'Local host: [ %s : %s ]' % (root.host_ip, root.host_port)
        BoxLayout:  # 日志信息
            orientation: 'vertical'
            RecycleView:
                id: rv
                viewclass: 'Label'
                RecycleGridLayout:
                    default_size: None, sp(52)
                    default_size_hint: 1, None
                    size_hint_y: None
                    height: self.minimum_height
                    cols: 1
                
        BoxLayout:  # 手动启动服务器
            size_hint_y: None
            height: sp(52)
            Button:
                text: 'Start'
                on_press: root.start_server()
            # Button:
            #    text: 'Stop'        
            #    on_press: root.stop_server()
            
<UserSetting>:  # 用户设置
    FloatLayout:
        orientation: 'vertical'
        Label:
            id: label_welcome
            font_name: 'msyh.ttc'
            size_hint: (.8, None)
            height: sp(54)
            pos_hint: {'x': .1, 'y': .6}
            text: 'Input a Nickname: ' if root.is_new else 'Welcome < %s >' % root.data['name']
        TextInput:
            id: ti_nickname
            font_name: 'msyh.ttc'
            height: sp(54)
            size_hint: (.8, None)
            pos_hint: {'x': .1, 'y': .5}
            multiline: False
            disabled: False if root.is_new else True 
            hint_text: 'Input a Nickname' if root.is_new else 'Click <Reset> to Setting a New Nickname'      
        Button:
            text: 'Reset'  
            height: sp(54)
            size_hint: (.8, None)
            pos_hint: {'x': .1, 'y': .4}
            disabled: True if root.is_new else False  
            on_press: root.is_new = True; root.data.clear() 
        Button:
            text: 'Start'
            size_hint_y: None
            height: sp(54)
            pos_hint: {'x': 0, 'y': 0}
            on_press: app.save_user_setting()
""")
Exemple #11
0
from kivy.app import App
from kivy.base import Builder
from kivy.properties import StringProperty, ObjectProperty
from kivy.uix.boxlayout import BoxLayout

Builder.load_string("""
<rootwi>:
    BoxLayout:
        orientation: 'vertical'
        textinputtext: txt.text
        obj_widget: w1
        BoxLayout:
            Button:
                on_press: root.print_txt()
            TextInput:
                id: txt
                text: root.textinputtext
<MyRootWidget@BoxLayout>:
    obj_widget: w1
    MyWidget:
        id: w1
        text: "purple turtle"
'''                
""")


class rootwi(BoxLayout):
    textinputtext = StringProperty()

    def __init__(self, **kwargs):
        super(rootwi, self).__init__(**kwargs)
Exemple #12
0
Builder.load_string("""
#:import Window kivy.core.window.Window
<VideoPlayerLayout>:
    BoxLayout:
        orientation:'vertical'
        Button:
            size_hint_y:.15
            text:'Browse'
            on_press:root.pop.open()

        TabbedPanel:
            do_default_tab: False
            tab_pos:'top_mid'
            tab_width:self.width/2
            TabbedPanelItem:
                text:'Library'

                Carousel:
                    id:vid_karuseli
            TabbedPanelItem:
                text:'VideoList'
    

<MyBox>:
    size_hint_y:None
    orientation:'vertical'
    spacing:15
    BoxLayout:
        Slider:
            size_hint_y:None
            height:self.parent.height
            on_touch_down:
                if self.collide_point(*Window.mouse_pos):self.height = 300
            on_touch_up:
                if self.collide_point(*Window.mouse_pos):self.height = self.parent.height
            canvas:
                Clear
                Color:
                    rgb: (0.2, 0.2, 0.2)
                Rectangle:
                    pos: self.pos
                    size: self.width, self.height
                Color:
                    rgb: (1, 0, 0)
                Rectangle:
                    pos: self.pos
                    size: self.width * (self.value_normalized if self.orientation == 'horizontal' else 1),\
                    self.height * (self.value_normalized if self.orientation == 'vertical' else 1)
                    
        Image:
            source:'Icons/muted.png' if vl_sld.value==0 else 'Icons/medium.png' if vl_sld.value<50 else 'Icons/high.png'
            size_hint_x:.15
        Slider:
            id:vl_sld
            min:0
            max:100
            size_hint_y:None
            height:self.parent.height
            size_hint_x:.30
            on_touch_down:
                if self.collide_point(*Window.mouse_pos):self.height = 300
            on_touch_up:
                if self.collide_point(*Window.mouse_pos):self.height = self.parent.height
            canvas:
                Clear
                Color:
                    rgb: (0.2, 0.2, 0.2)
                Rectangle:
                    pos: self.pos
                    size: self.width, self.height
                Color:
                    rgb: (1, 0, 0)
                Rectangle:
                    pos: self.pos
                    size: self.width * (self.value_normalized if self.orientation == 'horizontal' else 1),\
                    self.height * (self.value_normalized if self.orientation == 'vertical' else 1)
    BoxLayout:
        size_hint_x:.40
        pos_hint:{'x':.30,'y':0}
        canvas:
            Color:
                rgba: 0.88,0.88,0.88,1
            RoundedRectangle:
                size: self.size
                pos: self.pos

        AnimBut:
            source:'Icons/back.png'
            on_touch_down: if self.collide_point(*Window.mouse_pos): print('BACK')
        AnimBut:
            source:'Icons/stop.png'
            on_touch_down: if self.collide_point(*Window.mouse_pos): root.parent.ids.vid_karuseli.current_slide.state='stop';\
            root.parent.ids.vid_karuseli.current_slide.source='IMG_0827.png';\
            strtbtn.state='normal'
                

        AnimTogBut:
            id:strtbtn
            source:'Icons/pause.png' if self.state=='down' else 'Icons/next.png'

            on_state:
                root.parent.ids.vid_karuseli.current_slide.source = root.parent.ids.vid_karuseli.current_slide.video;\
                root.parent.ids.vid_karuseli.current_slide.state='play' if self.state=='down' else 'pause'
        AnimBut:
            source:'Icons/next.png'
            on_touch_down: if self.collide_point(*Window.mouse_pos): print('NEXT')

""")
Exemple #13
0
Builder.load_string("""
<ChatScreen>:  # 客户端
    BoxLayout:
        orientation: 'vertical'
        BoxLayout:
            size_hint_y: None
            height: sp(52)
            CHButton:  # 打开联系人节点列表
                size_hint_x: None
                width: self.height * 2
                text: 'Contact'
            CHButton:  # 对话地址
                text: 'Client'
            CHButton: # 打开服务端
                text: 'Server'
                size_hint_x: None
                width: self.height * 2
        BoxLayout:
            size_hint_y: None
            height: sp(36)
            CHLabel:
                text: 'To '
                text_size: self.size
                halign: 'center'
                size_hint_x: None
                width: sp(104)
            CHLabel:  # 对话地址
                id: t_address
                text_size: self.size
                halign: 'left'
                text: 'All Nodes'
        RecycleView:
            id: rv_messages
        Button:  # 占位
            size_hint_y: None
            height: sp(52)
    FloatLayout:  # 信息输入
        BoxLayout:
            id: input_layout
            size_hint:(1, None)
            pos_hint: {'x': 0, 'y': 0}
            orientation: 'horizontal'
            height: sp(52)
            CHTextInput:
                id: ti_message
                font_name: 'msyh.ttc'
                hint_text: '输入信息...'
                text_language: 'zh_CN'
                on_focus: input_layout.pos_hint = ({'x': 0, 'y': .5} if self.focus else {'x': 0, 'y': 0})
            CHButton:
                size_hint_x: None
                width: self.height
                text: '发送'
""")