Example #1
0
	def build(self):
		Window.bind(on_key_down=self.on_key_down)
		root = Widget()
		self.container = Container(ws_count=7)
		# here we add an instance of container to the window, ws_count shows number of workspaces we need
		root.add_widget(self.container)
		return root
Example #2
0
 def __init__(self, **kwargs):
     self.slides = []
     super(Slides, self).__init__(**kwargs)
     Window.bind(on_keyboard=self.on_keyboard)
     Clock.schedule_interval(self.increase_time, 1 / 30.0)
     Clock.schedule_once(self.init, 0)
     self.add_widget(SlidesForeground(slides=self))
Example #3
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()
Example #4
0
 def on_code_input_focus(self, *args):
     '''Focus on CodeInput, to enable/disable keyboard listener
     '''
     if args[1]:
         Window.bind(on_keyboard=self.on_keyboard)
     else:
         Window.unbind(on_keyboard=self.on_keyboard)
 def _on_keyboard_down(self,keyboard,keycode,text,modifiers):
     if(keycode[1] == 'up'):
         self.draw_up()
     if(keycode[1] == 'left'):
         self.draw_left()
     if(keycode[1] == 'down'):
         self.draw_down()
     if(keycode[1] == 'right'):
         self.draw_right()
     if(keycode[1] == 'r'):
         self.output_eval()
     ## START TESTING WHEN ENTER IS PUSHED ##
     if(keycode[1] == 'enter'):
         self.current_position_X = 200
         self.current_position_Y = 200
         self.togglewriting()
         if self.writing == True:
             self.path = [Point(self.current_position_X,self.current_position_Y)]
             self.goals.createNewGoal(self.current_position_X,self.current_position_Y)
             self.draw_goal()
         if self.writing == False:
             self.canvas.clear()
             self.canvas.add(self.boxes)
     if keycode[1] == "s":
         Window.screenshot(name='screenshot.jpg')
 def _in_out(self, dt):
     self._duration -= dt * 1000
     if self._duration <= 0:
         self._transparency = 1.0 + (self._duration / self._rampdown)
     if -(self._duration) > self._rampdown:
         Window.remove_widget(self)
         return False
Example #7
0
    def do_email(self, popup, address, filename, widget):
        thread = SenderThread(address, filename)
        thread.daemon = True
        thread.start()
        popup.dismiss()

        layout = BoxLayout(orientation='vertical')
        label = Label(
            text='Just sent this image to:\n\n{}'.format(address),
            font_size=30)
        button = Button(
            text='Awesome!',
            font_size=30,
            background_color=(0, 1, 0, 1))
        layout.add_widget(label)
        layout.add_widget(button)

        popup = Popup(
            title='Just thought you should know...',
            content=layout,
            size_hint=(.5, .5))

        button.bind(on_release=popup.dismiss)
        from kivy.core.window import Window

        Window.release_all_keyboards()
        self.reset_email_textinput()
        popup.open()
Example #8
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 #9
0
 def on_listen_key(self, instance, value, *args):
     """Enable/disable keyboard listener
     """
     if value:
         Window.bind(on_key_down=self._on_key_down)
     else:
         Window.unbind(on_key_down=self._on_key_down)
Example #10
0
    def build(self):
        sm = ScreenManager(transition=WipeTransition())
        sm.add_widget(MainWindow(name='mainwindow'))
        sm.add_widget(StandardWidgets(name='inputstation'))
        
        Window.bind(on_keyboard=self.hook_keyboard)
        
        self.content = content = BoxLayout()
    
        sc = Trainccs()
        
        #~ spinner = Spinner(
            #~ text='About',
            #~ values=('About',),
            #~ size_hint=(None, None),
            #~ size=(100, 44),
            #~ 
            #~ )
            #~ pos_hint={'center_x': 0.5, 'center_y': 0.5})
            
        #~ sc.add_widget(spinner)
        
        sc.content.add_widget(sm)

        return sc
Example #11
0
    def open_pampamt(self):

        window.get_running_app().stop()
        Window.close()

        os.chdir(user + '/.PampaMT')
        os.system('./PampaMT.py')
Example #12
0
 def on_start(self):
     self.spacing = 0.5 * self.root.width
     self.background = self.root.ids.background
     self.bird = self.root.ids.bird
     Clock.schedule_interval(self.update, 1.0/500.0)
     Window.bind(on_key_down=self.on_key_down)
     self.background.on_touch_down = self.user_action
Example #13
0
    def __init__(self, **kwargs):
        super(LayoutFunctioning, self).__init__(**kwargs)

        # Enable send_btn after some seconds
        self.cb_disablesend = lambda dt: self.disablesend(False)
        Clock.schedule_once(self.cb_disablesend, self.send_disabled_t)

        # When previously saw finish screen
        if self.master_kanji.cur_framenum == -1:
            self.master_kanji.nextkanji()
            self.reinitscreen(0)
        else:
            self.reinitscreen(self.master_kanji.dbcurrent("nextKanji"))

        # First time opening app show explanation story
        if self.master_kanji.cur_framenum == 0:
            print("First time app")
            self.master_kanji.story_show = True

        # Link button to website
        print("!!!   DEBUG UTF-8   !!!")
        #print(self.master_kanji.cur_framekanji)
        print(type(self.master_kanji.cur_framekanji))
        self.ww_link = "http://kanji.koohii.com/study/kanji/{}".format(self.master_kanji.cur_framekanji)  # "TODO")

        # Keyboard height
        #Clock.schedule_once(lambda dt: self.storykeybheight())

        print("Keyboard binding")
        Window.bind(on_keyboard=self.storykeybheight)

        print("--- INIT LayoutFunctioning COMPLETED ---\n")
Example #14
0
File: app.py Project: 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)
Example #15
0
 def __init__(self, **kwargs):
     Builder.load_string(FLYIN_PANEL_LAYOUT)
     super(FlyinPanel, self).__init__(**kwargs)
     self.hide_decay = Clock.create_trigger(lambda dt: self.hide(), self.SESSION_HIDE_DELAY)
     Window.bind(mouse_pos=self.on_mouse_pos)
     Window.bind(on_motion=self.on_motion)
     Clock.schedule_once(lambda dt: self.show())
Example #16
0
    def __init__(self, **kwargs):
        
        pos = kwargs.pop('pos', (-100,-100))
        
        super(Launcher, self).__init__(source='docklauncher512x512.png',
                                        size_hint=(None,None),
                                       allow_stretch=True,
                                        **kwargs)
        
        #icons sizes
        self.selected_scale = 1.5
        self.unselected_scale = .3
        
        print 'Launcher image size: ', self.size
            
        #for mouse over event
        Window.bind(mouse_pos=self.mouse_over)
    
    
        self.animin = Animation(width=100, height=100, duration=.3)
        self.animax = Animation(width=400, height=400, duration=.3)
        
        
        '''
        self.animin = Animation(scale_x=1, scale_y=1, duration=.3)
        self.animax = Animation(scale_x=2, scale_y=2, duration=.3)
        '''
            
        self.animin.bind(on_complete=self.on_minimized)
        self.animax.bind(on_complete=self.on_maximized)

        self.state = 'minimizing'
    
        self.animin.start(self)
Example #17
0
 def __init__(self, **kwargs):
     super(CreateAccountDialog, self).__init__(**kwargs)
     self.action = kwargs.get('action')
     _trigger_size_dialog = Clock.create_trigger(self._size_dialog)
     Window.bind(size=_trigger_size_dialog,
                 rotation=_trigger_size_dialog)
     _trigger_size_dialog()
Example #18
0
    def on_start(self):
        Logger.debug("%s: on_start %s" % (APP, datetime.now()))

        from kivy.core.window import Window
        Window.bind(on_keyboard=self.on_keypress)

        if platform == 'android':
            android.map_key(android.KEYCODE_BACK, 1001)

            import android.activity as python_activity
            python_activity.bind(on_new_intent=self.on_new_intent)
            self.on_new_intent(activity.getIntent())

        self.server_url = self.config.get('general', 'server_url')

        self.root.bind(
            on_touch_down=lambda *a: setattr(self, 'delay_image_loading', True),
            on_touch_up=lambda *a: setattr(self, 'delay_image_loading', False))

        imagedir = ImageDir(server_url=self.server_url)
        wp = 'with_previous'
        imagedir.bind(
            on_navigate_top=lambda *a: setattr(self.root, wp, False),
            on_navigate_down=lambda *a: setattr(self.root, wp, True),
            on_img_selected=self.load_carousel,
            path=lambda w,v: setattr(self.root, 'title', v),
            on_loading_start=lambda *a: setattr(self.root, 'loading', True),
            on_loading_stop=lambda *a: setattr(self.root, 'loading', False))
        self.imagedir = imagedir

        self.root.container.add_widget(imagedir)
        self.root.bind(on_touch_down=lambda *a: Loader.pause(),
                       on_touch_up=lambda *a: Loader.resume())
        Loader.max_upload_per_frame = 1  # Maximize interactivity
 def __init__(self, **kwargs):
     self.writing = False
     Window.bind(mouse_pos=self.update_pos)
     self._keyboard = Window.request_keyboard(self._keyboard_closed,self)
     self._keyboard.bind(on_key_down=self._on_keyboard_down)
     super(MyPaintWidget, self).__init__(**kwargs)
     self.connect()
Example #20
0
 def print_ticket_grupal(self, cant, delegacion, cat, date, recibo):
     """
     Imprime el ticket grupal para el día(date), para la delegación
     dada y la cantidad solicitada.
     """
     user = user_session.get_user()
     id_log = controlador.insert_log(user, 'comprar_grupal', UNIDAD)
     ticket_grupal = controlador.comprar_ticket_grupal(
         cant, delegacion, cat, date, recibo, id_log
     )
     row = controlador.get_ticket_grupal_by_id(ticket_grupal)
     id_log = controlador.insert_log(user, 'imprimir_grupal', UNIDAD)
     controlador.insert_ticket_log(ticket_grupal, id_log)
     print_thread = Thread(
         target=impresora.imprimir_ticket_grupal,
         args=(
             user['nombre'],
             user['dni'],
             row['id'],
             UNIDAD,
             row['fecha'].strftime('%d/%m/%Y'),
             row['cantidad'],
             row['barcode'],
             row['importe'],
             row['delegacion'],
             row['recibo']
         )
     )
     print_thread.start()
     Window.release_all_keyboards()
     self.cancel()
Example #21
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")
Example #22
0
 def _reload_keypress(self, instance, code, *largs):
     if code != 286:
         return
     for child in Window.children[:]:
         Window.remove_widget(child)
     root = Builder.load_file(self.options['filename'])
     Window.add_widget(root)
Example #23
0
    def on_touch_down(self, touch, *kwargs):
        if not self.collide_point(*touch.pos):
            return
        if self.keyboard_mode == "global":
            self.request_keyboard()
        else:
            Window.release_all_keyboards()
            self.browser.GetFocusedFrame().ExecuteJavascript("__kivy__keyboard_requested = false;")

        touch.moving = False
        self.touches.append(touch)
        touch.grab(self)

        if len(self.touches) == 1:
            # Only mouse click when single touch
            y = self.height-touch.pos[1] + self.pos[1]
            x = touch.x - self.pos[0]
            self.browser.SendMouseClickEvent(
                x,
                y,
                cefpython.MOUSEBUTTON_LEFT,
                mouseUp=False,
                clickCount=1
            )
        return True
Example #24
0
 def start_screen(self):
     """Displays the start screen with the title and play button. Also sets the initial difficulty variables."""
     self.clear_widgets()
     #create the logo
     self.logo = Label(text='Expression Collector',font_size=0.1*Window.height)
     self.logo.center_x = Window.width/2
     self.logo.center_y = Window.height/2
     self.add_widget(self.logo)
     #create the playbtn
     self.playbtn = Button(text='play',font_size=0.05*Window.height,background_color=[0,0,0,0])
     self.playbtn.center_x = Window.width/2
     self.playbtn.center_y = Window.height/2 - 0.1*Window.height
     self.playbtn.bind(on_release=self.play)
     self.add_widget(self.playbtn)
     #create the howtoplaybtn 100 px under the playbtn
     self.howtoplaybtn = Button(text='how to play',font_size=0.05*Window.height,background_color=[0,0,0,0])
     self.howtoplaybtn.center_x = Window.width/2
     self.howtoplaybtn.center_y = self.playbtn.center_y - 100
     self.howtoplaybtn.bind(on_release=self.howtoplay)
     self.add_widget(self.howtoplaybtn)
     #make bindings to make start screen fluid
     Window.bind(size=self.adjust_start_widgets)
     #create initial difficulty variables
     self.MINUTE = 0 #it has been 0 minutes so far
     self.MAX_NUMBER = 2 # the biggest number that can be part of an expression
     self.MAX_LENGTH = 2 #the maximum number of numbers in an expression
     self.AVAILABLE_OPERATORS = ['+','-'] #at first just + and - operators are available
     self.sound = SoundLoader.load('startscreen.wav')
     self.sound.loop = True
     self.sound.play()
Example #25
0
    def play(self,*args):
        """Goes from the start screen to the game screen. Creates the playerexpr, grid, and random Exprs."""
        #Delete the logo and button
        self.remove_widget(self.logo)
        self.remove_widget(self.playbtn)
        self.remove_widget(self.howtoplaybtn)
        #Delete start screen music, load game music
        self.sound.stop()
        self.sound = SoundLoader.load('game.wav')
        self.sound.loop = True
        self.sound.play()

        #create the grid
        global grid
        grid = Grid()
        grid.adjust_grid() #Adjust/draw the grid to the initial window size
        Window.bind(size=grid.adjust_grid) #bind Window.size -> grid.adjust_grid
        self.add_widget(grid)

        #create the playerexpr
        global playerexpr
        playerexpr = PlayerExpr(value=1,text='1',color=[1,1,1,1],font_size=grid.cell_height)
        self.add_widget(playerexpr)

        Clock.schedule_interval(playerexpr.check_collisions,1/30.0) #Check for collisions with PlayerExpr
        Clock.schedule_interval(self.create_expr,2) #create Expr objects for the game
        Clock.schedule_interval(self.make_harder,60) #make the game harder every 60 seconds

        #play bindings
        Window.bind(size=self.reposition_children) #bind window resizing to repositioning all of its children
Example #26
0
	def __init__(self, **kwargs):
		super(ThemeManager, self).__init__(**kwargs)
		self._win_size = Window.size
		Window.bind(on_resize=lambda *x: setattr(self, '_win_size', Window.size),
					on_rotate=lambda *x: setattr(self, '_win_size', Window.size))
		for font in FONTS:
			LabelBase.register(**font)
Example #27
0
    def __init__(self):
        super(TextAdventureGame, self).__init__()
        self.backgroundWidget = Widget()
        with self.backgroundWidget.canvas.before:
            pass
            # Color(76. / 256., 230. / 256., 0., .5)
            # Rectangle(pos=(0, 0), size=Window.size)

        self.char = Character()
        self.world = self.createLandscape()
        self.world = self.generateTerrain(self.world)
        for i in range(randint(3, 6)):
            self.createRoom(self.world)
        self.worldWithCharacter = list(self.world)
        self.worldWithCharacter = self.placeChar(self.worldWithCharacter, self.char)
        self.worldLabel = Label(
            color=(76. / 256., 146. / 256., 0., 1.),
            text=self.joinRoom(self.world),
            markup=True,
            center_x=Window.width / 2,
            center_y=Window.height / 2,
            font_name="assets/fonts/DejaVuSansMono.ttf",
            font_size="20sp"
        )
        self.worldLabel.size = self.worldLabel.texture_size
        with self.worldLabel.canvas:
            Color(146. / 256., 76. / 256., 0., 1.)
            Rectangle(pos=self.worldLabel.pos, size=self.worldLabel.size)
        self.add_widget(self.backgroundWidget)
        self.add_widget(self.worldLabel)
        Window.bind(on_key_down=self.on_key_down)
Example #28
0
 def confirmacion(self):
     Window.release_all_keyboards()
     self.fecha = self.validar_anulacion()
     if self.fecha:
         self.popup = ConfirmPopup(text="\rSeguro deseas anular el ticket\r\n del día %s?" % (self.fecha))
         self.popup.bind(on_answer=self._on_answer)
         self.popup.open()
Example #29
0
 def set_tittle(self, *largs):
     ''' Sets the title of the window using the currently running
     tab. This is called at 1Hz. '''
     return
     Window.set_title('Filers v{}, CPL lab.{}{}'.format(
         __version__, Players.get_window_title(),
         VideoConverterController.get_window_title()))
Example #30
0
    def __init__(self, **kwargs):
        super(RaceCaptureApp, self).__init__(**kwargs)

        # We do this because when this app is bundled into a standalone app
        # by pyinstaller we must reference all files by their absolute paths
        # sys._MEIPASS is provided by pyinstaller
        if getattr(sys, 'frozen', False):
            self.base_dir = sys._MEIPASS
        else:
            self.base_dir = os.path.dirname(os.path.abspath(__file__))

        #RaceCapture serial I/O
        self._rc_api = RcpApi(on_disconnect=self._on_rcp_disconnect)

        #self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
        #self._keyboard.bind(on_key_down=self._on_keyboard_down)
        self.settings = SystemSettings(self.user_data_dir, base_dir=self.base_dir)
        self._databus = DataBusFactory().create_standard_databus(self.settings.systemChannels)
        self.settings.runtimeChannels.data_bus = self._databus
        HelpInfo.settings = self.settings

        Window.bind(on_keyboard=self._on_keyboard)
        self.register_event_type('on_tracks_updated')
        self.processArgs()
        self.settings.appConfig.setUserDir(self.user_data_dir)
        self.trackManager = TrackManager(user_dir=self.settings.get_default_data_dir(), base_dir=self.base_dir)
        self.setup_telemetry()
 def __init__(self, **kwargs):
     super(Game, self).__init__(**kwargs)
     Window.bind(on_resize=self.init)
Example #32
0
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 popup
    content = GridLayout(cols=1)
    content_cancel = Button(text='Cancel', size_hint_y=None, height=40)
    content.add_widget(Label(text='This is a hello world'))
    content.add_widget(content_cancel)
    popup = Popup(title='Test popup',
                  size_hint=(None, None),
                  size=(256, 256),
                  content=content,
                  disabled=True)
    content_cancel.bind(on_release=popup.dismiss)

    layout = GridLayout(cols=3)
    for x in range(9):
        btn = Button(text=str(x))
        btn.bind(on_release=popup.open)
        layout.add_widget(btn)

    Window.add_widget(layout)

    popup.open()

    runTouchApp()
Example #33
0
 def __init__(self, **kwargs):
     super(MyKeyboardListener, self).__init__(**kwargs)
     self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
     self._keyboard.bind(on_key_down=self._on_keyboard_down)
Example #34
0
 def close_tooltip(self, *args):
     try:
         Window.remove_widget(self.tooltip)
     except Exception as e:
         print 'Error occurred in close_tooltip: ', str(e)
Example #35
0
 def __init__(self, parent):
     super().__init__()
     self.parent_class = parent
     self.parent_class.add_widget(self, index=7)
     self.selected_widget = None
     Window.bind(on_resize=self.move_resize)
Example #36
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     Window.bind(on_joy_button_up=self.on_joy_button_up)
Example #37
0
 def minimize(self):
     Window.minimize()
Example #38
0
 def __init__(self, **kw):
     super(CoffeeMenu, self).__init__(**kw)
     Window.bind(on_keyboard=self.events_program)
Example #39
0
 def post_build_init(self, *args):
     Window.bind(on_keyboard=self.onBackBtn)
Example #40
0
 def __init__(self, **kwargs):
     super(PongGame, self).__init__(**kwargs)
     self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
     self._keyboard.bind(on_key_down=self._on_keyboard_down)
 def close(self, *_):
     App.get_running_app().stop()
     Window.close()
Example #42
0
 def process_startim(self):
     Window.set_title("Sonata's Revenge")
 def __init__(self, **kwargs):
     Window.bind(mouse_pos=self.on_mouse_pos)
     super(HoverBehavior, self).__init__(**kwargs)
Example #44
0
 def remove_info(self):
     Window.remove_widget(self.info)
Example #45
0
 def __init__(self, **kwargs):
     super(Manager, self).__init__(**kwargs)
     Window.bind(on_key_down=self._on_keyboard_down)
Example #46
0
 def respawn(self):
     if self._keyboard is None:
         print('My keyboard has been respawned!')
         self._keyboard = Window.request_keyboard(
             self._keyboard_closed, self, 'text')
         self._keyboard.bind(on_key_down=self._on_keyboard_down)
Example #47
0
 def __init__(self, **kwargs):
     super(MyApp, self).__init__(**kwargs)
     Window.bind(on_key_down=self.on_key_down)
Example #48
0
__status__ = "Developed"
'''For more information see:
www.github.com/zotho
'''

from space import Space
from fps import Fps
from lineprinter import LinePrinter

ANGLE = pi / 18.
'''Here window start create
For less wait to build
'''
from kivy.core.window import Window
Window.borderless = True
Window.hide()


class GravApp(App):
    def __init__(self, *args, filename=None, **kwargs):
        self.filename = filename
        super(GravApp, self).__init__(*args, **kwargs)

        self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
        self._keyboard.bind(on_key_down=self._on_keyboard_down,
                            on_key_up=self._on_keyboard_up)
        self._keyboard_modifiers = []

        # work aroung bug [1]
        self.y = 0
        '''
Example #49
0
 def __init__(self, **kwargs):
     super(LessonGroupScreen, self).__init__(**kwargs)
     Window.bind(on_keyboard=self.on_key)
     Clock.schedule_once(self.add_buttons, 1)
Example #50
0
 def __init__(self, **kwargs):
     self._win = None
     super(DropDown, self).__init__(**kwargs)
     Window.bind(on_key_down=self.on_key_down)
     self.bind(size=self._reposition)
Example #51
0
 def change_cursor(self, dt):
     pos = self.to_widget(*Window.mouse_pos)
     if self.box.collide_point(*pos):
         Window.set_system_cursor('size_all')
     else:
         Window.set_system_cursor('arrow')
Example #52
0
 def __init__(self, **kwargs):
     super(LessonListScreen, self).__init__(**kwargs)
     Window.bind(on_keyboard=self.on_key)
Example #53
0
 def on_pre_leave(self):
     Window.unbind(on_keyboard=self.voltar)
Example #54
0
 def __init__(self, **kwargs):
     super(LessonTitleScreen, self).__init__(**kwargs)
     self.speak_flag = 0
     Window.bind(on_keyboard=self.on_key)
Example #55
0
 def on_pre_enter(self):
     Window.bind(on_request_close=self.confirmacao)
Example #56
0
 def unschedule_cursor_change(self, *args, **kwargs):
     Clock.unschedule(self.cursor_change_event)
     Window.set_system_cursor('arrow')
Example #57
0
 def on_start(self):
     Window.bind(on_keyboard=self.back_key_handler)
Example #58
0
 def on_pre_enter(self):
     Window.bind(on_keyboard=self.voltar)
Example #59
0
 def __init__(self, **kwargs):
     Screen.__init__(self, **kwargs)
     self.manager = self.parent  # The screen manager
     self.layout = FloatLayout()  # The layout
     self.add_widget(self.layout)
     self.rows = 8  # The amount of rows in the board
     self.cols = 8  # The amount of columns in the board
     self.status = "Playing"  # Game status ("Playing"/"Win")
     self.win_text = Label(font_size="20sp", size_hint=(None, None))  # Label displayed at the end of the game
     self.reset = Button(text="Click to play again", width=Window.size[0]/5, size_hint=(None, None))  # Button displayed at the end of the game
     self.reset.bind(on_press=self.reset_board)
     self.menu = Button(text="Click to return to menu", width=Window.size[0]/5, size_hint=(None, None))  # Button displayed at the end of the game
     self.menu.bind(on_press=self.go_menu)
     self.quit = Button(text="Click to quit", width=Window.size[0]/5, size_hint=(None, None))  # Button displayed at the end of the game
     self.quit.bind(on_press=quit_game)
     self.depth = 2  # Minimax depth
     self.start_time = 0  # Used for measuring move calculation time
     self.offset = 0  # Used to lower minimax depth in real time
     self.tooLong = False  # If calculation time is longer than 10 seoncds
     self.rotatable = False  # If a board can rotated
     self.turn = 1  # Player turn (1/2)
     Window.bind(on_resize=self.resize)
     self.buttons = list()  # Buttons displayed on screen
     for i, y in enumerate(range(0, Window.size[1], int(Window.size[1]/self.rows))):
         # In case loop does one extra
         if i < self.rows:
             self.buttons.append(list())
         for j, x in enumerate(range(0, Window.size[0], int(Window.size[0]/self.cols))):
             # In case loop does one extra
             if j < self.cols:
                 # First button to be added
                 if i == 0 and j == 0:
                     self.buttons[i].append(Button(text="Menu", pos=(x, y), size=(Window.size[0] / 8, Window.size[1] / 8), size_hint=(None, None)))
                     self.buttons[i][j].mark = "menu"
                     self.buttons[i][j].bind(on_press=self.go_menu)
                 else:
                     self.buttons[i].append(WidgetButton((x, y), (Window.size[0] / self.cols, Window.size[1] / self.rows), i, j))
                     # If not out of bounds
                     if 0 < i < self.rows-1 and 0 < j < self.cols - 1:
                         self.buttons[i][j].bind(on_press=self.place)
                         self.buttons[i][j].mark = "empty"
                     # Arrows positions
                     elif i in [0, self.rows-1] and j in [1, self.cols-2] or i in [1, self.rows-2] and j in [0, self.cols-1]:
                         self.buttons[i][j].bind(on_press=self.rotate)
                     self.draw(self.buttons[i][j])
                 self.layout.add_widget(self.buttons[i][j])
     self.buttons[0][1].mark = "right"
     self.draw(self.buttons[0][1])
     self.buttons[0][1].start_row = self.buttons[1][0].start_row = 1
     self.buttons[0][1].start_col = self.buttons[1][0].start_col = 1
     self.buttons[0][1].cw = True
     self.buttons[1][0].mark = "up"
     self.draw(self.buttons[1][0])
     self.buttons[1][0].cw = False
     self.buttons[self.rows-2][0].mark = "down"
     self.draw(self.buttons[self.rows-2][0])
     self.buttons[self.rows-2][0].start_row = self.buttons[self.rows-1][1].start_row = int((self.rows-2)/2)+1
     self.buttons[self.rows-2][0].start_col = self.buttons[self.rows-1][1].start_col = 1
     self.buttons[self.rows-2][0].cw = True
     self.buttons[self.rows-1][1].mark = "right"
     self.draw(self.buttons[self.rows-1][1])
     self.buttons[self.rows-1][1].cw = False
     self.buttons[self.rows-1][self.cols-2].mark = "left"
     self.draw(self.buttons[self.rows-1][self.cols-2])
     self.buttons[self.rows-1][self.cols-2].start_row = self.buttons[self.rows-2][self.cols-1].start_row = int((self.rows-2)/2)+1
     self.buttons[self.rows-1][self.cols-2].start_col = self.buttons[self.rows-2][self.cols-1].start_col = int((self.cols-2)/2)+1
     self.buttons[self.rows-1][self.cols-2].cw = True
     self.buttons[self.rows-2][self.cols-1].mark = "down"
     self.draw(self.buttons[self.rows-2][self.cols-1])
     self.buttons[self.rows-2][self.cols-1].cw = False
     self.buttons[1][self.cols-1].mark = "up"
     self.draw(self.buttons[1][self.cols-1])
     self.buttons[1][self.cols-1].start_row = self.buttons[0][self.cols-2].start_row = 1
     self.buttons[1][self.cols-1].start_col = self.buttons[0][self.cols-2].start_col = int((self.cols-2)/2)+1
     self.buttons[1][self.cols-1].cw = True
     self.buttons[0][self.cols-2].mark = "left"
     self.draw(self.buttons[0][self.cols-2])
     self.buttons[0][self.cols-2].cw = False
Example #60
0
 def __init__(self, **kwargs):
     self.register_event_type('on_enter')
     self.register_event_type('on_leave')
     Window.bind(mouse_pos=self.on_mouse_pos)
     super(HoverBehavior, self).__init__(**kwargs)