Пример #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
""")
Пример #2
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
				



	''')
import json

from kivy.base import Builder
from kivy.storage.jsonstore import JsonStore
from kivy.uix.boxlayout import BoxLayout
from MMUser import *
from MessageWidget import *
from CHLabel import *
from MMMessage import *

Builder.load_file('ChatWidget.kv')


class ChatWidget(BoxLayout):
    """个人信息界面"""
    message_path = ""  # 信息存储位置
    user = ""  # 用户
    contact = {'name': None, 'address': None, 'pubkey': None}  # 联系人信息

    def __init__(self, user, contact, m_path, **kwargs):
        """构造函数"""
        super(ChatWidget, self).__init__(**kwargs)
        self.message_path = m_path
        self.user = user
        self.contact = contact
        self.load_history()

    def load_history(self):
        """加载聊天历史"""
        self.ids['history_list'].clear_widgets()
        try:
from MineWidget import *
from NodeWidget import *
from MessageWidget import *
from ChatWidget import *
from util import *
from MMUser import *
from MMMessage import *
from PublicWidget import *
from secp256k1 import PrivateKey, PublicKey
from Crypto.PublicKey import RSA
from Crypto.Hash import SHA
from Crypto.Cipher import PKCS1_v1_5
from Crypto import Random
import binascii

Builder.load_file('UserScreen.kv')
help_text = """
**帮助信息**
===========
点击<[color=ff3333]私有信息[/color]>按钮 -> 查看对话信息
点击<[color=ff3333]公开信息[/color]>按钮 -> 查看公开信息
点击<[color=ff3333]联系人[/color]>按钮 -> 查看联系人列表
点击<[color=ff3333]个人信息[/color]>按钮 -> 查看个人地址密钥等信息
点击<[color=ff3333]重新选择[/color]>按钮 -> 重新选择测试用户
点击<[color=ff3333]配置信息[/color]>按钮 -> 查看节点配置信息
点击<[color=ff3333]用户名[/color]>按钮 -> 同步服务器与本地信息
点击<[color=ff3333]扫一扫[/color]>按钮 -> 添加好友或节点等
"""


class ContactView(ScrollView):
Пример #5
0
import math
from typing import Optional
import chess
import chess.engine
from chess.pgn import GameNode
from kivy.animation import Animation
from kivy.uix.boxlayout import BoxLayout
import analysis
from kivy.uix.widget import Widget
from kivy.properties import NumericProperty, ObjectProperty, BooleanProperty, StringProperty
from kivy.graphics import Color, Mesh, Line
from kivy.clock import *
from kivy.base import Builder
Builder.load_file("./kv/analysis.kv")


def getHeight(instance, eval):
    return 0.5 * instance.height * \
        (1 + instance.sign * eval / 10)


class EvaluationBar(Widget):
    bgColor = ObjectProperty((0, 0, 0))
    barColor = ObjectProperty((0, 0, 0))
    eval = NumericProperty()
    rectHeight = NumericProperty()
    textEval = StringProperty()
    pov = StringProperty("WHITE")
    sign = BooleanProperty()
    animRunning = BooleanProperty(False)
    animWidget = ObjectProperty(rebind=True)

from kivy.uix.gridlayout import GridLayout
from kivy.base import Builder
from kivy.uix.screenmanager import Screen
import database_interface
import display_controller as controller
from kivy.uix.textinput import TextInput
from kivy.uix.checkbox import CheckBox
from kivy.uix.label import Label


Builder.load_file('Kivy_Layouts/NewAlert.kv')


class NewAlertScreen(Screen):

    def add_alert(self):

        info = controller.MANAGER.get_screen("new_alert").children[0].children[0]
        alarm = dict()
        alarm['description'] = ""
        alarm['type'] = "quantity"
        alarm['flag'] = dict()
        alarm['flag']['max'] = 0
        alarm['flag']['min'] = 0
        alarm['target_bins'] = []

        if len(info.children[-1].text) > 200:
            alarm['description'] = info.children[-1].text[0:200].lstrip().rstrip()
        else:
from kivy.core.window import Window
from kivy.properties import NumericProperty, ListProperty, StringProperty, ObjectProperty, ReferenceListProperty, BooleanProperty
from kivy.vector import Vector
from kivy.utils import platform, get_color_from_hex
from kivy.metrics import dp
from kivy.clock import Clock
from kivy.app import App
from kivy.base import Builder
from kivy.event import EventDispatcher

# non-kivy imports
from colorsys import rgb_to_hsv
from time import time

#  Load the .kv file
Builder.load_file('VLSI_Circuit_Breaker_2.kv')


class VLSI_Circuit_BreakerClass(FloatLayout, EventDispatcher):
    """main class of the game"""
    wirehead = ObjectProperty(None)
    circuitbreakerbase = ObjectProperty(None)
    wire_color = get_color_from_hex('47f597')[:-1] + [.8]
    wire_visible = BooleanProperty(False)

    def __init__(self, **kwargs):
        super(VLSI_Circuit_BreakerClass, self).__init__(**kwargs)
        Window.bind(on_keyboard=self.on_keyboard)
        self.register_event_type('on_hacked')

    def on_enter(self, *args):
Пример #8
0
                    mp = self.add_mirror_page()
                    for ph, b in zip(
                            reversed(mp.children),
                        [dual_dict[f] for f in vars['added_ones']]):
                        self.set_ph_img(ph, b, use_img_size=False)
                #Once completed, add a new page
                self.add_page()
                vars['added_ones'] = list()
                #Now, put back into the fg the needed cs. Also link dual if exists
                ncs = self.ids.pictures.children[0]
                if dual_dict:
                    dual_dict[ncs] = dual_dict[cs]
                fg.append((ncs, _))
            elif not (
                    fg
            ) and dual_dict:  #layout is done. proceed with last uncompleted mirror page
                vars['added_ones'].append(cs)
                mp = self.add_mirror_page()
                for ph, b in zip(reversed(mp.children),
                                 [dual_dict[f] for f in vars['added_ones']]):
                    self.set_ph_img(ph, b, use_img_size=False)
            else:
                vars['added_ones'].append(cs)

        Clock.schedule_interval(inner, .05)


Builder.load_file('kv/layout.kv')

from csv import DictReader
Пример #9
0
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'
""")
__author__ = 'Nixon'

