Пример #1
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):
Пример #2
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 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):
Пример #4
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.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:
Пример #6
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
Пример #7
0
from kivy.app import App
from kivy.base import Builder
from kivy.uix.textinput import TextInput


Builder.load_file('CHTextInput.kv')


class CHTextInput(TextInput):
    """中文输入框"""
    pass

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:
Пример #9
0
from kivy.app import App
from kivy.base import Builder
from kivy.uix.button import Button
from kivy.uix.togglebutton import ToggleButton


Builder.load_file('CHButton.kv')


class CHButton(Button):
    """中文字体按钮"""
    pass


class CHToggleButton(ToggleButton):
    """中文字体按钮"""
    pass
Пример #10
0
import json

from kivy.app import App
from kivy.base import Builder
from kivy.uix.boxlayout import BoxLayout
from CHButton import *
from util import *
from CHLabel import *
from MMMessage import *

Builder.load_file('MessageWidget.kv')


class MessageWidget(BoxLayout):
    """信息缩略图界面"""
    name = ""
    address = ""
    content = ""

    def __init__(self, s_name=None, s_address=None, s_content=None, **kwargs):
        super(MessageWidget, self).__init__(**kwargs)
        self.name = s_name
        self.address = s_address
        self.content = s_content

    def update(self):
        """更新信息内容"""
        if self.name is None:
            self.ids['s_name'].text = '?'
        else:
            self.ids['s_name'].text = self.name
Пример #11
0
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('PublicWidget.kv')


class PublicWidget(BoxLayout):
    """公开信息界面"""
    message_path = ""  # 信息存储位置
    user = ""  # 用户
    contacts = {}  # 联系人地址-姓名对照表

    def __init__(self, user, m_path, contacts, **kwargs):
        """初始化"""
        super(PublicWidget, self).__init__(*kwargs)
        self.user = user
        self.message_path = m_path
        self.contacts = contacts
        self.load_history()

    def load_history(self):
        """加载聊天历史"""
        try:
Пример #12
0
import kivy.uix.widget
import kivy.uix.scrollview
import time
from kivy.properties import ObjectProperty
from kivy.base import Builder
Builder.load_file("./kv/scrollview_no_blur.kv")


class BetterScrollView(kivy.uix.widget.Widget):
    real_scroll_widget: kivy.uix.scrollview.ScrollView = ObjectProperty()

    def add_widget(self, widget, index=0, canvas=None):
        if (self.real_scroll_widget is None):
            return super().add_widget(widget, index, canvas)
        else:
            return self.real_scroll_widget.add_widget(widget, index)

    pass
Пример #13
0
import kivy

from kivy.app import App
from kivy.base import Builder
from kivy.factory import Factory

from file_browser.manager import FileBrowserManager
from table.scroll_view import TableScrollView
from table.size_manager import TableSizeManager

kivy.require('1.10.0')

Builder.load_file('file_browser/dialogs.kv')
Builder.load_file('table/table.kv')

Factory.register('FileBrowserManager', cls=FileBrowserManager)
Factory.register('TableScrollView', cls=TableScrollView)
Factory.register('TableSizeManager', cls=TableSizeManager)


class TableEditorApp(App):
    pass
Пример #14
0
from kivy.uix.image import Image
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.boxlayout import BoxLayout
from kivy.metrics import dp
from kivy.properties import (ObjectProperty, DictProperty, StringProperty,
                             BooleanProperty, ListProperty)

from kivymd.selectioncontrols import (MDCheckbox, MDSwitch)
from kivymd.ripplebehavior import CircularRippleBehavior
from kivymd.button import MDIconButton
from kivymd.list import (ILeftBody, ILeftBodyTouch, IRightBodyTouch,
                         TwoLineAvatarIconListItem, OneLineListItem,
                         OneLineIconListItem, ThreeLineAvatarIconListItem,
                         OneLineAvatarListItem)

Builder.load_file(os.path.join(os.path.dirname(__file__), 'kvs', 'lists.kv'))


class LeftMDIcon(ILeftBodyTouch, MDIconButton):
    pass


class LeftIcon(ILeftBody, Image):
    pass


class Icon(CircularRippleBehavior, ButtonBehavior, Image):
    pass


class RightButton(IRightBodyTouch, Icon):
Пример #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.app import App
from kivy.base import Builder
from kivy.uix.boxlayout import BoxLayout
from CHButton import *

Builder.load_file('UserContact.kv')


class ContactLayout(BoxLayout):
    """联系人卡片布局"""
    default_size = 24
    name = ""
    address = ""
    pubkey = ""

    def __init__(self, u_name=None, u_address=None, u_pubkey=None, **kwargs):
        super(ContactLayout, self).__init__(**kwargs)
        self.name = u_name
        self.address = u_address
        self.pubkey = u_pubkey

    def update(self):
        """更新联系人卡片显示"""
        self.ids['u_name'].text = self.name
        self.ids['u_address'].text = self.address
        self.ids['u_pubkey'].text = self.pubkey

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:
Пример #18
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)
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):
Пример #20
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
Пример #21
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
__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

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()
__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)


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)
Пример #26
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
Пример #27
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,
Пример #28
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
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:
Пример #30
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

__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
Пример #32
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
Пример #33
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']
__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)
Пример #35
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')
Пример #36
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
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"
Пример #38
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):
Пример #39
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

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: