Example #1
1
    def test_widget_root_from_code_with_kv(self):
        from kivy.lang import Builder
        from kivy.factory import Factory
        from kivy.properties import ObjectProperty, StringProperty
        from kivy.uix.floatlayout import FloatLayout
        
        Builder.load_string("""
<MyWidget>:
    Label:
        text: root.title
        
<BaseWidget>:
    CallerWidget:
""")
        
        class CallerWidget(FloatLayout):
            def __init__(self, **kwargs):
                super(CallerWidget, self).__init__(**kwargs)
                self.add_widget(MyWidget(title="Hello World"))
            
        class NestedWidget(FloatLayout):
            title = StringProperty('aa')
            
        class MyWidget(NestedWidget):
            pass
        
        class BaseWidget(FloatLayout):
            pass
        
        Factory.register('MyWidget', cls=MyWidget)
        Factory.register('CallerWidget', cls=CallerWidget)

        r = self.render
        root = BaseWidget()
        r(root)
Example #2
0
    def test_list_view_declared_in_kv_with_adapter(self):
        from kivy.lang import Builder
        from kivy.uix.modalview import ModalView
        from kivy.uix.widget import Widget
        from kivy.factory import Factory
        from kivy.properties import StringProperty, ObjectProperty, BooleanProperty

        Builder.load_string(
            """
#:import label kivy.uix.label
#:import sla kivy.adapters.simplelistadapter

<ListViewModal>:
    size_hint: None,None
    size: 400,400
    lvm: lvm
    ListView:
        id: lvm
        size_hint: .8,.8
        adapter:
            sla.SimpleListAdapter(
            data=["Item #{0}".format(i) for i in xrange(100)],
            cls=label.Label)
"""
        )

        class ListViewModal(ModalView):
            def __init__(self, **kwargs):
                super(ListViewModal, self).__init__(**kwargs)

        list_view_modal = ListViewModal()

        list_view = list_view_modal.lvm

        self.assertEqual(len(list_view.adapter.data), 100)
Example #3
0
 def build(self):
     Builder.load_string(textwrap.dedent(
     '''
         <CustomButtonClass@Button>:
             description_a: ''
             description_b: ''
             text: root.description_a + ' <newline> ' + root.description_b
             halign:'center'
             size_hint:(1, 0.1)
         <MyListView>:
             size_hint:(0.5, 0.5)
             ListView:
                 item_strings: [str(index) for index in range(10)]
         <OtherNamedScreen>:
             GridLayout:
                 cols: 2
                 MyListView
                 ScrollView:
                     ContainerForButtons:
                         cols:1
                         row_default_height:150
                         size_hint_y: None
     '''))
     Window.bind(on_keyboard=self.check_what_key_was_pressed)
     self.screen_mgr = ScreenManager()
     first = Screen(name='First')
     self.screen_mgr.add_widget(first)
     first.add_widget(Button(text="click me", bind=self.swap_screen))
     self.screen_mgr.add_widget(OtherNamedScreen(name='Second'))
     return self.screen_mgr
Example #4
0
	def __init__(self, **kwargs):
		Builder.load_string(materiallbl_kv)
		super(MaterialLabel, self).__init__(**kwargs)
		self.bind(theme_text_color=self._update_color,
				  theme_style=self._update_color,
				  text_color=self._update_color)
		self.theme_style = self._theme_cls.theme_style
Example #5
0
    def test_kv_python_init(self):
        from kivy.lang import Builder, Factory
        from kivy.uix.widget import Widget

        class MyObject(object):
            value = 55

        class MyWidget(Widget):
            cheese = MyObject()

        Builder.load_string('''
<MyWidget>:
    x: 55
    y: self.width + 10
    height: self.cheese.value
    width: 44

<MySecondWidget@Widget>:
    x: 55
    Widget:
        x: 23
''')

        w = MyWidget(x=22, height=12, y=999)
        self.assertEqual(w.x, 22)
        self.assertEqual(w.width, 44)
        self.assertEqual(w.y, 44 + 10)
        self.assertEqual(w.height, 12)

        w2 = Factory.MySecondWidget(x=999)
        self.assertEqual(w2.x, 999)
        self.assertEqual(w2.children[0].x, 23)
Example #6
0
    def update_serial_choices(self, *largs):
        extra_mac_ports = set(glob.glob('/dev/tty.usbserial*'))
        new_serial_choices = set([port for port, _, _ in comports()])
        for i_hate_macs in extra_mac_ports:
            new_serial_choices.add(i_hate_macs)

        if not sets_equal(self.last_serial_choices, new_serial_choices):
            self.indicators.serial_choices.clear_widgets()
            self.last_serial_choices = new_serial_choices
            for port in sorted(list(new_serial_choices)):
                port_name = port
                if port_name.startswith('/dev/'):
                    port_name = port[5:]
                btn = Builder.load_string('''
CheckBox:
    size_hint_y: 1
    group: 'serial_choice_group'
                ''')
                lbl = Builder.load_string('''
SaneLabel:
    size_hint_y: 1
    text: '%s'
                ''' % (port_name,))
                btn.bind(active=self.on_serial_choice)
                btn.port = port
                if self.serial is not None and self.serial.port == port:
                    btn.active = True
                self.indicators.serial_choices.add_widget(btn)
                self.indicators.serial_choices.add_widget(lbl)
Example #7
0
def make_button_class(class_name, img_up, img_down, img_path, color_down='000000', color_up='000000', color_dis='000000'):
    template = """
<{cls}@RemoteKey>:
    canvas:
        Clear
        Color:
            rgb: self.hextorgb('{bgdis}' if self.disabled else '{bgup}')
        RoundedRectangle:
            size: self.size
            pos: self.pos
    bgup: '{bgup}'
    bgdown: '{bgdn}'
    bgdis: '{bgdis}'
    #background_normal: 'img/white.png'
    #background_down: ''#''
    border: 0,0,0,0
    Image:
        id: btnimg
        source: '{btnimg}'
        y: self.parent.y
        x: self.parent.x
        size: self.parent.size
        mipmap: True
""".format(cls=class_name, bgup=color_up, bgdn=color_down, bgdis=color_dis,
           btnimg=('{}/{}.png'.format(img_path, img_up) if img_up != '' else ''))
    Builder.load_string(template)
def start():
    for font in G.kivy_fonts:
        LabelBase.register(**font)
    Window.size = (900, 600)
    Builder.load_string(kv_text)

    G.app = ScrollApp()
    G.app.run()
Example #9
0
 def test_apply_rules(self):
     Builder = self.import_builder()
     Builder.load_string('<TestClassCustom>:\n\tobj: 42')
     wid = TestClass()
     Builder.apply(wid)
     self.assertIsNone(wid.obj)
     Builder.apply_rules(wid, 'TestClassCustom')
     self.assertEqual(wid.obj, 42)
Example #10
0
				def _update_main_console( self ,
										  count ,
										  threaded = False ,
										  func = None ,
										  moniker = None ,
										  edit = False
										  ) :
					"""

					:return:
					"""



					self.ids.cci_action_prev.title = 'king console(' + str( count ) + ')'

					carousel = self.ids.maelstrom_carousel_id
					layout = GridLayout( cols = 1 ,
										 padding = [0 , 5 , 0 ,5]
										  )
					App.get_running_app()._console_count += 1
					layout.add_widget( Label( text = moniker  + str( App.get_running_app()._console_count ),
											color = [ 1, 0 , 0 , 1] ,
											font_size = 14 ,
											id = 'content' ,
											size_hint_y = 0.1 ) )
					# console text
					if edit :
						scrolly = Builder.load_string( self._retr_resource( 'note_scroller' ) )
					else :
						scrolly = Builder.load_string( self._retr_resource( 'text_scroller' ) )
					tx = scrolly.children[0]
					if edit :
						tx.text = ''
						tx.readonly = False
						tx.cursor_blink = True
						tx.background_color =  [0,0,0,0]
						tx.foreground_color =  [1,1,1,1]
						tx.font_size  = 16
					else :
 						tx.text = 'standby...working...'
					self._console_text = tx
					#scrollbox
					layout.add_widget( scrolly )
					#footer
					layout.add_widget( Label( text = datetime.datetime.now().strftime( "%Y-%m-%d %H:%M:%S" )   ,
											font_size = 16  ,
											size_hint_y = 0.2 ,
											color = [ 1, 0 , 0 , 1] ) )
					carousel.add_widget( layout )
					carousel.index = len( carousel.slides ) - 1
					self.canvas.ask_update()

					if threaded :
						func( carousel.slides[carousel.index] )
						return
					return carousel.slides[carousel.index]
Example #11
0
    def remake_display(self, *args):
        """Remake any affected widgets after a change in my ``kv``.

        """
        Builder.load_string(self.kv)
        if hasattr(self, '_kv_layout'):
            self.remove_widget(self._kv_layout)
            del self._kv_layout
        self._kv_layout = KvLayout()
        self.add_widget(self._kv_layout)
Example #12
0
        def build(self):

            Builder.load_string(kvdemo)
            android_tabs = AndroidTabs()

            for n in range(1, 6):
                tab = MyTab(text='TAB %s' % n)
                android_tabs.add_widget(tab)

            return android_tabs
Example #13
0
    def build(self):
        file_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'screens', 'boot.kv'))
        print(file_path)
        with open(file_path, 'r', encoding='utf8') as f:
            Builder.load_string(f.read())
        sr = ScreenRoot()
        sm = sr.ids.sm
        sm.add_widget(top.TopScreen(name='top'))
        # TODO add screens

        return sr
Example #14
0
 def test_loading_failed_1(self):
     # invalid indent
     Builder = self.import_builder()
     from kivy.lang import ParserError
     try:
         Builder.load_string('''#:kivy 1.0
         <TestClass>:
         ''')
         self.fail('Invalid indentation.')
     except ParserError:
         pass
Example #15
0
    def test_complex_rewrite(self):
        # this test cover a large part of the lang
        # and was used for testing the validity of the new rewrite lang
        # however, it's not self explained enough :/

        from kivy.lang import Builder
        from kivy.uix.widget import Widget
        from kivy.uix.label import Label
        from kivy.factory import Factory
        from kivy.properties import StringProperty, ObjectProperty, \
            BooleanProperty

        Builder.load_string(rules)

        class TestWidget(Widget):
            source = StringProperty('')
            source2 = StringProperty('')
            source3 = StringProperty('')
            can_edit = BooleanProperty(False)

            def __init__(self, **kwargs):
                self.register_event_type('on_release')
                super(TestWidget, self).__init__(**kwargs)

            def on_release(self):
                pass

        class MainWidget(Widget):
            refwid = ObjectProperty(None)
            refwid2 = ObjectProperty(None)

        class TestWidget2(Widget):
            pass

        class CustomLabel(Label):
            pass

        Factory.register('CustomLabel', cls=CustomLabel)
        Factory.register('TestWidget', cls=TestWidget)
        Factory.register('TestWidget2', cls=TestWidget2)

        a = MainWidget()
        self.assertTrue(isinstance(a.refwid, TestWidget))
        self.assertEqual(a.refwid.source, 'valid.png')
        self.assertEqual(a.refwid.source2, 'valid.png')
        self.assertEqual(a.refwid.source3, 'valid.png')
        self.assertTrue(len(a.refwid.children) == 1)
        self.assertEqual(a.refwid.children[0].title, 'valid')
        self.assertTrue(isinstance(a.refwid2, TestWidget2))
        self.assertEqual(a.refwid2.source, 'valid.png')
Example #16
0
				def _show_payload_dialog( self , title , content , params ) :
					"""

					:param content:
					:param params:
					:return:
					"""

					layout = GridLayout( cols = 1 ,
											 padding = [0 , 5 , 0 ,5] , size = (480 , 600 )
											  )
					layout.add_widget( Label( text = params  ,
											  color = [ 1, 0 , 0 , 1] ,
											  #font_size = 14 ,
											  size_hint_y = 0.1 ) )

					scrolly = Builder.load_string( self._retr_resource( 'text_scroller' ) )
					tx = scrolly.children[0]
					tx.text = content
					tx.readonly = False

					layout.add_widget( scrolly )
					layout.add_widget( Label( text =  datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S" )  ,
											#font_size = 14  ,
											size_hint_y = 0.2 ,
											color = [ 1, 0 , 0 , 1] ) )
					popup = ConsolePopup( title=title , content = layout , size_hint=(None, None), size=( 480 , 500 ) )

					popup.open()
Example #17
0
 def build(self):
     """   Called by kivy run().  """
     print("** inside build()")
     widget = Builder.load_string(
         "Button:\n  text: 'hello from TestKVStringApp'")
     print("** widget built")
     return widget
Example #18
0
def add_console( self ,
				  parent ,
				  content ,
				  console_count ,
				  tag  ) :
				"""
				:param parent:
				:param content:
				:param: console_count:
				:param tag:

				:return:
				"""

				layout = GridLayout( cols = 1 ,
									 padding = [0 , 5 , 0 ,5]
									  )
				self._console_count += 1
				layout.add_widget( Label( text = tag + str( console_count ) ,
										color = [ 1, 0 , 0 , 1] ,
										font_size = 16 ,
										size_hint_y = 0.1 ) )

				scrolly = Builder.load_string( self._retr_resource( 'text_scroller' ) )
				tx = scrolly.children[0]
				tx.text = content
				layout.add_widget( scrolly )
				layout.add_widget( Label( text = strftime("%Y-%m-%d %H:%M:%S", gmtime()) ,
										font_size = 16  ,
										size_hint_y = 0.2 ,
										color = [ 1, 0 , 0 , 1] ) )
				parent.add_widget( layout )
    def __init__(self, **kwargs):
        super(GreeterApp, self).__init__(**kwargs)
        self.password = ""
        self.session = ""
        
        # Connect to lightDM
        install_gobject_iteration()
        self.greeter = LightDM.Greeter()
        self.greeter.connect("authentication-complete", self.authentication_complete_cb)
        self.greeter.connect("show-prompt", self.show_prompt_cb)
        self.greeter.connect_sync()
        
        # Get all available sessions
        available_sessions = []
        for sess in LightDM.get_sessions():
            available_sessions.append(LightDM.Session.get_key(sess))
        
        # Get all available users
        available_users = []
        inst = LightDM.UserList.get_instance()
        for user in LightDM.UserList.get_users(inst):
            user_name = LightDM.User.get_name(user)
            available_users.append(user_name)

        self.root_widget = Builder.load_string(kv)
        self.root_widget.username_spinner.values = available_users
        self.root_widget.session_spinner.values = available_sessions
Example #20
0
    def build(self):
        from kivy.garden.smaa import SMAA

        Window.bind(on_keyboard=self._on_keyboard_handler)

        self.smaa = SMAA()
        self.effects = [self.smaa, Widget()]
        self.effect_index = 0
        self.label = Label(text='SMAA', top=Window.height)
        self.effect = effect = self.effects[0]
        self.root = FloatLayout()
        self.root.add_widget(effect)

        if 0:
            from kivy.graphics import Color, Rectangle
            wid = Widget(size=Window.size)
            with wid.canvas:
                Color(1, 1, 1, 1)
                Rectangle(size=Window.size)
            effect.add_widget(wid)

        if 1:
            #from kivy.uix.image import Image
            #root.add_widget(Image(source='data/logo/kivy-icon-512.png',
            #                      size=(800, 600)))

            filenames = sys.argv[1:]
            if not filenames:
                filenames = glob(join(dirname(__file__), '*.svg'))

            for filename in filenames:
                svg = SvgWidget(filename)
                effect.add_widget(svg)

            effect.add_widget(self.label)
            svg.scale = 5.
            svg.center = Window.center

        if 0:
            wid = Scatter(size=Window.size)
            from kivy.graphics import Color, Triangle, Rectangle
            with wid.canvas:
                Color(0, 0, 0, 1)
                Rectangle(size=Window.size)
                Color(1, 1, 1, 1)
                w, h = Window.size
                cx, cy = w / 2., h / 2.
                Triangle(points=[cx - w * 0.25, cy - h * 0.25,
                                 cx, cy + h * 0.25,
                                 cx + w * 0.25, cy - h * 0.25])
            effect.add_widget(wid)

        if 0:
            from kivy.uix.button import Button
            from kivy.uix.slider import Slider
            effect.add_widget(Button(text='Hello World'))
            effect.add_widget(Slider(pos=(200, 200)))

        control_ui = Builder.load_string(smaa_ui)
        self.root.add_widget(control_ui)
Example #21
0
    def _get_body(self):
        from kivy.lang import Builder
        import textwrap
        self.browser = Builder.load_string(textwrap.dedent('''\
        FileChooser:
            FileChooserIconLayout
            FileChooserListLayout
        '''))

        self.browser.path = self.path
        self.browser.multiselect = self.multiselect
        self.browser.dirselect = self.dirselect
        self.browser.filters = self.filters
        self.browser.bind(path=self.setter('path'),
                          selection=self.setter('selection'))
        self.bind(view_mode=self.browser.setter('view_mode'),
                  multiselect=self.browser.setter('multiselect'),
                  dirselect=self.browser.setter('dirselect'),
                  filters=self.browser.setter('filters'))

        lbl_path = Factory.XLabel(
            text=self.browser.path, valign='top', halign='left',
            size_hint_y=None, height=metrics.dp(25))
        self.browser.bind(path=lbl_path.setter('text'))

        layout = BoxLayout(orientation='vertical')
        layout.add_widget(self._ctrls_init())
        layout.add_widget(lbl_path)
        layout.add_widget(self.browser)
        return layout
 def build(self):
     self.settings_cls = MySettingsWithTabbedPanel
     root = Builder.load_string(kv)
     label = root.ids.label
     label.text = self.config.get('My Label', 'text')
     label.font_size = float(self.config.get('My Label', 'font_size'))
     return root
Example #23
0
    def build(self):
        self.root = Builder.load_string(kv)
        counter = 0
        
        for i in IMAGES:            
            image = Image(source=IMAGEDIR + i, size=(100, 100),
                          size_hint=(None, None))
            draggable = DraggableImage(img=image, app=self,
                                       size_hint=(None, None), pos_hint={'x': 0, 'center_y': .5},
                                       size=(100, 100))
            
            empty_image = Image(source="empty_square.png", size=(100, 100),
                          size_hint=(None, None))
            empty_draggable = DraggableImage(img=empty_image, app=self,
                                       size_hint=(None, None), pos_hint={'x': 0, 'center_y': .5},
                                       size=(100, 100))   
 
            if counter < 9:
                self.root.ids.dealer_layout.add_widget(empty_draggable)
            elif counter <= 17:
                self.root.ids.player_layout.add_widget(empty_draggable) 
            elif counter <= 22:
                self.root.ids.new_cards_layout.add_widget(draggable)  
            
            if counter == 22:
                break 
               
            counter += 1
            
        return self.root
Example #24
0
 def build(self):
     # conexao UDP com os tratores
     self.conexao = Echo (self)
     reactor.listenMulticast (10000, self.conexao, listenMultiple = True)
     # escreve os logs a cada 10 segundos, pra nao perder
     Clock.schedule_interval (self.conexao.writeLogs, 10)
     return Builder.load_string(kv)
    def show_file_chooser(self):
        # update data_file_dir here
        pop = Builder.load_string('''
Popup
    title: 'Select data flie dir'
    BoxLayout
        padding: dp(9)
        spacing: dp(20)
        orientation: 'vertical'
        FileChooserIconView
            id: fl
            filters: ['*.']
            path: '/mnt/sdcard/'
            # dirselect: True
            #filter_dirs: True
        BoxLayout
            spacing: dp(9)
            size_hint_y: None
            height: dp(36)
            ActiveButton
                text: 'Select'
                on_release:
                    app.screenregister.data_file_dir = fl.path
                    root.dismiss()
            ActiveButton
                text: 'Cancel'
                on_release: root.dismiss()
''')
        pop.ids.fl.path = self.data_file_dir
        pop.open()
    def test_instantiate_from_kv_with_child(self):
        from kivy.lang import Builder

        class TestEventsFromKVChild(TrackCallbacks.get_base_class()):
            instantiated_widgets = []

        widget = Builder.load_string(textwrap.dedent("""
        TestEventsFromKVChild:
            events_in_post: [1, 2]
            on_kv_pre: self.add(2, 'pre')
            on_kv_applied: self.add(2, 'applied')
            on_kv_post: self.add(2, 'post')
            root_widget: self
            base_widget: self
            name: 'root'
            my_roots_expected_ids: {'child_widget': child_widget}
            TestEventsFromKVChild:
                events_in_post: [1, 2]
                on_kv_pre: self.add(2, 'pre')
                on_kv_applied: self.add(2, 'applied')
                on_kv_post: self.add(2, 'post')
                root_widget: root
                base_widget: root
                name: 'child'
                id: child_widget
                my_roots_expected_ids: {'child_widget': self}
        """))

        self.assertIsInstance(widget, TestEventsFromKVChild)
        widget.check(self)