from kivy.uix.gridlayout import GridLayout
from kivy.base import Builder
from kivy.uix.screenmanager import Screen
from kivy.uix.progressbar import ProgressBar
from kivy.uix.label import Label
import database_interface
import display_controller as controller
import math

Builder.load_file('Kivy_Layouts/FoodScreen.kv')


class FoodScreen(Screen):
    pass


class FoodGrid(GridLayout):
    pass


class DataGrid(GridLayout):
    def update(self):
        self.clear_widgets()

        bins = controller.sort_bin(database_interface.get_data(database_interface.CONFIG.BINS, {}))
        temp = list()
        for b in bins:
            temp.append(b)
        bins = temp
Пример #11
0
from kivy.properties import NumericProperty, ObjectProperty, BooleanProperty, StringProperty
from kivy.uix.anchorlayout import *
from kivy.uix.behaviors import *
from kivy.uix.boxlayout import *
from kivy.uix.gridlayout import GridLayout
from kivy.uix.image import *
from kivy.uix.modalview import ModalView
from kivy.uix.widget import Widget
from kivy.input.motionevent import MotionEvent
from movelist import MoveList
from tile import Tile
from typing import List, Optional
import chess
import chess.pgn
from kivy.base import Builder
Builder.load_file("./kv/board.kv")


class Row(GridLayout):
    rowNumber = NumericProperty(0)
    reverseOrder = BooleanProperty(False)


class PromotionBubble(ModalView):
    color = BooleanProperty(chess.WHITE)
    promotePlay = ObjectProperty(None)
    pieceDir = StringProperty("")

    def __init__(self, attachWidget, color, pieceDir, **kwargs):
        self.attach_to = attachWidget
        self.color = color
