Ejemplo n.º 1
0
Archivo: app.py Proyecto: edthedev/kivy
    def run(self, kv_file = None):
        '''Launches the app in standalone mode.
        '''
        if not self.built:
            self.load_config()
            self.load_kv(kv_file)
            root = self.build()
            if root:
                self.root = root
        if self.root:
            from kivy.core.window import Window
            Window.add_widget(self.root)

        # Check if the window is already created
        from kivy.base import EventLoop
        window = EventLoop.window
        if window:
            self._app_window = window
            window.set_title(self.get_application_name())
            icon = self.get_application_icon()
            if icon:
                window.set_icon(icon)
            self._install_settings_keys(window)
        else:
            Logger.critical("Application: No window is created."
                " Terminating application run.")
            return

        self.dispatch('on_start')
        runTouchApp()
        self.dispatch('on_stop')

        # Clear the window children
        for child in window.children:
            window.remove_widget(child)
Ejemplo n.º 2
0
    def run(self):
        """Launches the app in standalone mode.
        """
        if not self.built:
            self.load_config()
            self.load_kv()
            root = self.build()
            if root:
                self.root = root
        if self.root:
            from kivy.core.window import Window

            Window.add_widget(self.root)

        # Check if the window is already created
        from kivy.base import EventLoop

        window = EventLoop.window
        if window:
            self._app_window = window
            window.set_title(self.get_application_name())
            icon = self.get_application_icon()
            if icon:
                window.set_icon(icon)
            self._install_settings_keys(window)

        self.dispatch("on_start")
        runTouchApp()
        self.dispatch("on_stop")
Ejemplo n.º 3
0
Archivo: app.py Proyecto: suparit/kivy
    def run(self):
        """Launches the app in standalone mode.
        """
        if not self.built:
            self.load_config()
            self.load_kv(filename=self.options.get("kv_file"))
            root = self.build()
            if root:
                self.root = root
        if self.root:
            from kivy.core.window import Window

            Window.add_widget(self.root)

        # Check if the window is already created
        from kivy.base import EventLoop

        window = EventLoop.window
        if window:
            self._app_window = window
            window.set_title(self.get_application_name())
            icon = self.get_application_icon()
            if icon:
                window.set_icon(icon)
            self._install_settings_keys(window)
        else:
            Logger.critical("Application: No window is created." " Terminating application run.")
            return

        self.dispatch("on_start")
        runTouchApp()
        self.stop()
Ejemplo n.º 4
0
 def start_loop(self, new_thread=False):
     if new_thread:
         print "Warning: kivy apps cannot run in any thread other then mainthread,"\
                "thus " + self.__class__.__name__ + ".start_loop() is running in blocking mode"\
                "the parameter \"new_thread=True\" passed in "+ self.__class__.__name__ + ".start_loop(new_thread=True)"\
                " is invalid and disabled."
     runTouchApp(self)
Ejemplo n.º 5
0
    def run(self):
        '''Launches the app in standalone mode.
        '''
        if not self.built:
            self.load_config()
            self.load_kv(filename=self.kv_file)
            root = self.build()
            if root:
                self.root = root
        if self.root:
            if not isinstance(self.root, Widget):
                Logger.critical('App.root must be an _instance_ of Widget')
                raise Exception('Invalid instance in App.root')
            from kivy.core.window import Window
            Window.add_widget(self.root)

        # Check if the window is already created
        from kivy.base import EventLoop
        window = EventLoop.window
        if window:
            self._app_window = window
            window.set_title(self.get_application_name())
            icon = self.get_application_icon()
            if icon:
                window.set_icon(icon)
            self._install_settings_keys(window)
        else:
            Logger.critical("Application: No window is created."
                            " Terminating application run.")
            return

        self.dispatch('on_start')
        runTouchApp()
        self.stop()
Ejemplo n.º 6
0
    def render(self, root, framecount=1):
        '''Call rendering process using the `root` widget.
        The screenshot will be done in `framecount` frames.
        '''
        from kivy.base import runTouchApp
        self.framecount = framecount
        runTouchApp(root)

        # reset for the next test, but nobody will know if it will be used :/
        if self.test_counter != 0:
            self.tearDown(fake=True)
            self.setUp()
Ejemplo n.º 7
0
Archivo: app.py Proyecto: fajran/kivy
 def run(self):
     '''Launches the app in standalone mode.
     '''
     if not self.built:
         self.load_kv()
         root = self.build()
         if root:
             self.root = root
     if self.root:
         from kivy.core.window import Window
         Window.add_widget(self.root)
     self.dispatch('on_start')
     runTouchApp()
     self.dispatch('on_stop')
Ejemplo n.º 8
0
Archivo: app.py Proyecto: aidanok/kivy
 def run(self):
     '''Launches the app in standalone mode.
     '''
     if not self.built:
         self.load_kv()
         root = self.build()
         if root:
             self.root = root
     self.dispatch('on_start')
     if self.root:
         runTouchApp(self.root)
     else:
         runTouchApp()
     self.dispatch('on_stop')
Ejemplo n.º 9
0
 def test_video_unload(self):
     # fix issue https://github.com/kivy/kivy/issues/2275
     # AttributeError: 'NoneType' object has no attribute 'texture'
     from kivy.uix.video import Video
     from kivy.clock import Clock
     from kivy.base import runTouchApp, stopTouchApp
     from os.path import join, dirname
     here = dirname(__file__)
     source = join(here, "..", "..", "examples", "widgets", "softboy.avi")
     video = Video(source=source, play=True)
     Clock.schedule_once(lambda x: stopTouchApp(), 1)
     def unload_video(video, position):
         if position > 0.01:
             video.unload()
             Clock.schedule_once(lambda x: stopTouchApp(), 0.1)
     video.bind(position=unload_video)
     runTouchApp(video)
Ejemplo n.º 10
0
Archivo: common.py Proyecto: kivy/kivy
    def render(self, root, framecount=1):
        '''Call rendering process using the `root` widget.
        The screenshot will be done in `framecount` frames.
        '''
        from kivy.base import runTouchApp
        from kivy.clock import Clock
        self.framecount = framecount
        try:
            Clock.schedule_interval(self._force_refresh, 1)
            runTouchApp(root)
        finally:
            Clock.unschedule(self._force_refresh)

        # reset for the next test, but nobody will know if it will be used :/
        if self.test_counter != 0:
            self.tearDown(fake=True)
            self.setUp()