Example #27
0
        def build(self):
            return Builder.load_string("""#:import MDSlider kivymd.slider.MDSlider
BoxLayout:
    orientation:'vertical'
    padding: '8dp'
    MDSlider:
        id:slider
        min:0
        max:100
        value: 40
        
    MDProgressBar:
        value: slider.value
    MDProgressBar:
        reversed: True
        value: slider.value
    BoxLayout:
        MDProgressBar:
            orientation:"vertical"
            reversed: True
            value: slider.value
            
        MDProgressBar:
            orientation:"vertical"
            value: slider.value
        
""")
				def _on_test_connect( self ) :
							"""

							:return:
							"""


							layout = GridLayout( orientation = 'horizontal' ,
											  cols = 1 ,
											  background_color = [0,0,0,0])
							action_bar = Builder.load_string( self._retr_resource( 'dlg_action_bar_3' ) )
							layout.add_widget( action_bar )
							img = Image( source = './image/kafka-logo.png' , size_hint_y = .15)
							scroll = ScrollView( id = 'scrlv' )
							grid = GridLayout( cols=1 , orientation = 'horizontal' , size_hint_y = None , size=(400 , 500 ) )
							grid.add_widget( img  )
							vx =  TextInput(
											text = '',
											background_color = [0,0,0,0] ,
											foreground_color =  [1,1,1,1] ,
											multiline = True ,
											font_size =  16 ,
											readonly =  True  )
							#vx.height = max( (len(vx._lines)+1) * vx.line_height, scroll.height )
							grid.add_widget( vx )
							scroll.add_widget( grid )
							layout.add_widget( scroll )

							popup = screen.ConsolePopup( title='kafka connect' , content = layout )
							b = popup.content.children[1].children[0].children[0]
							b.text = 'test connect'
							b.bind( on_press = lambda a:self._show_info( vx ) )
							popup.open()
Example #29
0
    def test_invalid_childname_before(self):
        from kivy.lang import Builder, ParserException
        try:
            Builder.load_string('''
Widget:
    thecursor.Cursor:
    FloatLayout:
        size: self.parent.size
        Button:
            text: "text"
            size_hint:(0.1, 0.1)
            pos_hint:{'x':0.45, 'y':0.45}
            ''')
            self.fail('Invalid children name')
        except ParserException:
            pass
Example #30
0
 def __init__(self, **kwargs):
     self._win = None
     if 'min_state_time' not in kwargs:
         self.min_state_time = float(
             Config.get('graphics', 'min_state_time'))
     if 'container' not in kwargs:
         c = self.container = Builder.load_string(_grid_kv)
     else:
         c = None
     if 'allow_sides' not in kwargs:
         self.allow_sides = False
     if 'do_scroll_x' not in kwargs:
         self.do_scroll_x = False
     if 'size_hint' not in kwargs:
         if 'size_hint_x' not in kwargs:
             self.size_hint_x = None
         if 'size_hint_y' not in kwargs:
             self.size_hint_y = None
     super(DropDown, self).__init__(**kwargs)
     if c is not None:
         super(DropDown, self).add_widget(c)
         self.on_container(self, c)
     Window.bind(
         on_key_down=self.on_key_down,
         size=self._reposition)
     self.fbind('size', self._reposition)
Example #31
0
from kivy.uix.label import Label
from kivy.uix.image import Image

from kivy.lang import Builder

from kivy.base import runTouchApp

Builder.load_string("""
<RootWidget>:
    text: "THE BACKGROUND"
    font_size: 150
    Image: 
        source: "colours.png"
        allow_stretch: True
        keep_ratio: False
    Image: 
        source: "colours2.png"
        allow_stretch: True
        keep_ratio: False
    Image: 
        source: "colours.png"
        allow_stretch: True
        keep_ratio: False
""")


class RootWidget(Label):

    def do_layout(self, *args):
        number_of_children = len(self.children)
        width = self.width
Example #32
0
)
from kivy.uix.anchorlayout import AnchorLayout
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.modalview import ModalView

from kivymd import images_path, uix_path
from kivymd.theming import ThemableBehavior
from kivymd.uix.behaviors import CircularRippleBehavior
from kivymd.uix.boxlayout import MDBoxLayout
from kivymd.uix.list import BaseListItem, ContainerSupport
from kivymd.uix.relativelayout import MDRelativeLayout
from kivymd.utils.fitimage import FitImage

with open(os.path.join(uix_path, "filemanager", "filemanager.kv"),
          encoding="utf-8") as kv_file:
    Builder.load_string(kv_file.read())


class BodyManager(MDBoxLayout):
    """
    Base class for folders and files icons.
    """


class BodyManagerWithPreview(MDBoxLayout):
    """
    Base class for folder icons and thumbnails images in ``preview`` mode.
    """


class IconButton(CircularRippleBehavior, ButtonBehavior, FitImage):
Example #33
0
Builder.load_string('''

<ThumbnailedGrid@ButtonBehavior+BoxLayout+SelectableView> 
        aa_label: aa_label
        ab_label: ab_label
        ba_label: ba_label
        bb_label: bb_label
        entry_image: entry_image
        canvas.before:
                Color:
                        rgba: .200,.200,.200,1
                Rectangle:
                        pos: self.pos
                        size: self.size
        padding: 3
        index: self.index
        height: self.height
        text: self.text
        GridLayout:
                cols:2
                Image:
                        id: entry_image
                        source: root.thumb
                        height: 30
                        size_hint_x:1

                GridLayout:
                        size_hint_x:2
                        canvas.before:
                                Color:
                                        rgba: .150,.150,.150,1
                                Rectangle:
                                        pos: self.pos
                                        size: self.size
                        cols:2
                        rows:2
                        Label:
                                id: aa_label
                                font_size: 10
                                text: root.entry_name
                        Label:
                                id: ab_label
                                font_size: 10
                                text: root.number

                        Label:
                                id: ba_label
                                font_size: 10
                                text: root.length
                        Label:
                                id: bb_label
                                font_size: 10
                                text: root.date


<DownloadItem@BoxLayout+SelectableView>
        size_hint_y: .2
		download_progress_bar: download_progress_bar
        canvas.before:
                Color:
                        rgba: .200,.200,.200,1
                Rectangle:
                        pos: self.pos
                        size: self.size

        BoxLayout:
                orientation: "horizontal"	
                Image:
                        source: root.thumb
                BoxLayout:
                        padding: 5
                        orientation: "vertical"
                        Label:
                                font_size: 10
                                text: root.name
                        Label: 
                                text: root.length
                                font_size: 10
                        ProgressBar:
                                id: download_progress_bar
                                max: 1
                                value: 0



''')
Example #34
0
 def build(self):
     return Builder.load_string(KV)
Example #35
0
import math
from physics import phy
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.widget import Widget
from kivy.clock import Clock
from kivy.properties import ListProperty
from kivy.uix.scatter import ScatterPlane
from kivy.graphics import Color, Rectangle, Ellipse

GRAVITY = 0, 0

Builder.load_string('''
#place kivy notation of app here
''')


class GraphicalObject(object):
    def __init__(self, **kw):
        self.widget = self.create_widget(**kw)

    def create_widget(self):
        ''' Should be implemented in subclass '''
        raise NotImplemented


class PhysicalObject(GraphicalObject):
    def __init__(self, world, mass, pos=(0, 0), **kw):
        ''' Create a physical object inside of the space '''
        super(PhysicalObject, self).__init__(**kw)
        self.world = world
Example #36
0
 def build(self):
     return Builder.load_string(codigo)
Example #37
0
Builder.load_string('''
#:import os os
<WalletDialog@Popup>:
    title: _('Wallets')
    id: popup
    path: os.path.dirname(app.get_wallet_path())
    BoxLayout:
        orientation: 'vertical'
        padding: '10dp'
        FileChooserListView:
            id: wallet_selector
            dirselect: False
            filter_dirs: True
            filter: '*.*'
            path: root.path
            rootpath: root.path
            size_hint_y: 0.6
        Widget
            size_hint_y: 0.1
        GridLayout:
            cols: 3
            size_hint_y: 0.1
            Button:
                id: open_button
                size_hint: 0.1, None
                height: '48dp'
                text: _('New')
                on_release:
                    popup.dismiss()
                    root.new_wallet(app, wallet_selector.path)
            Button:
                id: open_button
                size_hint: 0.1, None
                height: '48dp'
                text: _('Open')
                disabled: not wallet_selector.selection
                on_release:
                    popup.dismiss()
                    root.open_wallet(app)
''')
Example #38
0
    IRightBodyTouch,
    OneLineAvatarIconListItem,
    ThreeLineAvatarIconListItem,
    TwoLineAvatarIconListItem,
)

Builder.load_string("""
<MDExpansionChevronRight>:
    icon: "chevron-right"
    disabled: True
    md_bg_color_disabled: 0, 0, 0, 0

    canvas.before:
        PushMatrix
        Rotate:
            angle: self._angle
            axis: (0, 0, 1)
            origin: self.center
    canvas.after:
        PopMatrix


<MDExpansionPanel>
    size_hint_y: None
    # height: dp(68)
""")


class MDExpansionChevronRight(IRightBodyTouch, MDIconButton):
    """Chevron icon on the right panel."""

    _angle = NumericProperty(0)
Example #39
0
Builder.load_string("""
<Chart>:
    background_color:0,0,0,0
    x_ticks_minor:2
    y_ticks_minor:2
    x_ticks_major:2
    y_ticks_major:20
    y_grid_label:True
    x_grid_label:True
    x_grid:False
    y_grid:False
    ylabel:"tps"
    xlabel:"rpm x 1000"
    xmin:0
    xmax:12
    ymin:0
    ymax:100
    border_color:0,0,0,0
    tick_color:0,1,1,1
    color:0,1,1,1
<LineCircle@FloatLayout>:
    angle_end:0
    angle_start:360
    tebal:1.5
    warna:0,1,1,1
    pos_hint:{"center_x":.5,"center_y":.5}
    canvas:
        Color:
            rgba:root.warna
        Line:
            width:root.tebal
            circle:
                (self.center_x, self.center_y, min(self.width, self.height)
                / 2,root.angle_start,root.angle_end)
<Dial@FloatLayout>:
    pos_hint:{"center_x":.5,"center_y":.5}
    LineCircle:
        pos_hint:{"center_x":.5,"center_y":.5}
        angle_start:220
        angle_end:220+50
        LineCircle: 
            pos_hint:{"center_x":.5,"center_y":.5}
            size_hint:.9,.9
            LineCircle
                tebal:1
                size_hint:.9,.9
                Label:
                    text:"14000"
                    font_name:"fonts/fish.ttf"
                    font_size:self.height/3
                    color:0,1,1,1
                    pos_hint:{"center_x":.5,"center_y":.5}
                Label:
                    text:"RPM"
                    font_name:"fonts/batmfa.ttf"
                    font_size:self.height/8
                    color:0,1,1,1
                    pos_hint:{"center_x":.5,"center_y":.8}
        
<LineVer@Label>:
    size_hint:1,None
    pos_hint:{"center_x":.5,"center_y":.5}
    height:"1sp"
    canvas:
        Color
            rgba:0,1,1,1
        Rectangle:
            size:self.size
            pos:self.pos
<LineHor@Label>:
    size_hint:None,1
    width:"1sp"
    canvas:
        Color
            rgba:0,1,1,1
        Rectangle:
            size:self.size
            pos:self.pos

<Dash>:
    size_hint:.99,.99
    pos_hint:{"center_x":.5,"center_y":.5}
    canvas:
        Color:
            rgba: 0,1,1,1
        Line:
            width: 1
            rectangle: (self.x, self.y, self.width, self.height)
    BoxLayout:
        pos_hint:{"center_x":.5,"center_y":.5}
        orientation:"vertical"
        Label:
            text:"sooko.io"
            font_name:"fonts/hemi.ttf"
            font_size:self.height/1.2
            halign:"left"
            valign:"top"
            text_size:self.size
            color:0,1,1,1
            size_hint:1,.1
        BoxLayout
            pos_hint:{"center_x":.5,"center_y":.5}
            padding:2
            BoxLayout:
                size_hint:.2,1
                orientation:"vertical"
                BoxLayout:
                    orientation:"vertical"
                    Label
                        size_hint:1,.091
                        text:" DATA LOGER"
                        font_size:self.height/1.8
                        font_name:"fonts/cn.ttf"
                        color:0,1,1,1
                        halign:"left"
                        text_size:self.size
                        valign:"middle"
                    ScrollView:
                        size_hint:.9,1
                        pos_hint:{"right":1}
                        Label:
                            id:lbl
                            size_hint:1,1.5
                            pos_hint:{"right":1}
                            text:root.dataloger
                            text_size:self.size
                            halign:"left"
                            valign:"top"
                            font_name:"fonts/consola.ttf"
                            font_size:self.height/27
                            color:0,1,1,1
                            readonly:True
                            foreground_color:0,1,1,1
                            background_color:0,0,0,0
            
            BoxLayout:
                orientation:"vertical"
                BoxLayout:
                    FloatLayout
                        size_hint:.8,1
                        Dial
                            size_hint:1,.8
                            pos_hint:{"center_x":.5,"top":1}
                    BoxLayout:
                        orientation:"vertical"
                        FloatLayout:
                            id:gr
                            GraphTabel:
                                pos_hint:{"center_x":.5,"center_y":.5}
                                id:chart
                        Label
                            size_hint:1,.4

""")
Builder.load_string('''
# Define your background color Template
<BackgroundColor@Widget>
    background_color: 1, 1, 1, 1
    canvas.before:
        Color:
            rgba: root.background_color
        Rectangle:
            size: self.size
            pos: self.pos
# Now you can simply Mix the `BackgroundColor` class with almost
# any other widget... to give it a background.
<BackgroundLabel@Label+BackgroundColor>
    background_color: 0, 0, 0, 0
    # Default the background color for this label
    # to r 0, g 0, b 0, a 0
    
<EnvironmentWidget>:
    size: (340, 100)
    size_hint: (None, None)

    canvas:
        # Border rect
        Color:
            rgba: root.base_color
        Line:
            rounded_rectangle: (2, 2, self.size[0]-4, self.size[1]-4, 20)
            width: 2 

    BoxLayout:
        orientation: 'vertical'
        size: (240, 240)
        padding: 10
        spacing: 10

        BoxLayout:
            orientation: 'horizontal'
            spacing: 10
            size_hint: (1, 1)
            
            Image:
                source: 'resources/temperature.png'
                color: root.temperature_label_color
                size_hint: (None, 0.8)
                size: (64, 64)            
    
            Label:
                text: '--' if root.temperature is None else root.temperature 
                color: root.temperature_value_color
                font_size: 40
                font_name: 'resources/FiraMono-Regular.ttf'    
    
            Label:
                text: '°C' 
                color: root.temperature_value_color
                font_size: 24
                halign: 'center'
                valign: 'top'
                size: (48, 48)
                text_size: self.size
                size_hint: (None, 1)
    
            Label:
                size_hint: (0.2, None)
    
            Image:
                source: 'resources/humidity.png'
                color: root.humidity_label_color
                size_hint: (None, 0.8)
                size: (64, 64)            
    
            Label:
                text: '--' if root.humidity is None else root.humidity 
                color: root.humidity_value_color
                font_size: 40
                font_name: 'resources/FiraMono-Regular.ttf'    
    
            Label:
                text: '%' 
                color: root.humidity_value_color
                font_size: 24
                halign: 'center'
                valign: 'top'
                size: (48, 48)
                text_size: self.size
                size_hint: (None, 1)
            
        BoxLayout:
            orientation: 'horizontal'
            size_hint: (1, 0.2)
            spacing: 2
            
            Label:
                size_hint: (0.2, 1)
            
            BackgroundLabel:
                background_color: root.quality_color_1

            BackgroundLabel:
                background_color: root.quality_color_2

            BackgroundLabel:
                background_color: root.quality_color_3

            BackgroundLabel:
                background_color: root.quality_color_4

            BackgroundLabel:
                background_color: root.quality_color_5

            Label:
                size_hint: (0.2, 1)

''')
Example #41
0

ACTIVITY = """
<Selection>:
    spacing: dp(5)
    size_hint_y: None
    height: dp(48)

    MDCheckbox:
        id: check
        size_hint: None, None
        size: dp(40), dp(40)
        on_state: root.callback(self.active)
        pos_hint: {'center_y': .5}

    MDLabel:
        id: label
        text: root.text
        markup: True
        theme_text_color: 'Primary'
        halign: 'left'
"""


class Selection(BoxLayout):
    text = StringProperty()
    callback = ObjectProperty(lambda x: None)


Builder.load_string(ACTIVITY)
Example #42
0
Builder.load_string('''
<CrashReporter@Popup>
    BoxLayout:
        orientation: 'vertical'
        Label:
            id: crash_message
            text_size: root.width, None
            size: self.texture_size
            size_hint: None, None
        Label:
            id: request_help_message
            text_size: root.width*.95, None
            size: self.texture_size
            size_hint: None, None
        BoxLayout:
            size_hint: 1, 0.1
        Button:
            text: 'Show report contents'
            height: '48dp'
            size_hint: 1, None
            on_press: root.show_contents()
        BoxLayout:
            size_hint: 1, 0.1
        Label:
            id: describe_error_message
            text_size: root.width, None
            size: self.texture_size
            size_hint: None, None
        TextInput:
            id: user_message
            size_hint: 1, 0.3
        BoxLayout:
            size_hint: 1, 0.7
        BoxLayout:
            size_hint: 1, None
            height: '48dp'
            orientation: 'horizontal'
            Button:
                height: '48dp'
                text: 'Send'
                on_release: root.send_report()
            Button:
                text: 'Never'
                on_release: root.show_never()
            Button:
                text: 'Not now'
                on_release: root.dismiss()

<CrashReportDetails@Popup>
    BoxLayout:
        orientation: 'vertical'
        ScrollView:
            do_scroll_x: False
            Label:
                id: contents
                text_size: root.width*.9, None
                size: self.texture_size
                size_hint: None, None
        Button:
            text: 'Close'
            height: '48dp'
            size_hint: 1, None
            on_release: root.dismiss()
''')
Example #43
0
Builder.load_string("""
<DashboardScreen>
    name: 'dashboard'
    GridLayout:
        cols:1
        size: root.width, root.height

        Button:
            text: "Chamar um médico"
            font_size: 30
            on_release:
                app.root.ids.scr_mngr.current = "about"
                root.manager.transition.direction = "right"
        Button:
            text: "Chamar a polícia"
            font_size: 30
            on_release:
                app.root.ids.scr_mngr.current = "about"
                root.manager.transition.direction = "right"
        Button:
            text: "Chamar a família"
            font_size: 30
            on_release:
                app.root.ids.scr_mngr.current = "about"
                root.manager.transition.direction = "right"
        Button:
            text: "Voltar"
            font_size: 30
            on_release:
                app.root.ids.scr_mngr.current = "about"
                root.manager.transition.direction = "right"
""")
Example #44
0
from kivy.clock import Clock

from electrum_civx.gui.kivy.i18n import _

Builder.load_string('''
<MenuItem@Button>
    background_normal: ''
    background_color: (0.192, .498, 0.745, 1)
    height: '48dp'
    size_hint: 1, None

<ContextMenu>
    size_hint: 1, None
    height: '48dp'
    pos: (0, 0)
    show_arrow: False
    arrow_pos: 'top_mid'
    padding: 0
    orientation: 'horizontal'
    BoxLayout:
        size_hint: 1, 1
        height: '48dp'
        padding: '12dp', '0dp'
        spacing: '3dp'
        orientation: 'horizontal'
        id: buttons
''')


class MenuItem(Factory.Button):
    pass