Пример #12
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()
""")
Пример #13
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)
Пример #14
0
import json

from kivy.base import Builder
from kivy.network.urlrequest import UrlRequest
from kivy.uix.boxlayout import BoxLayout
from MessageWidget import *
from MMMessage import *
from kivy.uix.gridlayout import GridLayout

Builder.load_file('NodeWidget.kv')

message_hash = set()  # 本地信息哈希集合


class NodeWidget(BoxLayout):
    """节点配置界面"""
    def __init__(self, **kwargs):
        super(NodeWidget, self).__init__(**kwargs)
        self.server_layout = ServerLayout()
        self.sync_layout = SyncMessageLayout()
        self.add_widget(self.server_layout)
        self.ids['sync_test'].bind(on_press=self.sync_test)
        self.ids['conn_test'].bind(on_press=self.conn_test)

    def sync_test(self, sender):
        """加载信息同步界面"""
        if sender.state == 'down':
            self.remove_widget(self.server_layout)
            url = self.server_layout.ids['server_url'].text
            self.sync_layout.update_url(url)
            self.add_widget(self.sync_layout)
Пример #15
0
from kivy.base import Builder
from kivy.uix.gridlayout import GridLayout
from kivy.uix.screenmanager import Screen
from kivy.uix.scrollview import ScrollView
from CHButton import *
from Configure import *

Builder.load_file('SelectUserScreen.kv')


class SelectUserScreen(Screen):
    pass


class SelectUserView(ScrollView):
    """选择用户视图"""
    demo_users = {}

    def __init__(self, **kwargs):
        """构造函数"""
        super(SelectUserView, self).__init__(**kwargs)
        layout = GridLayout(cols=1, spacing=10, size_hint_y=None, height=1024)
        layout.bind(minimum_height=layout.setter('height'))
        # 添加已有测试用户按钮
        for name in demo_user_names:
            c = CHButton(text=name, size_hint_y=None, height=160)
            self.demo_users[name] = c
            layout.add_widget(c)
        # 添加新建用户按钮
        c = CHButton(text="新建用户", size_hint_y=None, height=160)
        # self.demo_users[name] = c

from kivy.uix.gridlayout import GridLayout
from kivy.base import Builder
from kivy.uix.screenmanager import Screen
import database_interface
import display_controller as controller
from kivy.uix.textinput import TextInput
from kivy.uix.label import Label

Builder.load_file('Kivy_Layouts/NewContact.kv')


class NewContactScreen(Screen):

    def add_contact(self):
        info = controller.MANAGER.get_screen("new_contact").children[0].children[0]
        contact = dict()
        if len(info.children[-1].text) > 30:
            contact['name'] = info.children[-1].text[0:30].lstrip().rstrip()
        else:
            contact['name'] = info.children[-1].text.lstrip().rstrip()
        if len(info.children[-2].text) > 40 and '@' in info[-2]:
            contact['email'] = info.children[-2].text[0:40].lstrip().rstrip()
        elif '@' in info.children[-2].text:
            contact['email'] = info.children[-2].text.lstrip().rstrip()
        else:
            contact['email'] = ''
        if len(info.children[-3].text) > 10:
            contact['phone'] = info.children[-3].text[0:10].lstrip().rstrip()
        else:
__author__ = 'Nixon'


from kivy.uix.gridlayout import GridLayout
from kivy.base import Builder
from kivy.uix.screenmanager import Screen
from kivy.uix.listview import ListView, ListItemButton
from kivy.adapters.listadapter import ListAdapter
import display_controller as controller
import database_interface

Builder.load_file('Kivy_Layouts/SettingContacts.kv')


class SettingContactScreen(Screen):
    pass


class SettingContactGrid(GridLayout):
    pass


class SettingContactSubGrid(GridLayout):
    def update_contacts(self):
        self.clear_widgets(children=0)
        self.add_widget(SettingContactList())

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

Пример #18
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}


""")
Пример #19
0
from typing import Set
from chess.pgn import GameNode
from kivy.uix.behaviors.button import ButtonBehavior
from kivy.uix.dropdown import DropDown
from kivy.uix.button import Button
from kivy.uix.widget import Widget
import kivy.effects.scroll
from kivy.base import Builder
from kivy.properties import BooleanProperty, StringProperty
Builder.load_file("./kv/dropbox.kv")


class GameButton(ButtonBehavior, Widget):
    selected = BooleanProperty(False)
    text = StringProperty("")
    instances = set()

    def __init__(self, game, controller, dropdown, **kwargs):
        self.selected = False
        super().__init__(**kwargs)
        self.game = game
        self.controller = controller
        self.dropdown = dropdown
        GameButton.instances.add(self)

    def loadGame(self, instance):
        self.dropdown.dismiss()
        self.controller.loadGame(self.game)
        for b in GameButton.instances:
            b.selected = False
        self.selected = True
Пример #20
0
from kivy.base import Builder
from kivy.uix.boxlayout import BoxLayout


Builder.load_file('MineWidget.kv')


class MineWidget(BoxLayout):
    """个人信息界面"""
    address = ""
    rsa_prikey = ""
    rsa_pubkey = ""
    ecc_prikey = ""
    ecc_pubkey = ""
    aes_key = ""
    aes_iv = ""

    def __init__(self, **kwargs):
        """初始化函数"""
        super(MineWidget, self).__init__(**kwargs)

    def set_user(self, user):
        """设置用户"""
        self.address = user.address
        self.rsa_prikey = user.rsa_prikey
        self.rsa_pubkey = user.rsa_pubkey
        self.ecc_prikey = user.ecc_prikey
        self.ecc_pubkey = user.ecc_pubkey
        self.aes_key = user.aes_key
        self.aes_iv = user.aes_iv
Пример #21
0
from kivy.app import App
from kivy.base import Builder
from kivy.uix.screenmanager import Screen
from CHButton import *

Builder.load_file('TestScreen.kv')


class TestScreen(Screen):
    pass

from kivy.uix.gridlayout import GridLayout
from kivy.base import Builder
from kivy.uix.screenmanager import Screen
from kivy.uix.textinput import TextInput
import database_interface
import display_controller as controller

Builder.load_file('Kivy_Layouts/UpdateContact.kv')


class UpdateContactScreen(Screen):
    
    def add_contact(self):
        info = controller.MANAGER.get_screen("new_contact").children[0].children[0]
        contact = dict()
        if len(info.children[-1].text)>30:
            contact['name'] = info.children[-1].text[0:30].lstrip().rstrip()
        else:
            contact['name'] = info.children[-1].text.lstrip().rstrip()
        if len(info.children[-2].text)>40 and '@' in info[-2]:
            contact['email'] = info.children[-2].text[0:40].lstrip().rstrip()
        elif '@' in info.children[-2].text:
            contact['email'] = info.children[-2].text.lstrip().rstrip()
        if len(info.children[-3].text)>10:
            contact['phone'] = info.children[-3].text[0:10].lstrip().rstrip()
        else:
            contact['phone'] = info.children[-3].text.lstrip().rstrip()
        database_interface.update(database_interface.CONTACT, {'name': contact['name']}, contact)
Пример #23
0
                self.remove_ph(ph)
                vars['row_index'] = 0
                vars['col_index'] = 0
                if dual_dict:
                    #First page is done, create dual
                    mp = self.add_mirror_page()
                    for ph, b in zip (reversed(mp.children), [dual_dict[f] for f in vars['added_ones']]):
                        self.set_ph_img(ph,b, use_img_size= False)
                #Once completed, add a new page
                self.add_page()
                vars['added_ones'] = list()
                #Now, put back into the fg the needed cs. Also link dual if exists
                ncs = self.ids.pictures.children[0]
                if dual_dict:
                    dual_dict[ncs] = dual_dict[cs]
                fg.append((ncs,_))
            elif not(fg) and dual_dict: #layout is done. proceed with last uncompleted mirror page
                vars['added_ones'].append(cs)
                mp = self.add_mirror_page()
                for ph, b in zip (reversed(mp.children), [dual_dict[f] for f in vars['added_ones']]):
                    self.set_ph_img(ph,b, use_img_size= False)
            else:
                vars['added_ones'].append(cs)

        Clock.schedule_interval(inner,.05)