Ejemplo n.º 11
0
 def run(self):
     '''Launches the app in standalone mode.
     '''
     self._run_prepare()
     runTouchApp()
     self.stop()
Ejemplo n.º 12
0
from kivy.base import runTouchApp
from kivy.garden import roulette, roulettescroll, tickline
from kivy.garden import DatetimePicker
from kivy.app import App


class TestApp(App):
    def build(self):
        #menuclock = MenuScreen()
        #Clock.schedule_interval(menuclock.get_time, 1)
        pass


if __name__ == '__main__':
    runTouchApp(DatetimePicker())
Ejemplo n.º 13
0
## -*- coding:latin-1 -*-

from kivy.uix.scrollview import ScrollView
from kivy.uix.label import Label
from kivy.app import App
from kivy.lang import Builder
from kivy.base import runTouchApp
from kivy.properties import *

import threading, time

Builder.load_string( '''
<ScrollableLabel>:
	text: "asdf " * 100
	Label:
		text: root.text
		font_size: 50
		text_size: self.width, None
		size_hint_y: None
		height: self.texture_size[ 1 ]

''' )

class ScrollableLabel( ScrollView ):
	text = StringProperty( "" )

runTouchApp( ScrollableLabel(  ) )
Ejemplo n.º 14
0
# -*- coding: utf-8 -*-

from kivy.lang import Builder
from kivy.base import runTouchApp

runTouchApp(
    Builder.load_string("""
 
Label:
#Creating 
    Button:
        text:'btn1'
        font_size:32
        color:0.8,0.9,0,1
        pos:50,100
        size:100,200
        
    Button:
        text:'btn2'
        font_size:40
        color:0.1,0.9,0.5,1
        size:200,100
        pos:200,100
                                
                                
                                
                                
"""))
Ejemplo n.º 15
0
                window.remove_widget(child)

            # put the video in fullscreen
            if state['parent'] is not window:
                state['parent'].remove_widget(self)
            window.add_widget(self)

            # ensure the video widget is in 0, 0, and the size will be
            # reajusted
            self.pos = (0, 0)
            self.size = (100, 100)
            self.pos_hint = {}
            self.size_hint = (1, 1)
        else:
            state = self._fullscreen_state
            window.remove_widget(self)
            for child in state['window_children']:
                window.add_widget(child)
            self.pos_hint = state['pos_hint']
            self.size_hint = state['size_hint']
            self.pos = state['pos']
            self.size = state['size']
            if state['parent'] is not window:
                state['parent'].add_widget(self)


if __name__ == '__main__':
    import sys
    from kivy.base import runTouchApp
    runTouchApp(VideoPlayer(source=sys.argv[1]))
Ejemplo n.º 16
0
                            allow_empty_selection=False,
                            cls=ListItemButton)

        self.list_view = ListView(adapter=self.list_adapter)

        self.add_widget(self.list_view)

        self.toggle = 'adding'

        Clock.schedule_interval(self.update_list_data, 1)

    def update_list_data(self, dt):
        items = self.list_adapter.data
        if self.toggle == 'adding':
            item = DataItem(name='New ' * random.randint(1, 2))
            items.append(item)
            self.toggle = 'changing'
            print 'added ' + item.name
        else:
            random_index = random.randint(0, len(items) - 1)
            item = items[random_index]
            items[random_index] = DataItem()
            self.toggle = 'adding'
            print 'changed {0} to {1}'.format(item.name,
                                              items[random_index].name)


if __name__ == '__main__':
    from kivy.base import runTouchApp
    runTouchApp(MainView(width=800))
Ejemplo n.º 17
0
                          pos=[0, 350],
                          size_hint=[None, None])
        self.isSuperMode = False
        self.btn.height = 100
        self.inp = TextInput(multiline=False,
                             size=[width, 100],
                             pos=[0, top - 100],
                             size_hint=[None, None])
        self.btn.bind(on_release=self.changeMode)
        func = lambda y: self.inp.insert_text("\n" + " " * len(
            self.inp.text) + "_" * 5 + " " * len(self.inp.text))
        btn2 = Button(text=r"\n",
                      size_hint=[None, None],
                      pos=[0, self.btn.top])
        btn2.bind(on_release=func)
        self.add_widget(btn2)
        self.add_widget(self.btn)
        self.add_widget(self.inp)

    def changeMode(self, m):
        #	initial = self.inp.padding_y
        if not self.isSuperMode:
            self.inp.padding_y[0] *= 3
        else:
            self.inp.padding_y[0] = 0


runTouchApp(Test())
help(TextInput.do_cursor_movement)
print(dir(TextInput))
print(dir(ToggleButton))
Ejemplo n.º 18
0
from kivy.base import runTouchApp
from kivy.lang import Builder

runTouchApp(Builder.load_file('action.kv'))
Ejemplo n.º 19
0
        list_item_args_converter = \
                lambda row_index, rec: {'text': rec['name'],
                                        'size_hint_y': None,
                                        'height': 25}

        dict_adapter = DictAdapter(sorted_keys=sorted(fruit_data.keys()),
                                   data=fruit_data,
                                   args_converter=list_item_args_converter,
                                   selection_mode='single',
                                   allow_empty_selection=False,
                                   cls=ListItemButton)

        master_list_view = ListView(adapter=dict_adapter, size_hint=(.3, 1.0))

        self.add_widget(master_list_view)

        detail_view = FruitDetailView(
            fruit_name=dict_adapter.selection[0].text, size_hint=(.7, 1.0))

        dict_adapter.bind(on_selection_change=detail_view.fruit_changed)
        self.add_widget(detail_view)


if __name__ == '__main__':

    from kivy.base import runTouchApp

    master_detail = MasterDetailView(sorted(fruit_data.keys()), width=800)

    runTouchApp(master_detail)
Ejemplo n.º 20
0
                            #obtener posibles particiones de este disco duro
                            for j in range(1, 9):
                                part = dev + str(j)
                                try:
                                    with open(part):
                                        hds.append(part)

                                except:
                                    continue

            except:
                continue

        #agregar destino null
        hds.append('/dev/null')

        #agregar opcion de imagen como destino
        hds.append('Archivo de imagen')

        #si el origen es particion, agregar opcion de pasar antivirus
        hds.append('Escanear con antivirus')

        return hds


if __name__ == '__main__':
    from kivy.base import runTouchApp

    runTouchApp(Clonator(orientation='vertical'))
Ejemplo n.º 21
0
      if self._closed:
        self._trump_card.rotation = 10
        self._trump_card.center = self.to_parent(
          local_talon_pos[0] + self._talon_size[0] / 2,
          local_talon_pos[1] + self._talon_size[1] / 2, True)
      else:
        self._trump_card.rotation = 90
        self._trump_card.pos = self.to_parent((self.width - height) / 2.0,
                                              (self.height - width) / 2.0, True)


if __name__ == "__main__":
  RATIO = 10
  talon_widget = TalonWidget(RATIO)
  talon_widget.pos = 50, 50
  talon_widget.size = 1000, 1000
  talon_widget.size_hint = None, None

  trump_card = CardWidget(Card(Suit.SPADES, CardValue.ACE), aspect_ratio=RATIO)
  talon_widget.set_trump_card(trump_card)

  _card = CardWidget(Card(Suit.SPADES, CardValue.ACE), aspect_ratio=RATIO)
  _card.visible = False
  talon_widget.push_card(_card)

  runTouchApp(talon_widget)

  # noinspection PyStringFormat
  print("(%.1f, (%d, %d), [%d, %d], (%.1f, %.1f), (%.1f, %.1f))" % (
    RATIO, *talon_widget.size, *_card.size, *_card.pos, *trump_card.pos))
Ejemplo n.º 22
0
    :data:`foreground_color` is an :class:`~kivy.properties.ListProperty`,
    Default to '(.5, .5, .5, .93)'
    """

    background_color = ListProperty((0, 0, 0, 1))
    """This defines the color of the background in the console

    :data:`foreground_color` is an :class:`~kivy.properties.ListProperty`,
    Default to '(0, 0, 0, 1)"""

    font_name = StringProperty("data/fonts/Roboto-Regular.ttf")
    """Indicates the font Style used in the console

    :data:`font` is a :class:`~kivy.properties.StringProperty`,
    Default to 'DroidSansMono'
    """

    font_size = NumericProperty("12sp")
    """Indicates the size of the font used for the console

    :data:`font_size` is a :class:`~kivy.properties.NumericProperty`,
    Default to '9'
    """
    def __init__(self, **kwargs):
        super(KivyConsole, self).__init__(**kwargs)


if __name__ == "__main__":
    runTouchApp(KivyConsole())
Ejemplo n.º 23
0
<TestWidget>:
    orientation: 'horizontal'
    list_size: int(dial.value)

    BoxLayout:
        orientation: 'vertical'
        DialSlider:
            id: dial
            dial_axis: 'x'
            min: 0
            max: 500
        Label:
            text: 'Num_Items: %d' % len(testview.data)
        Label:
            text: 'Navigation ID: %s' % testview.nav_id
        Label:
            text: 'Reference: %0.2f' % testview.reftop_id


    TestRecycleView:
        id: testview
        dial_axis: 'y'
        viewclass: 'TestItem'
        data: [{'number': i} for i in range(0, root.list_size)]

""")

if __name__ == '__main__':
    runTouchApp(widget=TestWidget())
Ejemplo n.º 24
0
            # the current size. Take the best side, and fit to it.
            height = max(h_bottom, h_top)
            if height == h_bottom:
                self.top = wy
                self.height = wy
            else:
                self.y = wtop
                self.height = win.height - wtop


if __name__ == '__main__':
    from kivy.uix.button import Button
    from kivy.base import runTouchApp

    def show_dropdown(button, *largs):
        dp = DropDown()
        dp.bind(on_select=lambda instance, x: setattr(button, 'text', x))
        for i in xrange(10):
            item = Button(text='hello %d' % i, size_hint_y=None, height=44)
            item.bind(on_release=lambda btn: dp.select(btn.text))
            dp.add_widget(item)
        dp.open(button)

    def touch_move(instance, touch):
        instance.center = touch.pos

    btn = Button(text='SHOW', size_hint=(None, None), pos=(300, 200))
    btn.bind(on_release=show_dropdown, on_touch_move=touch_move)

    runTouchApp(btn)
Ejemplo n.º 25
0
class RootWidget(Label):
    def do_layout(self, *args):
        self.add_widget(Image('Transparent.png'))
        number_of_children = len(self.children)
        width = self.width
        width_per_child = width/number_of_children
        positions = range(0, width, width_per_child)
        for position, child in zip(positions, self.children):
            child.height = self.height
            child.x = self.x + position
            child.y = self.y
            child.width = width_per_child

    # on_blank means this function will be called whenever blank is changed
    def on_size(self, *args):
        self.do_layout()

    def on_pos(self, *args):
        self.do_layout()

    def add_widget(self, widget):
        super(RootWidget, self).add_widget(widget)
        self.do_layout

    def remove_widget(self, widget):
        super(RootWidget, self).remove_widget(widget)
        self.do_layout()

runTouchApp(RootWidget())
Ejemplo n.º 26
0
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.lang import Builder
from kivy.base import runTouchApp

Builder.load_string("""
<BoxLayout>:
    orientation: 'horizontal'
    Button:
        text: 'B1'
    Button:
        text: 'B2'
    Button:
        text: 'B3'