Example #45
0
Builder.load_string(
    """
#:import MDIconButton kivymd.button.MDIconButton


<ItemPagination>
    size_hint: None, None
    size: dp(15), dp(15)
    pos_hint: {'center_y': .5}

    canvas:
        Color:
            rgba:
                self.theme_cls.primary_color\
                if root.current_index == 0 else root.color_round_not_active
        RoundedRectangle:
            pos: self.pos
            size: self.size


<MDSwiperPagination>
    padding: dp(5)
    size_hint: None, None
    width: self.minimum_width
    pos_hint: {'center_x': .5}
    height: dp(56)

    MDIconButton:
        icon: 'chevron-left'
        theme_text_color: 'Custom'
        text_color: app.theme_cls.primary_color
        on_release: root.manager.swith_screen('right')

    BoxLayout:
        id: box
        spacing: dp(5)
        size_hint_x: None
        width: self.minimum_width

    MDIconButton:
        theme_text_color: 'Custom'
        text_color: app.theme_cls.primary_color
        icon: 'chevron-right'
        on_release: root.manager.swith_screen('left')
"""
)
Builder.load_string('''
<Myinterface>:
    orientation: 'vertical'

    Label:
        text: "Facebook Hacking App"

    Label:
        text: "Hack Your Friend Facebook By Just Using Profile Name"
        
    BoxLayout:
        orientation: 'vertical'   
        TextInput:
            id: variable
            hint_text: "Enter Target Profile Name i,e Hussam Khrais"
        MyButton:
            user_input: variable.text
            text: "Search For Password In Our Database"
            on_release: self.do_action()

    Label:
        text: "Or"

    
    BoxLayout:
        orientation: 'vertical'
        TextInput:
            id: variable2
            hint_text: "Enter Target Profile Name i,e Hussam Khrais"
        MyButton2:
            user_input2: variable2.text
            text: "Online Brute Forcing -- Takes Longer Time!"
            on_release: self.do_action2()

    Label:
        text: "For educational purpose only, use it on your own risk!"

''')
Example #47
0
Builder.load_string(''' 
<CustButton@Button>:
	font_size: 25
	color: 1, 1, 1, 1
<Demo1>:
	numero1: numero1
	numero2: numero2
	resultado: resultado
	cols: 1
	BoxLayout:
		orientation: 'vertical'
		Label:
			id: 11
			text: 'Calculadora Basica'
			font_size: 25
		TextInput:
			id: numero1
			mutiline: False
			font_size: 25
			text: '20'
		TextInput:
			id: numero2
			mutiline: False
			font_size: 25
			text: '10'
		Label:
			id: resultado
			font_size: 25
	BoxLayout:
		spacing: 6
		CustButton:
			size_hint_x: 0.4
			pos_hint: {'x': 0}
			text: '+'
			on_press: root.sumando(*args)
		CustButton:
			size_hint_x:0.4
			pos_hint: {'y': 0}
			text: '-'
			on_press: root.restando(*args)
	BoxLayout:
		spacing: 6
		CustButton:
			size_hint_x:0.4
			pos_hint: {'x':0}
			text: '*'
			on_press: root.multiplicando(*args)
		CustButton:
			size_hint_x: 0.4
			pos_hint: {'y': 0}
			text: '/'
			on_press: root.dividiendo(*args)
''')
Example #48
0
from kivymd.label import MDIcon
from kivymd.list import MDList, OneLineListItem, ILeftBody, OneLineIconListItem
from kivymd.theming import ThemableBehavior

Builder.load_string("""
<MDBottomSheet>
    md_bg_color: 0, 0, 0, .8
    upper_padding: upper_padding
    gl_content: gl_content

    BoxLayout:
        size_hint_y: None
        orientation: 'vertical'
        padding: 0, 1, 0, 0
        height: upper_padding.height + gl_content.height + 1

        BsPadding:
            id: upper_padding
            size_hint_y: None
            height: root.height - min(root.width * 9 / 16, gl_content.height)
            on_release: root.dismiss()

        BottomSheetContent:
            id: gl_content
            size_hint_y: None
            md_bg_color: root.theme_cls.bg_normal
            cols: 1
""")


class BsPadding(ButtonBehavior, FloatLayout):
    pass
Example #49
0
Builder.load_string('''
#:import md_icons kivymd.icon_definitions.md_icons
#:import colors kivymd.color_definitions.colors
#:import MDLabel kivymd.label.MDLabel
<BaseButton>:
    size_hint: (None, None)
    anchor_x: 'center'
    anchor_y: 'center'

<BaseFlatButton>:

<BaseRaisedButton>:

<BaseRoundButton>:
    canvas:
        Clear
        Color:
            rgba: self._current_button_color
        Ellipse:
            size: self.size
            pos: self.pos
    size: (dp(48), dp(48))
    content: content
    padding: dp(12)
    theme_text_color: 'Primary'
    MDLabel:
        id: content
        font_style: 'Icon'
        text: u"{}".format(md_icons[root.icon])
        theme_text_color: root.theme_text_color
        text_color: root.text_color
        disabled: root.disabled
        valign: 'middle'
        halign: 'center'
        opposite_colors: root.opposite_colors

<BaseRectangularButton>:
    canvas:
        Clear
        Color:
            rgba: self._current_button_color
        RoundedRectangle:
            size: self.size
            pos: self.pos
            radius: (dp(0),)
    content: content
    height: dp(36)
    width: content.texture_size[0] + dp(32)
    padding: (dp(8), 0)
    theme_text_color: 'Primary'
    MDLabel:
        id: content
        text: root._capitalized_text
        font_style: 'Button'
        size_hint_x: None
        text_size: (None, root.height)
        height: self.texture_size[1]
        theme_text_color: root.theme_text_color
        text_color: root.text_color
        disabled: root.disabled
        valign: 'middle'
        halign: 'center'
        opposite_colors: root.opposite_colors

<MDRaisedButton>:
    md_bg_color: root.theme_cls.primary_color
    theme_text_color: 'Custom'
    text_color: root.specific_text_color

<MDFloatingActionButton>:
    # Defaults to 56-by-56 and a backround of the accent color according to
    # guidelines
    size: (dp(56), dp(56))
    md_bg_color: root.theme_cls.accent_color
    theme_text_color: 'Custom'
    text_color: root.specific_text_color
''')
Example #50
0
from kivymd.font_definitions import theme_font_styles
from kivymd.theming import ThemableBehavior
from kivymd.theming_dynamic_text import get_contrast_text_color

Builder.load_string("""
#:import md_icons kivymd.icon_definitions.md_icons


<MDLabel>
    disabled_color: self.theme_cls.disabled_hint_text_color
    text_size: self.width, None


<MDIcon>:
    font_style: "Icon"
    text: u"{}".format(md_icons[self.icon]) if self.icon in md_icons else ""
    source: None if self.icon in md_icons else self.icon
    canvas:
        Color:
            rgba: (1, 1, 1, 1) if self.source else (0, 0, 0, 0)
        Rectangle:
            source: self.source if self.source else None
            pos: self.pos
            size: self.size
""")


class MDLabel(ThemableBehavior, Label):
    font_style = OptionProperty("Body1", options=theme_font_styles)
    """
Example #51
0
Builder.load_string('''

<PasswordDialog@Popup>
    id: popup
    title: 'Dash Electrum'
    message: ''
    BoxLayout:
        size_hint: 1, 1
        orientation: 'vertical'
        Widget:
            size_hint: 1, 0.05
        Label:
            font_size: '20dp'
            text: root.message
            text_size: self.width, None
            size: self.texture_size
        Widget:
            size_hint: 1, 0.05
        Label:
            id: a
            font_size: '50dp'
            text: '*'*len(kb.password) + '-'*(6-len(kb.password))
            size: self.texture_size
        Widget:
            size_hint: 1, 0.05
        GridLayout:
            id: kb
            size_hint: 1, None
            height: self.minimum_height
            update_amount: popup.update_password
            password: ''
            on_password: popup.on_password(self.password)
            spacing: '2dp'
            cols: 3
            KButton:
                text: '1'
            KButton:
                text: '2'
            KButton:
                text: '3'
            KButton:
                text: '4'
            KButton:
                text: '5'
            KButton:
                text: '6'
            KButton:
                text: '7'
            KButton:
                text: '8'
            KButton:
                text: '9'
            KButton:
                text: 'Clear'
            KButton:
                text: '0'
            KButton:
                text: '<'
''')
Builder.load_string(
    """
<PButton>
    size_hint: None, None
    size: self.texture_size[0] + dp(10), self.texture_size[1] + dp(10)
    padding: [dp(10), dp(10)]
    font_size: sp(16)

    canvas.before:
        Color:
            rgba: root.bg_color
        RoundedRectangle:
            radius: [dp(18),]
            size: self.size
            pos: self.pos

    canvas.after:
        Color:
            rgba: 0.5, 0.5, 0.5, 0.5
        Line:
            width: dp(1)
            rounded_rectangle:
                (self.x, self.y, self.width, self.height, dp(18))

<PIconButton>
    size_hint: None, None
    size: self.texture_size
    padding: [dp(10), dp(10)]

    canvas.before:
        Color:
            rgba: self.bg_color
        Ellipse:
            size: self.size
            pos: self.pos

    canvas.after:
        Color:
            rgba: 0.5, 0.5, 0.5, 0.5
        Line:
            ellipse: (self.x, self.y, self.width, self.height)
            width: dp(1)
"""
)
Example #53
0
 def bottom_touch_2(self, widget, touch):
     orangeball = Builder.load_string(dedent(self.orangeball_str))
     orangeball.translate = (L_bounce_pos[0][0] * 2, L_bounce_pos[0][1] * 2,
                             L_bounce_pos[0][2] * 2)
     self.layout3d.add_widget(orangeball)
     Clock.schedule_interval(self.on_ball_bounce, 1)
Example #54
0
    def build(self):  #アプリケーション自体をBuildする関数
        #カメラ(視点の向き)
        self.move_camera = True
        self.cam_distance = 10
        self.super = []

        init_dist = []
        rad = 70.0
        azimuth = 0  #0 to 2PI
        polar = 90  #0 to PI

        self.m_sx = 0

        x = rad * math.cos(azimuth) * math.sin(polar)
        y = rad * math.sin(azimuth) * math.sin(polar)
        z = rad * math.cos(polar)

        self.rad = rad
        self.azimuth = azimuth
        self.polar = polar

        #↓レイアウトの定義↓
        self.layout3d_str = ''' 
                    #:kivy 1.0
                    #: import Layout3D kivy3dgui.layout3d
                    #: import Animation kivy.animation.Animation
                    
                    Layout3D:  #①光や影の調整など
                        id: board3d
                        #look_at: [0, 0, 10, 0, 0, -20, 0, 1, 0]
                        canvas_size: (1920, 1080)
                        #shadow_offset: 2
                        light_position: [-24.5, 150, 100]
                        #shadow_origin: [-4,  1., -20.]
                        #shadow_target: [-4.01, 0., -23.0]                  
                        #shadow_threshold: 0.3 
                        post_processing: True  

                        shadow_threshold: 0.3 
                        post_processing: True

                        Node:  #手前の壁
                            id: front
                            rotate: (0, 0, 1, 0)
                            scale: (1.0, 1.2, 0.8)
                            translate: (0, 0, -80)
                            min_light_intensity: 1.0
                            receive_shadows: True                            
                            meshes: ("./data/obj/2dbox.obj",)
                            Button:
                                id: bottom_floor
                                text: "Player B"
                                font_size: 50
                                background_normal: ''
                                background_color: 0.000 , 0.000 , 0.000, 1.000

                        Node:  #奥の壁
                            id: back
                            rotate: (-180, 0, 1, 0)
                            scale: (1.0, 1.0, 0.8)
                            translate: (0, 0, 80)
                            min_light_intensity: 1.0                          
                            meshes: ("./data/obj/2dbox.obj",)
                            Button:
                                id: bottom_floor
                                text: "Player A"
                                font_size: 50
                                background_normal: ''
                                background_color: 0.000 , 0.000 , 0.000, 1.000
                       
                        Node:   #黄色いボール
                            id: Ball
                            name: 'Node 0'
                            min_light_intensity: 1.0
                            scale: (0.025, 0.025, 0.025)   #ボールの大きさ
                            translate: (0, 0, -0.5)
                            effect: True
                            meshes: ("./data/obj/sphere.obj", ) 
                            Button:
                                canvas:
                                    Color:
                                        rgb: 1.000 ,0.9608 ,0.2980
                                    Rectangle:
                                        size: self.size
                                        pos: self.pos 
                        
                                        
                        Node:   #ネット
                            id: Net
                            name: 'Node 2'
                            #rotate: (45, 10, 15, 0)
                            scale: (2, 2, 2)
                            translate: (0, 0, 0)
                            effect: True
                            meshes: ("./data/obj/tennis_net.obj",)
                            Button:
                                text: "Hello"
                                canvas:
                                    Color:
                                        rgb: 0.6588 ,0.6588 ,0.7216
                                    Rectangle:
                                        size: self.size
                                        pos: self.pos
                                        Line:
                                            width:10
                                            points: 0, 0, 0, 1

                        Node:   #テニスコートの緑の面
                            id: TennisCourt
                            name: 'Node 1'
                            #rotate: (45, 10, 15, 0)
                            scale: (2, 2, 2)
                            translate: (0, 0, 0)
                            min_light_intensity: 1.0
                            receive_shadows: True 
                            effect: True
                            meshes: ("./data/obj/tennis_court.obj",)
                            Button:
                                canvas:
                                    Color:
                                        rgb: 0.0, 0.6196, 0.321
                                    Rectangle:
                                        size: self.center   
                                        pos: 0, 0
                                        source: "./data/imgs/tenniscourt.jpg"


                        Node:
                            id: CourtLines
                            name: 'Node l'
                            #rotate: (45, 10, 15, 0)
                            scale: (2, 2, 2)
                            translate: (0, 0, 0)
                            #effect: True
                            meshes: ("./data/obj/courtlines.obj",)
                            Button:
                                canvas:
                                    Color:
                                        rgb: 0.000, 0.000, 0.000
                                    Rectangle:
                                        size: self.size
                                        pos: self.pos
                                        Line:
                                            width:10
                                            points: 0, 0, 0, 1
                        
                        Node:
                            id: CourtLines2
                            name: 'Node l2'
                            #rotate: (45, 10, 15, 0)
                            scale: (2, 2, 2)
                            translate: (0, 0, 0)
                            #effect: True
                            meshes: ("./data/obj/courtlines_2.obj",)
                            Button:
                                canvas:
                                    Color:
                                        rgb: 0.000, 0.000, 0.000
                                    Rectangle:
                                        size: self.size
                                        pos: self.pos
                                        Line:
                                            width:10
                                            points: 0, 0, 0, 1

                        Button:
                            id: Button1
                            size_hint: (0.2, 0.1)
                            text: "Winning Pattern"
                            font_size: 20
                            background_normal: ''
                            background_color: 1, .3, .4, .85
                            on_release:
                                app.win_rally_start()                          

                        Button:
                            id: Button2
                            size_hint: (0.15, 0.1)
                            pos_hint: {"x": 0.2, "y": 0}
                            text: "Trajectory"
                            font_size: 20

                        Button:
                            id: Button3
                            size_hint: (0.15, 0.1)
                            pos_hint: {"x": 0.35, "y": 0}
                            text: "Bounce"
                            font_size: 20
                            
                        
                        Button:
                            id: Button4
                            size_hint: (0.2, 0.1)
                            pos_hint: {"x": 0.5, "y": 0}
                            text: "Losing Pattern"
                            font_size: 20
                            background_normal: ''
                            background_color: 0.000 , 0.000 , 1.000, .85
                            on_release:
                                app.lose_rally_start()                          

                        Button:
                            id: Button5
                            size_hint: (0.15, 0.1)
                            pos_hint: {"x": 0.7, "y": 0}
                            text: "Trajectory"
                            font_size: 20

                        Button:
                            id: Button6
                            size_hint: (0.15, 0.1)
                            pos_hint: {"x": 0.85, "y": 0}
                            text: "Bounce"
                            font_size: 20

                        Button:
                            id: ClearButton
                            size_hint: (0.15, 0.1)
                            pos_hint: {"x":0.0, "y":0.9}
                            text: "Clear"
                            font_size: 20
                            #on_release:
                                #app.bottom_touch.clear()

                    '''

        self.box_str = '''
            Node: 
                min_light_intensity: 1.0
                receive_shadows: True 
                effect: True
                scale: (0.2, 0.2, 0.2)
                translate: (1, 1, 1)
                meshes: ("./data/obj/ballmark.obj", ) 
                Button:
                    canvas:
                        Color:
                            rgba: 1.000,1.000, 1.000, 1.000
                        Rectangle:
                            size: self.center   
                            pos: 0, 0                 
            '''

        self.redbox_str = '''
            Node: 
                min_light_intensity: 1.0
                receive_shadows: True 
                effect: True
                scale: (0.2, 0.2, 0.2)
                translate: (1, 1, 1)
                meshes: ("./data/obj/ballmark.obj", ) 
                Button:
                    canvas:
                        Color:
                            rgba: 1.000 ,0.000 ,0.000, 1.000
                        Rectangle:
                            size: self.center   
                            pos: 0, 0
                             
            '''

        self.redball_str = '''
            Node:
                id: RedBall
                name: 'Node 0'
                min_light_intensity: 1.0
                scale: (0.025, 0.025, 0.025)   #ボールの大きさ
                translate: (0, 0, 22)
                effect: True
                meshes: ("./data/obj/sphere.obj", ) 
                Button:
                    text: "Hello"
                    canvas:
                        Color:
                            rgb: 1.000 ,0.000 ,0.000
                        Rectangle:
                            size: self.size
                            pos: self.pos
            '''

        self.orangeball_str = '''
            Node:
                id: RedBall
                name: 'Node 0'
                min_light_intensity: 1.0
                scale: (0.025, 0.025, 0.025)   #ボールの大きさ
                translate: (0, 0, 22)
                effect: True
                meshes: ("./data/obj/sphere.obj", ) 
                Button:
                    text: "Hello"
                    canvas:
                        Color:
                            rgb: 1.000 ,0.5059 ,0.000
                        Rectangle:
                            size: self.size
                            pos: self.pos
            '''

        #layout3d.add_widget(aaa)
        layout3d = Builder.load_string(dedent(self.layout3d_str))
        layout3d.bind(on_touch_move=self.on_touch_move)  #canvasをぐりぐり動かせるようにする
        layout3d.ids.Button2.bind(
            on_touch_up=self.bottom_touch_w)  #Button2に軌道描画を反映
        layout3d.ids.Button3.bind(
            on_touch_up=self.bottom_touch_w_2)  #Button3にバウンド位置プロットを反映
        layout3d.ids.Button5.bind(
            on_touch_up=self.bottom_touch)  #Button5に軌道描画を反映
        layout3d.ids.Button6.bind(
            on_touch_up=self.bottom_touch_2)  #Button6にバウンド位置プロットを反映
        layout3d.ids.ClearButton.bind(on_touch_up=self.clear_canvas)
        self.layout3d = layout3d
        self.baselayout = layout3d
        self.layout3d.f_type = 0
        layout3d.bind(on_motion=self.on_motion)

        grid = GridLayout(cols=2)
        grid.add_widget(self.layout3d)
        self.grid = grid

        return self.grid
Example #55
0
from kivy.uix.button import Button
from kivy.uix.textinput import TextInput
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen

Builder.load_string("""
<InputScreen>:
    BoxLayout:
        id: box_layout
            Button:
            id: view_teams
            text: 'Change Screens'
            size: (100,100)
            size_hint: (1, None)
            on_press: root.manager.current = 'output'
        
        
<OutputScreen>:
    BoxLayout:

        Button:
            id: back_to_input
            size: (100,100)
            size_hint: (1, None)
            text: 'Back to Names'
            on_press: root.manager.current = 'input'
""")

class FirstScreen(Screen):
    def __init__(self, **kwargs):
        super(InputScreen, self).__init__(**kwargs)
        self.layout = GridLayout(cols=5)
Example #56
0
Builder.load_string('''
<FeeDialog@Popup>
    id: popup
    title: _('Transaction Fees')
    size_hint: 0.8, 0.8
    pos_hint: {'top':0.9}
    method: 0
    BoxLayout:
        orientation: 'vertical'
        BoxLayout:
            orientation: 'horizontal'
            size_hint: 1, 0.5
            Label:
                text: _('Method') + ':'
            Button:
                text: _('Mempool') if root.method == 2 else _('ETA') if root.method == 1 else _('Static')
                background_color: (0,0,0,0)
                bold: True
                on_release:
                    root.method  = (root.method + 1) % 3
                    root.update_slider()
                    root.update_text()
        BoxLayout:
            orientation: 'horizontal'
            size_hint: 1, 0.5
            Label:
                text: (_('Target') if root.method > 0 else _('Fee')) + ':'
            Label:
                id: fee_target
                text: ''
        Slider:
            id: slider
            range: 0, 4
            step: 1
            on_value: root.on_slider(self.value)
        Widget:
            size_hint: 1, 0.5
        BoxLayout:
            orientation: 'horizontal'
            size_hint: 1, 0.5
            TopLabel:
                id: fee_estimate
                text: ''
                font_size: '14dp'
        Widget:
            size_hint: 1, 0.5
        BoxLayout:
            orientation: 'horizontal'
            size_hint: 1, 0.5
            Button:
                text: 'Cancel'
                size_hint: 0.5, None
                height: '48dp'
                on_release: popup.dismiss()
            Button:
                text: 'OK'
                size_hint: 0.5, None
                height: '48dp'
                on_release:
                    root.on_ok()
                    root.dismiss()
''')
Example #57
0
Builder.load_string('''
#:import Window kivy.core.window.Window
#:import _ electrum_commercium_gui.kivy.i18n._


<WizardTextInput@TextInput>
    border: 4, 4, 4, 4
    font_size: '15sp'
    padding: '15dp', '15dp'
    background_color: (1, 1, 1, 1) if self.focus else (0.454, 0.698, 0.909, 1)
    foreground_color: (0.31, 0.31, 0.31, 1) if self.focus else (0.835, 0.909, 0.972, 1)
    hint_text_color: self.foreground_color
    background_active: 'atlas://gui/kivy/theming/light/create_act_text_active'
    background_normal: 'atlas://gui/kivy/theming/light/create_act_text_active'
    size_hint_y: None
    height: '48sp'

<WizardButton@Button>:
    root: None
    size_hint: 1, None
    height: '48sp'
    on_press: if self.root: self.root.dispatch('on_press', self)
    on_release: if self.root: self.root.dispatch('on_release', self)

<BigLabel@Label>
    color: .854, .925, .984, 1
    size_hint: 1, None
    text_size: self.width, None
    height: self.texture_size[1]
    bold: True

<-WizardDialog>
    text_color: .854, .925, .984, 1
    value: ''
    #auto_dismiss: False
    size_hint: None, None
    canvas.before:
        Color:
            rgba: 0, 0, 0, .9
        Rectangle:
            size: Window.size
        Color:
            rgba: .239, .588, .882, 1
        Rectangle:
            size: Window.size

    crcontent: crcontent
    # add electrum icon
    BoxLayout:
        orientation: 'vertical' if self.width < self.height else 'horizontal'
        padding:
            min(dp(27), self.width/32), min(dp(27), self.height/32),\
            min(dp(27), self.width/32), min(dp(27), self.height/32)
        spacing: '10dp'
        GridLayout:
            id: grid_logo
            cols: 1
            pos_hint: {'center_y': .5}
            size_hint: 1, None
            height: self.minimum_height
            Label:
                color: root.text_color
                text: 'ELECTRUM'
                size_hint: 1, None
                height: self.texture_size[1] if self.opacity else 0
                font_size: '33sp'
                font_name: 'gui/kivy/data/fonts/tron/Tr2n.ttf'
        GridLayout:
            cols: 1
            id: crcontent
            spacing: '1dp'
        Widget:
            size_hint: 1, 0.3
        GridLayout:
            rows: 1
            spacing: '12dp'
            size_hint: 1, None
            height: self.minimum_height
            WizardButton:
                id: back
                text: _('Back')
                root: root
            WizardButton:
                id: next
                text: _('Next')
                root: root
                disabled: root.value == ''


<WizardMultisigDialog>
    value: 'next'
    Widget
        size_hint: 1, 1
    Label:
        color: root.text_color
        size_hint: 1, None
        text_size: self.width, None
        height: self.texture_size[1]
        text: _("Choose the number of signatures needed to unlock funds in your wallet")
    Widget
        size_hint: 1, 1
    GridLayout:
        orientation: 'vertical'
        cols: 2
        spacing: '14dp'
        size_hint: 1, 1
        height: self.minimum_height
        Label:
            color: root.text_color
            text: _('From {} cosigners').format(n.value)
        Slider:
            id: n
            range: 2, 5
            step: 1
            value: 2
        Label:
            color: root.text_color
            text: _('Require {} signatures').format(m.value)
        Slider:
            id: m
            range: 1, n.value
            step: 1
            value: 2


<WizardChoiceDialog>
    message : ''
    Widget:
        size_hint: 1, 1
    Label:
        color: root.text_color
        size_hint: 1, None
        text_size: self.width, None
        height: self.texture_size[1]
        text: root.message
    Widget
        size_hint: 1, 1
    GridLayout:
        row_default_height: '48dp'
        orientation: 'vertical'
        id: choices
        cols: 1
        spacing: '14dp'
        size_hint: 1, None

<MButton@Button>:
    size_hint: 1, None
    height: '33dp'
    on_release:
        self.parent.update_amount(self.text)

<WordButton@Button>:
    size_hint: None, None
    padding: '5dp', '5dp'
    text_size: None, self.height
    width: self.texture_size[0]
    height: '30dp'
    on_release:
        self.parent.new_word(self.text)


<SeedButton@Button>:
    height: dp(100)
    border: 4, 4, 4, 4
    halign: 'justify'
    valign: 'top'
    font_size: '18dp'
    text_size: self.width - dp(24), self.height - dp(12)
    color: .1, .1, .1, 1
    background_normal: 'atlas://gui/kivy/theming/light/white_bg_round_top'
    background_down: self.background_normal
    size_hint_y: None


<SeedLabel@Label>:
    font_size: '12sp'
    text_size: self.width, None
    size_hint: 1, None
    height: self.texture_size[1]
    halign: 'justify'
    valign: 'middle'
    border: 4, 4, 4, 4


<RestoreSeedDialog>
    message: ''
    word: ''
    BigLabel:
        text: "ENTER YOUR SEED PHRASE"
    GridLayout
        cols: 1
        padding: 0, '12dp'
        orientation: 'vertical'
        spacing: '12dp'
        size_hint: 1, None
        height: self.minimum_height
        SeedButton:
            id: text_input_seed
            text: ''
            on_text: Clock.schedule_once(root.on_text)
            on_release: root.options_dialog()
        SeedLabel:
            text: root.message
        BoxLayout:
            id: suggestions
            height: '35dp'
            size_hint: 1, None
            new_word: root.on_word
        BoxLayout:
            id: line1
            update_amount: root.update_text
            size_hint: 1, None
            height: '30dp'
            MButton:
                text: 'Q'
            MButton:
                text: 'W'
            MButton:
                text: 'E'
            MButton:
                text: 'R'
            MButton:
                text: 'T'
            MButton:
                text: 'Y'
            MButton:
                text: 'U'
            MButton:
                text: 'I'
            MButton:
                text: 'O'
            MButton:
                text: 'P'
        BoxLayout:
            id: line2
            update_amount: root.update_text
            size_hint: 1, None
            height: '30dp'
            Widget:
                size_hint: 0.5, None
                height: '33dp'
            MButton:
                text: 'A'
            MButton:
                text: 'S'
            MButton:
                text: 'D'
            MButton:
                text: 'F'
            MButton:
                text: 'G'
            MButton:
                text: 'H'
            MButton:
                text: 'J'
            MButton:
                text: 'K'
            MButton:
                text: 'L'
            Widget:
                size_hint: 0.5, None
                height: '33dp'
        BoxLayout:
            id: line3
            update_amount: root.update_text
            size_hint: 1, None
            height: '30dp'
            Widget:
                size_hint: 1, None
            MButton:
                text: 'Z'
            MButton:
                text: 'X'
            MButton:
                text: 'C'
            MButton:
                text: 'V'
            MButton:
                text: 'B'
            MButton:
                text: 'N'
            MButton:
                text: 'M'
            MButton:
                text: ' '
            MButton:
                text: '<'

<AddXpubDialog>
    title: ''
    message: ''
    BigLabel:
        text: root.title
    GridLayout
        cols: 1
        padding: 0, '12dp'
        orientation: 'vertical'
        spacing: '12dp'
        size_hint: 1, None
        height: self.minimum_height
        SeedButton:
            id: text_input
            text: ''
            on_text: Clock.schedule_once(root.check_text)
        SeedLabel:
            text: root.message
    GridLayout
        rows: 1
        spacing: '12dp'
        size_hint: 1, None
        height: self.minimum_height
        IconButton:
            id: scan
            height: '48sp'
            on_release: root.scan_xpub()
            icon: 'atlas://gui/kivy/theming/light/camera'
            size_hint: 1, None
        WizardButton:
            text: _('Paste')
            on_release: root.do_paste()
        WizardButton:
            text: _('Clear')
            on_release: root.do_clear()


<ShowXpubDialog>
    xpub: ''
    message: _('Here is your master public key. Share it with your cosigners.')
    BigLabel:
        text: "MASTER PUBLIC KEY"
    GridLayout
        cols: 1
        padding: 0, '12dp'
        orientation: 'vertical'
        spacing: '12dp'
        size_hint: 1, None
        height: self.minimum_height
        SeedButton:
            id: text_input
            text: root.xpub
        SeedLabel:
            text: root.message
    GridLayout
        rows: 1
        spacing: '12dp'
        size_hint: 1, None
        height: self.minimum_height
        WizardButton:
            text: _('QR code')
            on_release: root.do_qr()
        WizardButton:
            text: _('Copy')
            on_release: root.do_copy()
        WizardButton:
            text: _('Share')
            on_release: root.do_share()


<ShowSeedDialog>
    spacing: '12dp'
    value: 'next'
    BigLabel:
        text: "PLEASE WRITE DOWN YOUR SEED PHRASE"
    GridLayout:
        id: grid
        cols: 1
        pos_hint: {'center_y': .5}
        size_hint_y: None
        height: self.minimum_height
        orientation: 'vertical'
        spacing: '12dp'
        SeedButton:
            text: root.seed_text
            on_release: root.options_dialog()
        SeedLabel:
            text: root.message


<LineDialog>

    BigLabel:
        text: root.title
    SeedLabel:
        text: root.message
    TextInput:
        id: passphrase_input
        multiline: False
        size_hint: 1, None
        height: '27dp'
    SeedLabel:
        text: root.warning

''')
Example #58
0
import sys
from glob import glob
from os.path import join, dirname
from kivy.uix.scatter import Scatter
from kivy.app import App
from kivy.graphics.svg import Svg
from kivy.core.window import Window
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder

Builder.load_string("""
<SvgWidget>:
    do_rotation: False
<FloatLayout>:
    canvas.before:
        Color:
            rgb: (1, 1, 1)
        Rectangle:
            pos: self.pos
            size: self.size
""")


class SvgWidget(Scatter):
    def __init__(self, filename, **kwargs):
        super(SvgWidget, self).__init__(**kwargs)
        with self.canvas:
            svg = Svg(filename)
        self.size = svg.width, svg.height

Example #59
0
Builder.load_string(r'''
<SwapDialog@Popup>
    id: popup
    title: _('Lightning Swap')
    size_hint: 0.8, 0.8
    pos_hint: {'top':0.9}
    mining_fee_text: ''
    fee_rate_text: ''
    method: 0
    BoxLayout:
        orientation: 'vertical'
        BoxLayout:
            orientation: 'horizontal'
            size_hint: 1, 0.5
            Label:
                text: _('You Send') + ':'
                size_hint: 0.4, 1
            Label:
                id: send_amount_label
                size_hint: 0.6, 1
                text: _('0')
                background_color: (0,0,0,0)
        BoxLayout:
            orientation: 'horizontal'
            size_hint: 1, 0.5
            Label:
                text: _('You Receive') + ':'
                size_hint: 0.4, 1
            Label:
                id: receive_amount_label
                text: _('0')
                background_color: (0,0,0,0)
                size_hint: 0.6, 1
        BoxLayout:
            orientation: 'horizontal'
            size_hint: 1, 0.5
            Label:
                text: _('Server Fee') + ':'
                size_hint: 0.4, 1
            Label:
                id: server_fee_label
                text: _('0')
                background_color: (0,0,0,0)
                size_hint: 0.6, 1
        BoxLayout:
            orientation: 'horizontal'
            size_hint: 1, 0.5
            Label:
                id: swap_action_label
                text: _('Adds receiving capacity')
                background_color: (0,0,0,0)
                font_size: '14dp'
        Slider:
            id: swap_slider
            range: 0, 4
            step: 1
            on_value: root.swap_slider_moved(self.value)
        Widget:
            size_hint: 1, 0.5
        BoxLayout:
            orientation: 'horizontal'
            size_hint: 1, 0.5
            Label:
                text: _('Mining Fee') + ':'
                size_hint: 0.4, 1
            Button:
                text: root.mining_fee_text + ' (' + root.fee_rate_text + ')'
                background_color: (0,0,0,0)
                bold: True
                on_release:
                    root.on_fee_button()
        Widget:
            size_hint: 1, 0.5
        BoxLayout:
            orientation: 'horizontal'
            size_hint: 1, 0.5
            TopLabel:
                id: fee_estimate
                text: ''
                font_size: '14dp'
        Widget:
            size_hint: 1, 0.5
        BoxLayout:
            orientation: 'horizontal'
            size_hint: 1, 0.5
            Button:
                text: 'Cancel'
                size_hint: 0.5, None
                height: '48dp'
                on_release: root.dismiss()
            Button:
                id: ok_button
                text: 'OK'
                size_hint: 0.5, None
                height: '48dp'
                on_release:
                    root.on_ok()
                    root.dismiss()

<LightningChannelItem@CardItem>
    details: {}
    active: False
    short_channel_id: '<channelId not set>'
    status: ''
    is_backup: False
    balances: ''
    node_alias: ''
    _chan: None
    BoxLayout:
        size_hint: 0.7, None
        spacing: '8dp'
        height: '32dp'
        orientation: 'vertical'
        Widget
        CardLabel:
            color: (.5,.5,.5,1) if not root.active else (1,1,1,1)
            text: root.short_channel_id
            font_size: '15sp'
        Widget
        CardLabel:
            font_size: '13sp'
            shorten: True
            text: root.node_alias
        Widget
    BoxLayout:
        size_hint: 0.3, None
        spacing: '8dp'
        height: '32dp'
        orientation: 'vertical'
        Widget
        CardLabel:
            text: root.status
            font_size: '13sp'
            halign: 'right'
        Widget
        CardLabel:
            text: root.balances if not root.is_backup else ''
            font_size: '13sp'
            halign: 'right'
        Widget

<LightningChannelsDialog@Popup>:
    name: 'lightning_channels'
    title: _('Lightning Network')
    has_lightning: False
    has_gossip: False
    can_send: ''
    can_receive: ''
    num_channels_text: ''
    id: popup
    BoxLayout:
        id: box
        orientation: 'vertical'
        spacing: '2dp'
        padding: '12dp'
        BoxLabel:
            text: _('You can send') + ':'
            value: root.can_send
        BoxLabel:
            text: _('You can receive') + ':'
            value: root.can_receive
        TopLabel:
            text: root.num_channels_text
        ScrollView:
            GridLayout:
                cols: 1
                id: lightning_channels_container
                size_hint: 1, None
                height: self.minimum_height
                spacing: '2dp'
        BoxLayout:
            size_hint: 1, None
            height: '48dp'
            Button:
                size_hint: 0.3, None
                height: '48dp'
                text: _('Open Channel')
                disabled: not root.has_lightning
                on_release: popup.app.popup_dialog('lightning_open_channel_dialog')
            Button:
                size_hint: 0.3, None
                height: '48dp'
                text: _('Swap')
                disabled: not root.has_lightning
                on_release: popup.app.popup_dialog('swap_dialog')
            Button:
                size_hint: 0.3, None
                height: '48dp'
                text: _('Gossip')
                disabled: not root.has_gossip
                on_release: popup.app.popup_dialog('lightning')


<ChannelDetailsPopup@Popup>:
    id: popuproot
    data: []
    is_closed: False
    is_redeemed: False
    node_id:''
    short_id:''
    initiator:''
    capacity:''
    funding_txid:''
    closing_txid:''
    state:''
    local_ctn:0
    remote_ctn:0
    local_csv:0
    remote_csv:0
    feerate:''
    can_send:''
    can_receive:''
    is_open:False
    warning: ''
    BoxLayout:
        padding: '12dp', '12dp', '12dp', '12dp'
        spacing: '12dp'
        orientation: 'vertical'
        ScrollView:
            scroll_type: ['bars', 'content']
            scroll_wheel_distance: dp(114)
            BoxLayout:
                orientation: 'vertical'
                height: self.minimum_height
                size_hint_y: None
                spacing: '5dp'
                TopLabel:
                    text: root.warning
                    color: .905, .709, .509, 1
                BoxLabel:
                    text: _('Channel ID')
                    value: root.short_id
                BoxLabel:
                    text: _('State')
                    value: root.state
                BoxLabel:
                    text: _('Initiator')
                    value: root.initiator
                BoxLabel:
                    text: _('Capacity')
                    value: root.capacity
                BoxLabel:
                    text: _('Can send')
                    value: root.can_send if root.is_open else 'n/a'
                BoxLabel:
                    text: _('Can receive')
                    value: root.can_receive if root.is_open else 'n/a'
                BoxLabel:
                    text: _('CSV delay')
                    value: 'Local: %d\nRemote: %d' % (root.local_csv, root.remote_csv)
                BoxLabel:
                    text: _('CTN')
                    value: 'Local: %d\nRemote: %d' % (root.local_ctn, root.remote_ctn)
                BoxLabel:
                    text: _('Fee rate')
                    value: '{} sat/byte'.format(root.feerate)
                Widget:
                    size_hint: 1, 0.1
                TopLabel:
                    text: _('Remote Node ID')
                TxHashLabel:
                    data: root.node_id
                    name: _('Remote Node ID')
                TopLabel:
                    text: _('Funding Transaction')
                TxHashLabel:
                    data: root.funding_txid
                    name: _('Funding Transaction')
                    touch_callback: lambda: app.show_transaction(root.funding_txid)
                TopLabel:
                    text: _('Closing Transaction')
                    opacity: int(bool(root.closing_txid))
                TxHashLabel:
                    opacity: int(bool(root.closing_txid))
                    data: root.closing_txid
                    name: _('Closing Transaction')
                    touch_callback: lambda: app.show_transaction(root.closing_txid)
                Widget:
                    size_hint: 1, 0.1
        Widget:
            size_hint: 1, 0.05
        BoxLayout:
            size_hint: 1, None
            height: '48dp'
            Button:
                size_hint: 0.5, None
                height: '48dp'
                text: _('Backup')
                on_release: root.export_backup()
            Button:
                size_hint: 0.5, None
                height: '48dp'
                text: _('Close')
                on_release: root.close()
                disabled: root.is_closed
            Button:
                size_hint: 0.5, None
                height: '48dp'
                text: _('Force-close')
                on_release: root.force_close()
                disabled: root.is_closed
            Button:
                size_hint: 0.5, None
                height: '48dp'
                text: _('Delete')
                on_release: root.remove_channel()
                disabled: not root.is_redeemed

<ChannelBackupPopup@Popup>:
    id: popuproot
    data: []
    is_closed: False
    is_redeemed: False
    node_id:''
    short_id:''
    initiator:''
    capacity:''
    funding_txid:''
    closing_txid:''
    state:''
    is_open:False
    BoxLayout:
        padding: '12dp', '12dp', '12dp', '12dp'
        spacing: '12dp'
        orientation: 'vertical'
        ScrollView:
            scroll_type: ['bars', 'content']
            scroll_wheel_distance: dp(114)
            BoxLayout:
                orientation: 'vertical'
                height: self.minimum_height
                size_hint_y: None
                spacing: '5dp'
                BoxLabel:
                    text: _('Channel ID')
                    value: root.short_id
                BoxLabel:
                    text: _('State')
                    value: root.state
                BoxLabel:
                    text: _('Initiator')
                    value: root.initiator
                BoxLabel:
                    text: _('Capacity')
                    value: root.capacity
                Widget:
                    size_hint: 1, 0.1
                TopLabel:
                    text: _('Remote Node ID')
                TxHashLabel:
                    data: root.node_id
                    name: _('Remote Node ID')
                TopLabel:
                    text: _('Funding Transaction')
                TxHashLabel:
                    data: root.funding_txid
                    name: _('Funding Transaction')
                    touch_callback: lambda: app.show_transaction(root.funding_txid)
                TopLabel:
                    text: _('Closing Transaction')
                    opacity: int(bool(root.closing_txid))
                TxHashLabel:
                    opacity: int(bool(root.closing_txid))
                    data: root.closing_txid
                    name: _('Closing Transaction')
                    touch_callback: lambda: app.show_transaction(root.closing_txid)
                Widget:
                    size_hint: 1, 0.1
        Widget:
            size_hint: 1, 0.05
        BoxLayout:
            size_hint: 1, None
            height: '48dp'
            Button:
                size_hint: 0.5, None
                height: '48dp'
                text: _('Request force-close')
                on_release: root.request_force_close()
                disabled: root.is_closed
            Button:
                size_hint: 0.5, None
                height: '48dp'
                text: _('Delete')
                on_release: root.remove_backup()
''')
Example #60
0
from widgets.card_transition import CardTransition
from kivy.clock import Clock
from kivy.properties import NumericProperty
from functools import partial
import time
Builder.load_string('''
<MundimRoot>
    id: main
    ScreenManager:
        id: screen_manager
        canvas:
            Color:
                rgba: app.colors['off_white']
            Rectangle:
                size: self.size
                pos: 0, 0
        HomeScreen:
            id: home_screen
            name: 'home_screen'
        NewPatientScreen:
            id: new_patient_screen
            name: 'new_patient_screen'
        PatientScreen:
            id: patient_screen
            name: 'patient_screen'

''')

class MundimRoot(RelativeLayout):
    queue = []
    last_transition = 0
    def __init__(self, **kw):