Builder.load_file('kv/layout.kv')

from csv import DictReader

Пример #24
0
from kivy.properties import NumericProperty, ObjectProperty, BooleanProperty, StringProperty, ColorProperty
from kivy.uix.widget import Widget
from kivy.base import Builder
Builder.load_file("./kv/arrows.kv")


class Arrow(Widget):
    clr = ColorProperty((1, 2 / 3, 0, 0.8))
    tileTo = ObjectProperty(None, rebind=True)
    tileFrom = ObjectProperty(None, rebind=True)
    vertical = BooleanProperty(False)
    horizontal = BooleanProperty(False)
    diagonal = BooleanProperty(False)
    rotated = BooleanProperty(False)
    # defines the angles function of the horizontal and vertical flip (in this order)
    diagonalAngle = [[45, -45], [135, 225]]


class ArrowKnight(Widget):
    clr = ColorProperty((1, 2 / 3, 0, 0.8))
    tileTo = ObjectProperty(None, rebind=True)
    tileFrom = ObjectProperty(None, rebind=True)
    rotated = BooleanProperty(False)
    angleDict = {
        (1, 2): 0,
        (-2, 1): 90,
        (-1, -2): 180,
        (2, -1): 270,
        (-1, 2): 0,
        (2, 1): 270,
        (1, -2): 180,
Пример #25
0
 def main(self):
     self.Function_page = Builder.load_file(
         "custom_camera/custom_camera.kv")
     camera = CameraWidget()
     self.Function_page.add_widget(camera)
     return self.Function_page
Пример #26
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>:
""")
__author__ = 'Nixon'

from kivy.uix.gridlayout import GridLayout
from kivy.base import Builder
from kivy.uix.screenmanager import Screen
from kivy.uix.listview import ListView, ListItemButton
from kivy.adapters.listadapter import ListAdapter
import database_interface
import display_controller as controller


Builder.load_file('Kivy_Layouts/SettingAreas.kv')


class SettingAreasScreen(Screen):
    pass


class SettingAreasGrid(GridLayout):
    pass


class SettingListGrid(GridLayout):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.add_widget(SettingAreasList())


class SettingAreasList(ListView):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
Пример #28
0
from kivy.metrics import dp
from kivy.core.window import Window
from kivy.utils import platform
from kivy.properties import StringProperty, ListProperty, ReferenceListProperty, NumericProperty, ObjectProperty, BooleanProperty
from kivy.base import Builder
from kivy.app import App
from kivy.config import Config

# other imports
import urllib3
from os.path import join, exists
from os import makedirs
import time

# load the kv file
Builder.load_file('reddress_visuals.kv')

# debugging
if platform == 'win':
    print("DEV mode turned on")
    DEBUG = True
else:
    DEBUG = True


class MainScreenManagerClass(ScreenManager):
    """the main screen manager class"""
    pass


class MainScreenClass(Screen):
Пример #29
0
from scrollview_no_blur import BetterScrollView
import chess
import chess.pgn
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.gridlayout import GridLayout
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.layout import Layout
from kivy.uix.stacklayout import StackLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.uix.scrollview import ScrollView
from kivy.properties import NumericProperty, ObjectProperty, BooleanProperty, StringProperty, ListProperty
from kivy.base import Builder
Builder.load_file("./kv/movelist.kv")


def loadNode(self, touch):
    if self.node is not None and self.controller is not None and self.collide_point(
            touch.pos[0], touch.pos[1]):
        self.controller.updateCurrentNode(self.node)


san_optimizer = {}
dict_optimizer = {}


def get_board(node: chess.pgn.GameNode) -> chess.Board():
    if (node in dict_optimizer):
        return dict_optimizer[node]
    else:
        iter_board = node.end().board()
__author__ = 'Nixon'

from kivy.uix.gridlayout import GridLayout
from kivy.base import Builder
from kivy.uix.screenmanager import Screen
import display_controller as controller

Builder.load_file('Kivy_Layouts/SettingScreen.kv')


class SettingsScreen(Screen):

    def go_to_general(self):
        controller.MANAGER.get_screen("setting_general").children[0].children[0].update()
        controller.MANAGER.transition.direction = 'left'
        controller.MANAGER.current = 'setting_general'


class SettingsGrid(GridLayout):
    pass


class SettingGrid(GridLayout):
    pass


class BackButtonGrid(GridLayout):
    pass
Пример #31
0
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'

""")
Пример #32
0
from urllib import parse
import json
from Crypto.Hash import SHA256, RIPEMD
from Crypto.PublicKey import RSA
from Crypto.Hash import SHA
from Crypto.Cipher import PKCS1_v1_5
from Crypto import Random
import binascii
import base64
from kivy.utils import platform
from util import *
from secp256k1 import PrivateKey, PublicKey
import os