""")


class MyListView(BoxLayout):
    pass


if __name__ == '__main__':
    runTouchApp(MyListView())
Ejemplo n.º 27
0
            item.add_widget(Label(text='This is a big content\n' * 20))
        acc.add_widget(item)

    def toggle_layout(*l):
        o = acc.orientation
        acc.orientation = 'vertical' if o == 'horizontal' else 'horizontal'
    btn = Button(text='Toggle layout')
    btn.bind(on_release=toggle_layout)

    def select_2nd_item(*l):
        acc.select(acc.children[-2])
    btn2 = Button(text='Select 2nd item')
    btn2.bind(on_release=select_2nd_item)

    from kivy.uix.slider import Slider
    slider = Slider()

    def update_min_space(instance, value):
        acc.min_space = value

    slider.bind(value=update_min_space)

    root = BoxLayout(spacing=20, padding=20)
    controls = BoxLayout(orientation='vertical', size_hint_x=.3)
    controls.add_widget(btn)
    controls.add_widget(btn2)
    controls.add_widget(slider)
    root.add_widget(controls)
    root.add_widget(acc)
    runTouchApp(root)
Ejemplo n.º 28
0
from kivy.base import runTouchApp
from kivy.lang import Builder
from kivy.garden.toggle_knob import Toggle_knob

# LOAD KV UIX
runTouchApp(Builder.load_file('example.kv'))
Ejemplo n.º 29
0
    .. versionadded:: 1.9.2

    :attr:`color` is a
    :class:`~kivy.properties.ListProperty` and defaults to
    '[1, 1, 1, 1]'.
    '''

    def on_state(self, instance, value):
        if value == 'down':
            self.active = True
        else:
            self.active = False

    def _toggle_active(self):
        self._do_press()

    def on_active(self, instance, value):
        self.state = 'down' if value else 'normal'


if __name__ == '__main__':
    from random import uniform
    from kivy.base import runTouchApp
    from kivy.uix.gridlayout import GridLayout
    x = GridLayout(cols=4)
    for i in range(36):
        r, g, b = [uniform(0.2, 1.0) for j in range(3)]
        x.add_widget(CheckBox(group='1' if i % 2 else '', color=[r, g, b, 2]))
    runTouchApp(x)
Ejemplo n.º 30
0

def test(*largs):
    print(largs)


if __name__ == '__main__':

    # Alert popup example
    from functools import partial
    popup = AlertPopup(title='Alert',
                       message='You system Contains a virus',
                       comfirm=partial(test, 'avour', 'Developer', 'Musician'))
    btn = Button(text='Press me')
    btn.bind(on_release=lambda a: popup.open())
    runTouchApp(btn)

    rbtn = RightIconButton(size_hint=(None, None),
                           width=300,
                           height=60,
                           pos=(20, 40),
                           icon_source='/root/croped.jpg',
                           text='IconButton')
    Effects().add_shadow(rbtn)
    runTouchApp(rbtn)

    #	runTouchApp(IconButton(size_hint=(None,None), width=70, height=70, pos=(20, 40), icon_source='/root/croped.jpg', shape='ellipse'))

    #	button = NormalButton(text='Normal Button',shape='ellipse', size_hint=(None,None), width=60, height=60, pos=(20, 40), font_size='10dp', color=(1,0,1,1))
    #	runTouchApp(button)
Ejemplo n.º 31
0
                  abs(touch.x - touch.ox) / self.width > self.swipe_threshold):
                self.page += 1
            else:
                self._trigger_layout()

            touch.ungrab(self)

        if len(self.children) > 1:
            return self.children[-self.page + 1].on_touch_up(touch)

    # 选择了新的页面
    def on_select(self, index):
        pass

    # 发送信号
    def on_page(self, instance, index):
        print('dispatch on_select', index)
        self.dispatch('on_select', index)


if __name__ == '__main__':
    from kivy.base import runTouchApp
    from kivy.uix.button import Button

    pl = PageLayout()
    for i in range(1, 4):
        b = Button(text='page%s' % i)
        pl.add_widget(b)

    runTouchApp(pl)
Ejemplo n.º 32
0
            Slider:
                id: slider
                value: 30
                max: 100
                min: 0

            ToggleButton:
                text: 'Animated'
                id: animated
                state: 'down'

            Spinner:
                id: orientation
                values: 'bt', 'tb', 'lr', 'rl'
                text: 'bt'

            Spinner:
                id: anim
                text: 'linear'
                values: 'linear', 'in_back', 'in_out_expo', 'out_elastic'

    ColorPicker:
        id: picker
        size_hint: 1, None
        height: '200dp'
        on_parent: self.remove_widget(self.children[0].children[0])

    ''')
    runTouchApp(kv)
Ejemplo n.º 33
0
            main_panel.text = 'MAIN PANEL' \
                              '\nTimeout = 5 Seconds' \
                              '\n Click anywhere on the screen.'

    def start_timer(*args):
        main_panel._start_time = time.time()

    def end_timer(*args):
        main_panel._start_time = None

    il = ImmersiveLayout()
    il.bind(on_exit_immersive=start_timer)
    il.bind(on_enter_immersive=end_timer)

    b = BoxLayout()
    b.add_widget(Button(text='1'))
    b.add_widget(Button(text='2'))
    hide_btn = Button(text='Hide Dock')
    hide_btn.bind(on_press=il.enter_immersive_mode)
    b.add_widget(hide_btn)

    main_panel = Label(halign='center')
    main_panel._start_time = None
    Clock.schedule_interval(_timer, 0.1)
    il.add_widget(main_panel)
    il.add_widget(b)

    box = BoxLayout(orientation='vertical')
    box.add_widget(il)
    runTouchApp(box)
Ejemplo n.º 34
0
            # none of both top/bottom have enough place to display the
            # widget at the current size. Take the best side, and fit to
            # it.
            if h_top < h_bottom:
                self.top = self.height = wy
            else:
                self.y = wtop
                self.height = win.height - wtop


if __name__ == '__main__':
    from kivy.uix.button import Button
    from kivy.base import runTouchApp

    def show_dropdown(button, *largs):
        dp = DropDown()
        dp.bind(on_select=lambda instance, x: setattr(button, 'text', x))
        for i in range(10):
            item = Button(text='hello %d' % i, size_hint_y=None, height=44)
            item.bind(on_release=lambda btn: dp.select(btn.text))
            dp.add_widget(item)
        dp.open(button)

    def touch_move(instance, touch):
        instance.center = touch.pos

    btn = Button(text='SHOW', size_hint=(None, None), pos=(300, 200))
    btn.bind(on_release=show_dropdown, on_touch_move=touch_move)

    runTouchApp(btn)
Ejemplo n.º 35
0
                window.remove_widget(child)

            # put the video in fullscreen
            if state['parent'] is not window:
                state['parent'].remove_widget(self)
            window.add_widget(self)

            # ensure the video widget is in 0, 0, and the size will be
            # reajusted
            self.pos = (0, 0)
            self.size = (100, 100)
            self.pos_hint = {}
            self.size_hint = (1, 1)
        else:
            state = self._fullscreen_state
            window.remove_widget(self)
            for child in state['window_children']:
                window.add_widget(child)
            self.pos_hint = state['pos_hint']
            self.size_hint = state['size_hint']
            self.pos = state['pos']
            self.size = state['size']
            if state['parent'] is not window:
                state['parent'].add_widget(self)


if __name__ == '__main__':
    import sys
    from kivy.base import runTouchApp
    runTouchApp(VideoPlayer(source=sys.argv[1]))
Ejemplo n.º 36
0
if __name__ == '__main__':
    from kivy.base import runTouchApp
    from kivy.uix.boxlayout import BoxLayout
    from kivy.uix.label import Label
    from kivy.garden.roulette import Roulette, CyclicRoulette, \
        TimeFormatCyclicRoulette
    b = BoxLayout()
    b.add_widget(Roulette(density=2.8, selected_value=2013))
    b.add_widget(CyclicRoulette(cycle=12, density=2.8, zero_indexed=False))
    b.add_widget(CyclicRoulette(cycle=30, density=2.8, zero_indexed=False))
    b.add_widget(TimeFormatCyclicRoulette(cycle=24))
    b.add_widget(TimeFormatCyclicRoulette(cycle=60))
    b.add_widget(TimeFormatCyclicRoulette(cycle=60))
    selected_value = Label()
    rolling_value = Label()
    for c in b.children:
        c.bind(selected_value=lambda _, val: selected_value.setter('text')
               (_, 'selected_value:\n' + str(val)),
               rolling_value=lambda _, val: rolling_value.setter('text')
               (_, 'rolling_value:\n' + str(val)))

    b.add_widget(selected_value)
    b.add_widget(rolling_value)

    runTouchApp(b)
Ejemplo n.º 37
0
                    self._start_repeat_key, 0.5)
            self.repeat_touch = touch

            self.process_key_on(touch)
            touch.grab(self, exclusive=True)

        else:
            super(VKeyboard, self).on_touch_down(touch)
        return True

    def on_touch_up(self, touch):
        if touch.grab_current is self:
            self.process_key_up(touch)

            if self._start_repeat_key_ev is not None:
                self._start_repeat_key_ev.cancel()
                self._start_repeat_key_ev = None
            if touch == self.repeat_touch:
                if self._repeat_key_ev is not None:
                    self._repeat_key_ev.cancel()
                    self._repeat_key_ev = None
                self.repeat_touch = None

        return super(VKeyboard, self).on_touch_up(touch)


if __name__ == '__main__':
    from kivy.base import runTouchApp
    vk = VKeyboard(layout='azerty')
    runTouchApp(vk)
Ejemplo n.º 38
0
    def _keyboard_closed(self):
        print('My keyboard have been closed!')
        self._keyboard.unbind(on_key_down=self._on_keyboard_down)
        self._keyboard = None

    def _on_keyboard_down(self, keyboard, keycode, text, modifiers):
        # Keycode is composed of an (integer, string)

        # quit if space or q
        if keycode[1] == 'q':
            self.dismiss()

        # If we hit escape, release the keyboard
        if keycode[1] == 'escape':
            keyboard.release()

        # Return True to accept the key. Otherwise, it will be used by
        # the system.
        return True


    def dismiss(self, *args, **kwargs):
        print('clicked')
        Window.close()


if __name__ == '__main__':
        from kivy.base import runTouchApp
        runTouchApp(Alert(title="Battery Warning Alert", message="Swipe or Hit Q to escape"))
Ejemplo n.º 39
0
        if self.have_capslock:
            ret.append("capslock")
        return ret

    def on_touch_down(self, touch):
        x, y = touch.pos
        if not self.collide_point(x, y):
            return
        if self.disabled:
            return True

        x, y = self.to_local(x, y)
        if not self.collide_margin(x, y):
            self.process_key_on(touch)
            touch.grab(self, exclusive=True)
        else:
            super(VKeyboard, self).on_touch_down(touch)
        return True

    def on_touch_up(self, touch):
        if touch.grab_current is self:
            self.process_key_up(touch)
        return super(VKeyboard, self).on_touch_up(touch)


if __name__ == "__main__":
    from kivy.base import runTouchApp

    vk = VKeyboard(layout="azerty")
    runTouchApp(vk)
Ejemplo n.º 40
0
    list_size: int(dial.value)

    BoxLayout:
        orientation: 'vertical'
        DialSlider:
            id: dial
            dial_axis: 'x'
            min: 0
            max: 500
        Label:
            text: 'Num_Items: %d' % len(testview.data)
        Label:
            text: 'Navigation ID: %s' % testview.nav_id
        Label:
            text: 'Reference: %0.2f' % testview.reftop_id


    TestRecycleView:
        id: testview
        dial_axis: 'y'
        viewclass: 'TestItem'
        data: [{'number': i} for i in range(0, root.list_size)]

""")




if __name__ == '__main__':
   runTouchApp(widget=TestWidget())
Ejemplo n.º 41
0
            ActionOverflow:
            ActionButton:
                text: 'Btn0'
                icon: 'atlas://data/images/defaulttheme/audio-volume-high'
            ActionButton:
                text: 'Btn1'
            ActionButton:
                text: 'Btn2'
            ActionGroup:
                text: 'Group 1'
                ActionButton:
                    text: 'Btn3'
                ActionButton:
                    text: 'Btn4'
            ActionGroup:
                dropdown_width: 200
                text: 'Group 2'
                ActionButton:
                    text: 'Btn5'
                ActionButton:
                    text: 'Btn6'
                ActionButton:
                    text: 'Btn7'
''')

    class MainWindow(FloatLayout):
        pass

    float_layout = MainWindow()
    runTouchApp(float_layout)
Ejemplo n.º 42
0
    with s:
        Builder.load_string('''
<TestButton>:
    canvas:
        Color:
            rgb: (.3, .2, 0) if self.state == 'normal' else (.7, .7, 0)
        Rectangle:
            pos: self.pos
            size: self.size
        Color:
            rgb: 1, 1, 1
        Rectangle:
            size: self.texture_size
            pos: self.center_x - self.texture_size[0] / 2., self.center_y - self.texture_size[1] / 2.
            texture: self.texture

    # invalid... for testing.
    #on_touch_up: root.d()
    #on_touch_down: root.f()
    on_release: root.args()
    #on_press: root.args()
''')
        b = TestButton(text='Hello World')
        s.add_widget(b)

        # this exception is within the "with" block, but will be ignored by
        # default because the sandbox on_exception will return True
        raise Exception('hello')

    runTouchApp(s)
Ejemplo n.º 43
0
    def show_output(self, data, dt):
        '''Show output to user.
        '''
        self.text_input.show_output(data)

    def _show_prompt(self, *args):
        '''Show prompt to user and asks for input.
        '''
        self.text_input.show_output(self.prompt)

    def get_input(self, prompt):
        '''Get input from user.
        '''
        import time
        self.prompt = prompt
        Clock.schedule_once(self._show_prompt, 0.1)
        while not self._ready_to_input and not self._exit:
            time.sleep(0.05)

        self._ready_to_input = False
        return self.text_input.last_line

    def exit(self):
        '''Exit PythonConsole
        '''
        self._exit = True
        self.sh.exit()

if __name__ == '__main__':
    runTouchApp(PythonConsole())
Ejemplo n.º 44
0
    def on_touch_up(self, touch):
        if touch.grab_current == self:
            if (
                touch.ud['page'] == 'previous' and
                abs(touch.x - touch.ox) / self.width > self.swipe_threshold
            ):
                self.page -= 1
            elif (
                touch.ud['page'] == 'next' and
                abs(touch.x - touch.ox) / self.width > self.swipe_threshold
            ):
                self.page += 1
            else:
                self._trigger_layout()

            touch.ungrab(self)
        return self.children[-self.page + 1].on_touch_up(touch)


if __name__ == '__main__':
    from kivy.base import runTouchApp
    from kivy.uix.button import Button

    pl = PageLayout()
    for i in range(1, 4):
        b = Button(text='page%s' % i)
        pl.add_widget(b)

    runTouchApp(pl)
                     font_name=self.font_name)
        label.resolve_font_name()
        label.render()

        # get lines
        font_name = self.font_name
        font_size = self.font_size
        halign = self.halign
        data = ({
            "index": index,
            "viewclass": "ScrollLabelPart",
            "text": " ".join([word.text for word in line.words]),
            "font_name": font_name,
            "font_size": font_size,
            "height": line.h,
            "size_hint_y": None,
            "halign": halign,
        } for index, line in enumerate(label._cached_lines))
        self.ids.rv.data = data

if __name__ == "__main__":
    from kivy.base import runTouchApp
    LOREM = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur nec arcu accumsan, lacinia libero sed, cursus nisi. Curabitur volutpat mauris id ornare finibus. Cras dignissim arcu viverra, bibendum est congue, tempor elit. Vivamus luctus sapien sapien, id tincidunt eros molestie vitae. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut commodo eget purus vel efficitur. Duis facilisis ex dolor, vel convallis odio pharetra quis. Vivamus eu suscipit tortor. Proin a tellus a nisl iaculis aliquam. Nam tristique ipsum dui, ut faucibus libero lacinia id. Pellentesque eget rhoncus justo, quis interdum eros. Suspendisse felis lorem, gravida in orci ac, auctor malesuada turpis. Fusce dapibus urna dolor, id viverra enim semper a. Proin dignissim neque quis ante commodo feugiat.
Duis dictum sagittis urna nec dapibus. Vestibulum ac elit vel nunc euismod lobortis. Vivamus sit amet tortor in diam consectetur ultrices vitae vulputate leo. Aenean vehicula orci leo, eget fringilla enim condimentum eget. Sed sapien lacus, vulputate nec ligula eget, luctus feugiat risus. Nullam ultricies quam ac metus imperdiet, eget scelerisque dolor commodo. Ut nec elementum orci. Cras massa lacus, consectetur varius est a, congue pulvinar magna. Proin nec sapien facilisis, tristique turpis vel, malesuada leo. Phasellus faucibus justo vel risus tristique, in laoreet ligula vestibulum. Vestibulum varius eget nibh nec convallis. Morbi eu diam at turpis mollis hendrerit. Aenean sed turpis lectus.
Suspendisse pharetra ligula nec faucibus mattis. Aliquam et felis eget augue efficitur aliquam viverra ut tellus. Aliquam sagittis ut sapien venenatis condimentum. Quisque in turpis ac nisi vehicula commodo vel porttitor erat. Maecenas lobortis, sapien dictum congue gravida, nulla urna ultricies lorem, at tincidunt ex arcu nec eros. Maecenas egestas a augue sit amet euismod. Praesent ut sapien metus. Curabitur lorem erat, consectetur quis rhoncus quis, tristique ac ligula. Suspendisse justo magna, cursus id mauris et, lacinia egestas neque.
Suspendisse bibendum sit amet est eget ullamcorper. Duis pellentesque tristique nisi. Donec id dolor eget arcu lobortis sollicitudin vel et justo. Vivamus vel risus eget felis condimentum tempus ac sed dui. Donec placerat risus quis metus auctor sagittis. Pellentesque vel sem dolor. Praesent erat eros, facilisis placerat ultrices et, interdum quis risus. Donec eleifend risus dapibus, laoreet felis ut, fermentum neque. Aenean purus elit, congue non tempus quis, dictum quis metus. Maecenas finibus rutrum bibendum. Ut vestibulum dapibus felis vel luctus. Aliquam vitae consequat eros, quis ultricies tortor. Quisque eu accumsan erat, id commodo nisi.
Etiam nec risus porttitor, placerat est et, facilisis diam. Etiam vel feugiat ligula. Aliquam at quam congue, lacinia velit nec, congue nibh. In varius quis elit vel sollicitudin. Vivamus molestie elementum ipsum et vehicula. Etiam non augue quis tortor ultrices maximus. Etiam vel blandit nibh. Nullam facilisis posuere erat vel mattis. Vestibulum mattis condimentum purus efficitur vehicula. Aliquam consequat interdum eros eu semper. Etiam feugiat, erat at tempor tincidunt, odio eros maximus sapien, sit amet lacinia nibh tortor quis dui. In hac habitasse platea dictumst.
"""

    runTouchApp(ScrollLabel(text=LOREM))
Ejemplo n.º 46
0
    def on_dismiss(self):
        pass


if __name__ == '__main__':
    from kivy.base import runTouchApp
    from kivy.uix.button import Button
    from kivy.uix.label import Label
    from kivy.uix.gridlayout import GridLayout
    from kivy.core.window import Window

    # add view
    content = GridLayout(cols=1)
    content.add_widget(Label(text='This is a hello world'))
    view = ModalView(size_hint=(None, None), size=(256, 256), auto_dismiss=True)
    view.add_widget(content)

    def open_view(btn):
        view.open()

    layout = GridLayout(cols=3)
    for x in xrange(9):
        btn = Button(text='click me %s' % x)
        btn.bind(on_release=view.open)
        layout.add_widget(btn)
    Window.add_widget(layout)

    view.open()

    runTouchApp()
Ejemplo n.º 47
0
            return True

    def _filepopup_callback(self, instance):
            if instance.is_canceled():
                return
            s = 'Path: %s' % instance.path
            if instance.__class__.__name__ == 'XFileSave':
                s += ('\nFilename: %s\nFull name: %s' %
                      (instance.filename, instance.get_full_name()))
            else:
                s += ('\nSelection: %s' % instance.selection)
            XNotification(title='Pressed button: ' + instance.button_pressed,
                          text=s, show_time=5)

    def _open_dialog_demo(self):
        XFileOpen(on_dismiss=self._filepopup_callback, path=expanduser(u'~'),
                  multiselect=True)

    def _save_dialog_demo(self):
        XFileSave(on_dismiss=self._filepopup_callback, path=expanduser(u'~'))

    def _folder_dialog_demo(self):
        XFolder(on_dismiss=self._filepopup_callback, path=expanduser(u'~'))


if __name__ == '__main__':
    import kivy
    kivy.require('1.9.1')
    from kivy.base import runTouchApp
    runTouchApp(XPopupDemo())
Ejemplo n.º 48
0
from kivy.uix.boxlayout import BoxLayout
from kivy.base import runTouchApp
from kivy.lang import Builder

Builder.load_string(
'''
#:import Label kivy.uix.label.Label
#:import SimpleListAdapter kivy.adapters.simplelistadapter.SimpleListAdapter

<MyListView>:
    ListView:
        adapter:
            SimpleListAdapter(data=["item #{0}".format(num) for num in range(100)],cls=Label)

'''
)

class Container(BoxLayout):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)


if __name__=='__main__':
    runTouchApp(Container())
Ejemplo n.º 49
0
#import gmaps
#from kivy.app import App

#from kivy.garden.mapview import MapView
#from kivy.app import App

#class MapViewApp(App):
#    def build(self):
#        mapview = MapView(zoom=20, lat=59.971530, lon=30.323057)
#        return mapview

#a=MapViewApp()
#a.run()
from kivy.base import runTouchApp
from kivy.lang import Builder

if __name__ == '__main__' and __package__ is None:
    from os import sys, path
    sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
#kw ={}
root = Builder.load_file("maptry.kv")

runTouchApp(root)
Ejemplo n.º 50
0
from kivy.app import App
from kivy.base import runTouchApp
from kivy.lang import Builder
from kivy.uix.gridlayout import GridLayout

runTouchApp(
    Builder.load_string('''
StackLayout:
    #layout left to right, bottom to top
    #choose 'rl-bt' for right to left and 'tb-rl/lr' for top to bottom
    orientation: 'lr-bt'
    padding: 10
    spaceing: 5 #gap between buttons
    Button:
        text: 'S1'
        size_hint: .2,.1
    Button:
        text: 'S2'
        size_hint: .2,.1
    Button:
        text: 'S3'
        size_hint: .2,.1
    Button:
        text: 'S4'
        size_hint: .2, .1

'''))
Ejemplo n.º 51
0
    except OSError:
        return False
    except:
        return False

def compute_size(maxs, imgw, imgh):
    if imgw > imgh:
        return maxs, maxs*imgh/imgw
    else:
        return maxs*imgw/imgh, maxs

if __name__ == "__main__":
    from kivy.base import runTouchApp
    from kivy.uix.boxlayout import BoxLayout
    from kivy.uix.label import Label

    box = BoxLayout(orientation="vertical", width=800, height=480)
    fileChooser = FileChooserThumbView(thumbsize=64,size_hint=(1.0,0.8))
    label = Label(markup=True,size_hint=(1,0.2))
    fileChooser.mylabel = label

    box.add_widget(fileChooser)
    box.add_widget(label)

    def setlabel(instance, value):
        instance.mylabel.text = "[b]Selected:[/b] {0}".format(value)

    fileChooser.bind(selection=setlabel)

    runTouchApp(box)
    ListView:
        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)


class MainView(GridLayout):
    """
    Implementation of a ListView using the kv language.
    """
    def __init__(self, **kwargs):
        kwargs['cols'] = 1
        super(MainView, self).__init__(**kwargs)

        listview_modal = ListViewModal()

        self.add_widget(listview_modal)


if __name__ == '__main__':
    from kivy.base import runTouchApp
    runTouchApp(MainView(width=800))
Ejemplo n.º 53
0
for index in range(10):
    # when adding widgets, we need to specify the height manually (disabling
    # the size_hint_y) so the dropdown can calculate the area it needs.
    btn = Button(text='Value %d' % index, size_hint_y=None, height=44)

    # for each button, attach a callback that will call the select() method
    # on the dropdown. We'll pass the text of the button as the data of the
    # selection.
    # 릴리즈될 때 dropdown의 select 이벤트 호출
    btn.bind(on_release=lambda btn: dropdown.select(btn.text))

    # then add the button inside the dropdown
    dropdown.add_widget(btn)

# create a big main button
mainbutton = Button(text='Hello', size_hint=(None, None))

# show the dropdown menu when the main button is released
# note: all the bind() calls pass the instance of the caller (here, the
# mainbutton instance) as the first argument of the callback (here,
# dropdown.open.).
mainbutton.bind(on_release=dropdown.open)

# one last thing, listen for the selection in the dropdown list and
# assign the data to the button text.
# 드랍다운의 select 이벤트에 핸들러 연결
dropdown.bind(on_select=lambda instance, x: setattr(mainbutton, 'text', x))

# App 인스턴스 만들지 않고 어플리케이션 실행
runTouchApp(mainbutton)
Ejemplo n.º 54
0
            video = RstVideoPlayer(
                source=uri,
                size_hint=(None, None),
                size=(width, height))
            anchor = AnchorLayout(size_hint_y=None, height=height + 20)
            anchor.add_widget(video)
            self.current.add_widget(anchor)

    def set_text(self, node, parent):
        text = self.text
        if parent == 'term' or parent == 'field_name':
            text = '[b]%s[/b]' % text
        # search anchors
        node.text = self.colorize(text, parent)
        node.bind(on_ref_press=self.root.on_ref_press)
        if self.text_have_anchor:
            self.root.add_anchors(node)
        self.text = ''
        self.text_have_anchor = False

    def colorize(self, text, name):
        return '[color=%s]%s[/color]' % (
            self.root.colors.get(name, self.root.colors['paragraph']),
            text)


if __name__ == '__main__':
    from kivy.base import runTouchApp
    import sys
    runTouchApp(RstDocument(source=sys.argv[1]))
Ejemplo n.º 55
0
        pos: 500, 300

<ClockRect>:
    canvas:
        Color:
            rgba: 1, 0, 0, 1
        Rectangle:
            pos: self.pos
            size: self.size

<AnimRect>:
    canvas:
        Color:
            rgba: 0, 1, 0, 1
        Rectangle:
            pos: self.pos
            size: self.size
''')

class Root(Widget):
    pass

class ClockRect(Widget):
    pass


class AnimRect(Widget):
    pass

runTouchApp(Root())
Ejemplo n.º 56
0
# create a dropdown with 10 buttons
dropdown = DropDown()
for index in range(10):
    # when adding widgets, we need to specify the height manually (disabling
    # the size_hint_y) so the dropdown can calculate the area it needs.
    btn = Button(text='Value %d' % index, size_hint_y=None, height=44)

    # for each button, attach a callback that will call the select() method
    # on the dropdown. We'll pass the text of the button as the data of the
    # selection.
    btn.bind(on_release=lambda btn: dropdown.select(btn.text))

    # then add the button inside the dropdown
    dropdown.add_widget(btn)

# create a big main button
mainbutton = Button(text='Hello', size_hint=(None, None))

# show the dropdown menu when the main button is released
# note: all the bind() calls pass the instance of the caller (here, the
# mainbutton instance) as the first argument of the callback (here,
# dropdown.open.).
mainbutton.bind(on_release=dropdown.open)

# one last thing, listen for the selection in the dropdown list and
# assign the data to the button text.
dropdown.bind(on_select=lambda instance, x: setattr(mainbutton, 'text', x))

runTouchApp(mainbutton)
Ejemplo n.º 57
0
            return
        touch.grab(self)
        self.touch_distance = 0
        self.touch_control = touch
        return True

    def on_touch_move(self, touch):
        if touch.grab_current is not self:
            return
        self.touch_distance = touch.x - touch.ox
        return True

    def on_touch_up(self, touch):
        if touch.grab_current is not self:
            return
        touch.ungrab(self)
        # depending of the distance, activate by norm pos or invert
        if abs(touch.ox - touch.x) < 5:
            self.active = not self.active
        else:
            self.active = self.active_norm_pos > 0.5
        Animation(active_norm_pos=int(self.active), t='out_quad',
                  d=.2).start(self)
        self.touch_control = None
        return True

if __name__ == '__main__':
    from kivy.base import runTouchApp
    runTouchApp(Switch())

from kivy.uix.spinner import Spinner
from kivy.base import runTouchApp

spinner = Spinner(
    text='Home',
    values=('Home', 'Work', 'Other', 'Custom'),
    size_hint=(None, None), size=(100, 44),
    pos_hint={'center_x': .5, 'center_y': .5})

def show_selected_value(spinner, text):
    print('The spinner', spinner, 'have text', text)

spinner.bind(text=show_selected_value)

runTouchApp(spinner)
Ejemplo n.º 59
0
        return self.value / float(d)

    def set_norm_value(self, value):
        self.value = value * self.max

    value_normalized = AliasProperty(get_norm_value, set_norm_value, bind=("value", "max"))
    """Normalized value inside the range 0-1::

        >>> pb = ProgressBar(value=50, max=100)
        >>> pb.value
        50
        >>> slider.value_normalized
        0.5

    :data:`value_normalized` is an :class:`~kivy.properties.AliasProperty`.
    """

    max = NumericProperty(100.0)
    """Maximum value allowed for :data:`value`.

    :data:`max` is a :class:`~kivy.properties.NumericProperty` and defaults to
    100.
    """


if __name__ == "__main__":

    from kivy.base import runTouchApp

    runTouchApp(ProgressBar(value=50))
Ejemplo n.º 60
0
        box.add_widget(cancel_button)
        box.add_widget(ok_button)
        self.grid.add_widget(box)

        self.main_layout.add_widget(self.grid)

        self.content = self.main_layout
        self.size_hint = self.pHint
        Window.release_all_keyboards()
        self.open()

    def ok_callback(self, _):
        selection = []
        for i, check_box in enumerate(self.opt_boxes):
            if check_box.active:
                selection.append(self.labels[i].text)
        self.callback(selection)
        self.dismiss()

    def cancel_callback(self, _):
        self.dismiss()


if __name__ == "__main__":
    from kivy.base import runTouchApp

    def cb(list_of_selection):
        print(list_of_selection)
    c = MultiSelectPopUp(title="Test", option_list=["Item1", "Item2", "Item3"], callback=cb, option_init=[True, False, True])
    runTouchApp(c)