demo_user_names = ('Alice', 'Bob', 'Charlie', 'Mark', 'King', 'Wu', 'Paige')
Builder.load_file('main.kv')  # load *.kv file
default_path = './demo_users.json'
message_path = './messages.json'
block_height = 0
message_hash = set()
contact_map = {}

# read block info
try:
    init_store = JsonStore(message_path)
    if not init_store.exists('block'):  # initialize block info
        init_store.put('block', height=0)
    else:
        block_height = init_store.get('block')['height']
        for i in range(0, block_height):
            msg_hash = init_store[str(i)]['hash']
Пример #33
0
imageStyleDir = "std/"
imageDict = {
    "r": "br.webp",
    "n": "bn.webp",
    "b": "bb.webp",
    "k": "bk.webp",
    "q": "bq.webp",
    "p": "bp.webp",
    "R": "wr.webp",
    "N": "wn.webp",
    "B": "wb.webp",
    "K": "wk.webp",
    "Q": "wq.webp",
    "P": "wp.webp"
}
Builder.load_file("./kv/pieceassets.kv")


def setpos(instance, pos):
    instance.pos = pos


def setsize(instance, size):
    instance.size = size


class ChessPieceWidget(Scatter):
    linkedTile: Optional[Tile] = ObjectProperty(allownone=True, rebind=True)
    source: Optional[str] = StringProperty()

    def __init__(self, linkedTile, src, boardwidget, **kwargs):
Пример #34
0
"""
initialize gui module
"""

import os

# suppress kivy log
os.environ['KIVY_NO_FILELOG'] = '1'
os.environ['KIVY_NO_CONSOLELOG'] = '1'

from kivy.base import Builder

# import gui modules and load kv files to define classes
import gui.balance_chart
import gui.breakdown
import gui.dashboard
import gui.display


Builder.load_file('gui/balance_chart.kv')
Builder.load_file('gui/breakdown.kv')
Builder.load_file('gui/dashboard.kv')
Builder.load_file('gui/display.kv')
Пример #35
0
from kivy.app import App
from kivy.base import Builder
from kivy.uix.label import Label

Builder.load_file('CHLabel.kv')


class CHLabel(Label):
    """中文输入框"""
    pass
Пример #36
0
        def build(self):
            window = Builder.load_string(kv_file)
            Window.bind(on_keyboard=self.on_keyboard)
            self.tryout()

            return window
Пример #37
0
from kivy.app import App
from custom_camera.custom_camera import CameraWidget, CustomCamera

from kivy.base import Builder

Builder.load_file("custom_camera/custom_camera.kv")


class TestCamera(App):
    def build(self):
        camera = CameraWidget()
        return camera


TestCamera().run()
__author__ = 'Nixon'


from kivy.uix.gridlayout import GridLayout
from kivy.base import Builder
from kivy.uix.screenmanager import Screen
from kivy.uix.togglebutton import ToggleButton
from kivy.uix.label import Label
import database_interface as db
import display_controller as controller
from kivy.uix.button import Button

Builder.load_file('Kivy_Layouts/SettingGeneral.kv')


class SettingGeneralScreen(Screen):

    def set_general_settings(self):
        info = controller.MANAGER.get_screen("setting_general").children[-1].children[0]
        for bin_grid in info.children:
            if isinstance(bin_grid, BinGrid):
                if isinstance(bin_grid.children[-1], Label) and len(bin_grid.children) > 2:
                    area = bin_grid.children[-1].text.split(":")[0]
                    area = int(area.split(" ")[-1])
                    if bin_grid.children[0].state == "down":
                        db.update(db.CONFIG.BINS, {'bin':  area}, {'$set': {'display_type': 1}})
                    elif bin_grid.children[1].state == "down":
                        db.update(db.CONFIG.BINS, {'bin':  area}, {'$set': {'display_type': 0}})

        controller.MANAGER.transition.direction = 'right'
        controller.MANAGER.current = "main"

from kivy.uix.gridlayout import GridLayout
from kivy.base import Builder
from kivy.uix.screenmanager import Screen
from kivy.uix.listview import ListView, ListItemButton
from kivy.adapters.listadapter import ListAdapter
import datetime
import database_interface
import display_controller as controller

Builder.load_file('Kivy_Layouts/UpdateBin.kv')


class UpdateBinScreen(Screen):
    def config_bin(self):

        name_list = self.children[0].children[0].children[0]
        type_list = self.children[0].children[0].children[1]

        if len(name_list.adapter.selection) == 0 or len(name_list.adapter.selection) == 0:
            return

        bin_list = controller.MANAGER.get_screen("setting_areas").children[0].children[0].children[0]

        area = bin_list.adapter.selection[0].text.split(":")[0].split(" ")[-1]

        new_bin = dict()
        new_bin['bin'] = int(area)
        new_bin['name'] = name_list.adapter.selection[0].text.lower()
        new_bin['type'] = type_list.adapter.selection[0].text.lower()
Пример #40
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
""")
__author__ = 'Nixon'


from kivy.uix.gridlayout import GridLayout
from kivy.base import Builder
from kivy.uix.screenmanager import Screen
from kivy.uix.listview import ListView, ListItemLabel
from kivy.adapters.listadapter import ListAdapter
import database_interface

Builder.load_file('Kivy_Layouts/AlertScreen.kv')


class AlertScreen(Screen):
    pass


class AlertGrid(GridLayout):
    pass


class MessagesList(ListView):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        concerns = database_interface.get_data(database_interface.DETECTED_CONCERNS, {})
        msgs = list()
        flag = True
        try:
            concerns[0]
        except IndexError:
Пример #42
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
""")

from kivy.uix.gridlayout import GridLayout
from kivy.base import Builder
from kivy.uix.screenmanager import Screen
from kivy.uix.textinput import TextInput
import database_interface
import display_controller as controller
from kivy.uix.label import Label
from kivy.uix.checkbox import CheckBox


Builder.load_file('Kivy_Layouts/UpdateAlert.kv')


class UpdateAlertScreen(Screen):

    def add_alert(self):

        info = controller.MANAGER.get_screen("setting_update_alert").children[0].children[0]
        alarm = dict()
        alarm['description'] = ""
        alarm['type'] = "quantity"
        alarm['flag'] = dict()
        alarm['flag']['max'] = 0
        alarm['flag']['min'] = 0
        alarm['target_bins'] = []

        if len(info.children[-1].text) > 200:
            alarm['description'] = info.children[-1].text[0:200].lstrip().rstrip()
        else: