Ejemplo n.º 1
0
    def reset_cutter(self):
        self.cutter_event.cancel()

        ph = {'right': 1.0}
        anim = Animation(pos_hint=ph, duration=config.cutter_downtime)
        anim.bind(on_complete=lambda i, j: self.start_clock())
        anim.start(self.cutter)
Ejemplo n.º 2
0
class CompassApp(App):

    needle_angle = NumericProperty(0)

    def build(self):
        self._anim = None
        Hardware.magneticFieldSensorEnable(True)
        Clock.schedule_interval(self.update_compass, 1 / 10.)

    def update_compass(self, *args):
        # read the magnetic sensor from the Hardware class
        (x, y, z) = Hardware.magneticFieldSensorReading()

        # calculate the angle
        needle_angle = Vector(x, y).angle((0, 1)) + 90.

        # animate the needle
        if self._anim:
            self._anim.stop(self)
        self._anim = Animation(needle_angle=needle_angle, d=.2, t='out_quad')
        self._anim.start(self)

    def on_pause(self):
        # when you are going on pause, don't forget to stop the sensor
        Hardware.magneticFieldSensorEnable(False)
        return True

    def on_resume(self):
        # reactivate the sensor when you are back to the app
        Hardware.magneticFieldSensorEnable(True)
 def show_error(self, e):
     self.info_label.text = str(e)
     duration = len(self.info_label.text)/50
     anim = Animation(top=190.0, opacity=1, d=0.5) +\
         Animation(top=190.0, d=duration) +\
         Animation(top=0, opacity=0, d=2)        
     anim.start(self.info_label)
Ejemplo n.º 4
0
class CalendarApp(App):
    # rightnow dateobject for alarms and such
    rightnow = ObjectProperty(dt.datetime.now())
    memos = ObjectProperty(JsonStore('memos.json'))

    def __init__(self, **kwargs):
        Logger.info('Building App')
        super(CalendarApp, self).__init__(**kwargs)
        # Clock.schedule_interval(self.update_time, 1)
        self.popup = AlertPopup()
        self.anim_dismiss_popup = Animation(opacity=0, duration=1.5)
        self.anim_dismiss_popup.bind(on_complete=self.popup.dismiss)

    # update self.rightnow to a new datetime object every 1sec
    def update_time(self, *args):
        self.rightnow = dt.datetime.now()

    def build(self):
        main = Main()
        return main

    def alert(self, text):
        self.popup.label.text = text
        self.popup.open()
        self.popup.opacity = 1
        self.anim_dismiss_popup.start(self.popup)

    def on_pause(self, *args):
        return True
Ejemplo n.º 5
0
	def fade_out(self, duration):
		if duration == 0:
			self._a = 0.
			return
		anim = Animation(_a=0., duration=duration, t='out_quad')
		anim.bind(on_complete=lambda *x: self.dispatch('on_invisible'))
		anim.start(self)
Ejemplo n.º 6
0
 def sinking(self, instance, value):
     anim = Animation(y=33, d=9)
     anim &= Animation(x=self.x + 10, t="in_out_back", d=2.25) + \
             Animation(x=self.x - 10, t="in_out_back", d=2.25) + \
             Animation(x=self.x + 10, t="in_out_back", d=2.25) + \
             Animation(x=self.x, t="in_out_back", d=2.25)
     anim.start(self)
Ejemplo n.º 7
0
    def on_enter(self):
        anim = Animation(
            opacity=1.0, duration=2.0)

#        anim &= Animation(size=[self.menu_text.size[0]+4, self.menu_text[1]+4], duration=.2)
        anim.start(self.story_text1)
        Clock.schedule_once(self.show_text2, 2.0)
Ejemplo n.º 8
0
 def on_touch_down(self, touch):
     """Either make a new tower, or display menu for an existing one
     """
     tower_coord = (touch.x // self.cell_width // TOWER_SIZE * TOWER_SIZE,
             touch.y // self.cell_height // TOWER_SIZE * TOWER_SIZE)
     matrix_coord = tower_coord[0] + 1, tower_coord[1] + 1
     if self.matrix[matrix_coord] < 0:
         # On tower?
         for tower in self.towers:
             # Yes, relay the touch to it
             if tower.coord == tower_coord:
                 tower.on_touch_down(touch)
                 break
         else:
             # Not on tower
             pass
     else:
         # On free space – make tower
         side = int(touch.x > self.window_width / 2)
         if self.funds[side] >= 0:
             size = (self.cell_width * TOWER_SIZE,
                     self.cell_height * TOWER_SIZE)
             tower = Tower(
                     pos=(
                             touch.x // size[0] * size[0],
                             touch.y // size[1] * size[1]),
                     size=size,
                     side=side
                 )
             tower.coord = tower_coord
             if self.add_tower(tower):
                 tower.on_touch_down(touch)
             else:
                 # Tower would block; display message to that effect
                 label = Label(
                         text='Blocking!',
                         pos=(-50, -50),
                         size=(100, 100),
                         font_size=self.cell_width * 2,
                         color=(1, 1, 1, 1),
                     )
                 self.add_widget(label)
                 with label.canvas.before:
                     PushMatrix()
                     Translate(touch.pos[0], touch.pos[1], 0)
                     Rotate(90 if side else 270, 0, 0, 1)
                 with label.canvas.after:
                     PopMatrix()
                 # Animate and fade out the message
                 anim = Animation(font_size=TOWER_PIXEL_SIZE * 2,
                         color=(1, 1, 1, 0), duration=1, t='in_quad')
                 anim.start(label)
                 def tick_blocking_anim(dt):
                     label.canvas.ask_update()
                     Clock.schedule_once(tick_blocking_anim)
                 tick_blocking_anim(0)
                 def end_blocking_anim(dt):
                     self.remove_widget(label)
                     Clock.unschedule(tick_blocking_anim)
                 Clock.schedule_once(end_blocking_anim, 1)
Ejemplo n.º 9
0
	def next(self,*largs):
		
		Clock.unschedule(self.next)
		
		if(self.screenManager.current == 'page1'):
			next = 'page2'
			page = self.page2
		else:
			next = 'page1'
			page = self.page1
			
		self.index += 1
		if self.index == len(self.photos):
			self.index = 0
		page.source = self.photos[self.index]
		page.background.scale = 1.0		
		self.screenManager.transition = self.transitions[random.randint(0, len(self.transitions) -1)]
		self.screenManager.current = next
		
		anim = Animation(
			scale=page.background.scale*1.3, 
			duration=15.0
		)
		
		Clock.schedule_once(self.next, 10)
		
		anim.start(page.background)
Ejemplo n.º 10
0
 def __init__(self, **kwargs):
     super(GoGame, self).__init__(**kwargs)
     self.stone = GoStone(size=(40,40))
     self.stone.center = (100,100)
     anim = Animation(x=500, y=500, duration=3)
     anim.start(self.stone)
     self.add_widget( self.stone )
Ejemplo n.º 11
0
	def initialise_setup(self):
                '''variable initialisation'''
		
                self.layout = FloatLayout(size=(800,800))
		self.Mainlabel = Label(text="SharePy",color=(0.6,0.7,0.2,1),font_size="65sp",pos=(280,450),size_hint=(.3,.3))
		self.layout.add_widget(self.Mainlabel)
		self.cont_but = Button(text="Cont...",background_color=(0.2,0.3,0.88,1),pos=(700,30),size_hint=(.12,.1))
		self.layout.add_widget(self.cont_but)
		self.INFO = Label(size_hint=(.3,.3),pos=(230,300),color=(0.6,0.3,0.1,1),font_size="21dp")
		self.INFO2 = Label(size_hint=(.3,.3),pos=(230,150),color=(0.3,0.3,0.7,1),font_size="21dp")
		self.INFO.text = "SharePy is a project based on File Sharing.\nIts a project developed in Kivy using Python.\n\nBasic Features include:\n "
		self.INFO2.text = self.INFO2.text + "\n-> Zero Configuration\n-> File Transfering\n-> File Syncing\n-> File Searching\n-> Notification Broadcasting on File Events\n-> ChatBot for communication between Clients\n-> File Listing"
		self.INFO3 = Label(text="Members:\nVarun Malhotra\nMayank Bhola\nHarsh Bhatia",color=(0.7,0.1,0.1,1),pos=(150,40),size_hint=(0.2,0.2),font_size="21dp")
		
		self.layout.add_widget(self.INFO)
		self.layout.add_widget(self.INFO2)
		self.layout.add_widget(self.INFO3)
		self.anim_info2 = Animation(x=80,y=150, opacity=0.4, d=0.4,t ='in_quad') +\
			Animation(x=230,y=150, opacity=1, d=0.5)
		self.anim_info2.start(self.INFO2)
		self.anim_info3 = Animation(x=80,y=20, opacity=0.4, d=0.6,t ='in_quad') +\
			Animation(x=150,y=20, opacity=1, d=0.8)
		self.anim_info3.start(self.INFO3)
		self.cont_but.bind(on_press=self.setup_gui)
		
		return self.layout
Ejemplo n.º 12
0
 def login(self):
     animation = Animation(x=self.login_area.x - self.login_area.width, duration=0.8)
     animation.start(self.login_area)
     self.pan_screen= Image(source= "mylogo1.jpg", keep_ratio= False, allow_stretch= True,
                     color= (1, 1, 1, 0.1))
     self.add_widget(self.pan_screen)
     animation.bind(on_complete=self.check_login)
Ejemplo n.º 13
0
 def on_touch_down(self, touch):
     col_self = self.collide_point(*touch.pos)
     col_side = self._side_panel.collide_point(*touch.pos)
     if col_side and not self._main_above and self._anim_progress > 0:
         self._side_panel.on_touch_down(touch)
         return
     if not col_self or self._touch is not None:
         super(NavigationDrawer, self).on_touch_down(touch)
         return
     if self._anim_progress > 0.001:
         valid_region = (self._main_panel.x <=
                         touch.x <=
                         (self._main_panel.x + self._main_panel.width))
     else:
         valid_region = (self.x <=
                         touch.x <=
                         (self.x + self.touch_accept_width))
     if not valid_region:
         super(NavigationDrawer, self).on_touch_down(touch)
         return False
     Animation.cancel_all(self)
     self._anim_init_progress = self._anim_progress
     self._touch = touch
     touch.ud['type'] = self.state
     touch.ud['panels_jiggled'] = False  # If user moved panels back
                                         # and forth, don't default
                                         # to close on touch release
     touch.grab(self)
     return True
Ejemplo n.º 14
0
 def move_to_repeat_battle(self, widget=None, event=None):
     self.graphics_widget.remove_widget(self.scatter_hero)        
     anim = Animation(x = 8 * X_BLOCK, duration = 12)
     self.image_baddy.walk(30, 8 * X_BLOCK)        
     anim.start(self.image_baddy)
     
     self.schedule(self.repeat_battle, 3)        
Ejemplo n.º 15
0
 def on_touch_down(self, touch):
     if self in touch.ud:
         self.anim_complete(self, self)
         self.ripple_pos = ripple_pos = (touch.x, touch.y)
         Animation.cancel_all(self, 'ripple_rad', 'ripple_color')
         rc = self.ripple_color
         ripple_rad = self.ripple_rad
         self.ripple_color = [rc[0], rc[1], rc[2], 1.]
         anim = Animation(
             ripple_rad=max(self.width, self.height) * self.ripple_scale, 
             t=self.ripple_func_in,
             ripple_color=[rc[0], rc[1], rc[2], self.fade_to_alpha], 
             duration=self.ripple_duration_in)
         anim.start(self)
         with self.canvas.after:
             x,y = self.to_window(*self.pos)
             width, height = self.size
             #In python 3 the int cast will be unnecessary
             ScissorPush(x=int(round(x)), y=int(round(y)),
                 width=int(round(width)), height=int(round(height)))
             self.col_instruction = Color(rgba=self.ripple_color)
             self.ellipse = Ellipse(size=(ripple_rad, ripple_rad),
                 pos=(ripple_pos[0] - ripple_rad/2., 
                 ripple_pos[1] - ripple_rad/2.))
             ScissorPop()
         self.bind(ripple_color=self.set_color, ripple_pos=self.set_ellipse,
             ripple_rad=self.set_ellipse)
     return super(TouchRippleBehavior, self).on_touch_down(touch)
Ejemplo n.º 16
0
 def prepare_next(self,dt):
     self.generateGameQuestion(self.level)
     self.y=self.parent.height/2-self.height/1.5
     self.x=-self.width-10
     anim=Animation(x=10,d=self.levelSpeed/4,t="in_out_back")
     anim.bind(on_complete=self.prepareQuestionPanel)
     anim.start(self)
Ejemplo n.º 17
0
 def on_touch_up(self, touch):
     if not self.disabled:
         if touch.grab_current is not self:
             return super(ButtonBehavior, self).on_touch_up(touch)
         Animation.cancel_all(self, "elevation")
         self.elevation_release_anim.start(self)
     return super(MDRaisedButton, self).on_touch_up(touch)
Ejemplo n.º 18
0
    def open(self, *largs, **kwargs):
        '''Show the view window from the :attr:`attach_to` widget. If set, it
        will attach to the nearest window. If the widget is not attached to any
        window, the view will attach to the global
        :class:`~kivy.core.window.Window`.

        When the view is opened, it will be faded in with an animation. If you
        don't want the animation, use::

            view.open(animation=False)

        '''
        if self._window is not None:
            Logger.warning('ModalView: you can only open once.')
            return
        # search window
        self._window = self._search_window()
        if not self._window:
            Logger.warning('ModalView: cannot open view, no window found.')
            return
        self._window.add_widget(self)
        self._window.bind(
            on_resize=self._align_center,
            on_keyboard=self._handle_keyboard)
        self.center = self._window.center
        self.fbind('center', self._align_center)
        self.fbind('size', self._align_center)
        if kwargs.get('animation', True):
            a = Animation(_anim_alpha=1., d=self._anim_duration)
            a.bind(on_complete=lambda *x: self.dispatch('on_open'))
            a.start(self)
        else:
            self._anim_alpha = 1.
            self.dispatch('on_open')
Ejemplo n.º 19
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)
Ejemplo n.º 20
0
 def grow(self, size):
     """Animate the widget to `size` over the time of 1 second
     """
     animation = Animation(size=(size, size), t='in_cubic', duration=1)
     animation.start(self)
     tick = schedule_tick(self.tick)
     Clock.schedule_once(lambda dt: Clock.unschedule(tick), 2)
Ejemplo n.º 21
0
    def countdown(self, num):
        """The countdown for the solving player

        For positive `num`, shows the number near the maze entrance, animates
        it, and schedules a call to countdown(num-1) for one second.
        For num == 0, display 'Go!', animate it, and grow the ball source.
        """
        label = Label(
                text=str(num) if num else 'Go!',
                font_size=24,
                color=(0, 0, 1, 1),
            )
        with label.canvas.before:
            PushMatrix()
            Translate(
                    self.window_width - self.cell_size * 1,
                    self.window_height - self.cell_size * 5,
                    0,
                )
            Rotate(90, 0, 0, 1)
        with label.canvas.after:
            PopMatrix()
        animation = Animation(font_size=256, color=(0, 0, 1, 0),
                t='in_cubic', duration=1.5)
        animation.start(label)
        self.add_widget(label)
        if num > 0:
            Clock.schedule_once(lambda dt: self.countdown(num - 1), 1)
        else:
            self.ball_source.grow(self.cell_size * 3)
            if self.parent:
                self.parent.set_message(True,
                        u'Take a ball from the blue corner.')
Ejemplo n.º 22
0
    def inflate(self):
        self.size = BALLOON_WIDTH, BALLOON_HEIGHT
        self.center[0] = self.parent.center[0]
        self.y = self.parent.top + COW_WIDTH // 2

        # Is there a better way? parent.parent huh?
        exp = generator.get_expression(
            True, EASY)
        # I'm ok with this:
        exp, self.answer = exp.split('=')
        while int(self.answer) < 0:
            exp = generator.get_expression(
                True, EASY)
            exp, self.answer = exp.split('=')

        l, r = re.search(r'[+-/*]', exp).span()
        # print expression[:operator[0]]

        exp = [exp[:l]] + [exp[l].replace('/', '%')] + [exp[r:]]
        # print exp
        # print expr
        # print [symbol for symbol in exp]
        self.expression = '\n'.join(exp)
        # print

        y = self.y + Window.height - BOTTOM_BORDER
        anim = Animation(x=self.x, y=y, d=FLYING_TIME, t='in_quad')
        anim.start(self)
Ejemplo n.º 23
0
 def on__rotation_angle(self, *args):
     if self._rotation_angle == 0:
         self._rotation_angle = 360
         if not self.determinate:
             _rot_anim = Animation(_rotation_angle=0,
                                   duration=2)
             _rot_anim.start(self)
Ejemplo n.º 24
0
	def openGearMenu(self):
		gearMenu = GearMenu()
		gearMenu.setScreen(self)
		gearMenu.opacity = 0
		anim = Animation(opacity = 1,duration=0.2)
		self.ids.layer.add_widget(gearMenu)
		anim.start(gearMenu)
Ejemplo n.º 25
0
    def _anim_back(self, *args):
        _angle_back_anim = Animation(_angle_start=self._angle_end - 8,
                                     duration=.6,
                                     t='in_out_cubic')
        _angle_back_anim.bind(on_complete=self._start_loop)

        _angle_back_anim.start(self)
Ejemplo n.º 26
0
Archivo: main.py Proyecto: spillz/37.6
    def place(self, hex_pos, center_pos):
        if self.selected:
            self.hex_pos = hex_pos
#            self.center = center_pos
            self.selected = False
            a = Animation(center_x = center_pos[0], center_y = center_pos[1], duration = 0.1)
            a.start(self)
Ejemplo n.º 27
0
 def fader(self):
     self.img=Image(source="fader.jpg",allow_stretch=True)
     self.add_widget(self.img)
     self.img.opacity=0
     anim=Animation(opacity=1,d=.5,t="out_sine")
     anim.bind(on_complete=self.fade_level)
     anim.start(self.img)
Ejemplo n.º 28
0
    def _start_animation(self, *args):
        Animation.cancel_all(self)

        # compute target offset for ease back, next or prev
        new_offset = 0
        is_horizontal = self.direction in ['right', 'left']
        extent = self.width if is_horizontal else self.height
        if self._offset < self.min_move * -extent:
            new_offset = -extent
        elif self._offset > self.min_move * extent:
            new_offset = extent

        # if new_offset is 0, it wasnt enough to go next/prev
        dur = self.anim_move_duration
        if new_offset == 0:
            dur = self.anim_cancel_duration

        if not self.loop:  # detect edge cases if not looping
            is_first = (self.index == 0)
            is_last = (self.index == len(self.slides) - 1)
            if self.direction in ['right', 'top']:
                towards_prev = (new_offset > 0)
                towards_next = (new_offset < 0)
            if self.direction in ['left', 'bottom']:
                towards_prev = (new_offset < 0)
                towards_next = (new_offset > 0)
            if (is_first and towards_prev) or (is_last and towards_next):
                new_offset = 0

        anim = Animation(_offset=new_offset, d=dur, t='out_quad')
        anim.start(self)
Ejemplo n.º 29
0
 def push_back_into_place(self,square) :
     id = str(square.geometry_id)
     if self.activate_animations : 
         animation = Animation(pos = self.geometry_squares[id].pos, duration = 0.9,t='in_out_back')
         animation.start(square)
     else : 
         square.pos = self.geometry_squares[id].pos
Ejemplo n.º 30
0
    def __init__(self, cows, difficulty, e_sound, s_sound):

        super(UFO, self).__init__()
        self.size = [UFO_WIDTH, UFO_HEIGHT]
        self.pos = [Window.center[0], Window.height]
        # self.engine_sound = SoundLoader.load('sound/ufo_engine.ogg')
        # self.shot_sound = SoundLoader.load('sound/ufo_shot.ogg')
        self.engine_sound = e_sound
        self.shot_sound = s_sound
        self.engine_sound.volume = 0.5
        self.engine_sound.loop = True
        self.source = 'img/cows/ufo_03.png'

        self.cows = cows
  #      self.victim = None
        self.difficulty = difficulty
        self.think_time = 3.5 - difficulty

        self.__all_engines_start()

        # self.__move_to_start_position()
        self.__chose_victim()
        anim = Animation(x=self.x, y=TOP_BORDER, d=0.5)

        _f = Clock.schedule_interval
        anim.bind(on_complete=lambda *args: _f(self.__move, FPS))
        anim.start(self)
Ejemplo n.º 31
0
 def _set_mode(self, instance, text):
     self.mode = text
     if self.mode == "persistent":
         Animation(duration=.1, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
Ejemplo n.º 32
0
 def open_navbar(self, button):
     self.sidenav.width = 50
     Animation(width=self.width / 3, d=.1).start(self.sidenav)
     self.add_widget(self.sidenav)
     button.disabled = True
Ejemplo n.º 33
0
 def set_selected_screen(self):
     anim = Animation(x=0, y=0, d=.1)
     anim.bind(on_complete=self.set_default_screens_position)
     anim.start(self.selected_screen)
Ejemplo n.º 34
0
 def _fade_out(self, item, time):
     anim = Animation(opacity=0, d=time)
     anim.start(item)
Ejemplo n.º 35
0
 def _update(self, *args):
     (Animation(opacity=1,
                d=randint(*self.parent.time_before_fade))).start(self)
Ejemplo n.º 36
0
 def wobble(self):
     anim = Animation(pos=(80, 10))
     anim &= Animation(size=(800, 800), duration=2.)
     anim.start(self)
Ejemplo n.º 37
0
class SingleLineTextField(ThemableBehavior, TextInput):
    line_color_normal = ListProperty()
    line_color_focus = ListProperty()
    error_color = ListProperty()
    error = BooleanProperty(False)
    message = StringProperty("")
    message_mode = StringProperty("none")
    mode = message_mode

    _hint_txt_color = ListProperty()
    _hint_lbl = ObjectProperty()
    _hint_lbl_font_size = NumericProperty(sp(16))
    _hint_y = NumericProperty(dp(10))
    _error_label = ObjectProperty()
    _line_width = NumericProperty(0)
    _hint_txt = StringProperty('')
    _current_line_color = line_color_focus
    _current_error_color = ListProperty([0.0, 0.0, 0.0, 0.0])
    _current_hint_text_color = _hint_txt_color

    def __init__(self, **kwargs):
        Clock.schedule_interval(self._update_color, 5)
        self._msg_lbl = MDLabel(font_style='Caption',
                                theme_text_color='Error',
                                halign='left',
                                valign='middle',
                                text=self.message)

        self._hint_lbl = MDLabel(font_style='Subhead',
                                 halign='left',
                                 valign='middle')
        super(SingleLineTextField, self).__init__(**kwargs)
        self.line_color_normal = self.theme_cls.divider_color
        self.line_color_focus = list(self.theme_cls.primary_color)
        self.base_line_color_focus = list(self.theme_cls.primary_color)
        self.error_color = self.theme_cls.error_color

        self._hint_txt_color = self.theme_cls.disabled_hint_text_color
        self.hint_text_color = (1, 1, 1, 0)
        self.cursor_color = self.theme_cls.primary_color
        self.bind(message=self._set_msg,
                  hint_text=self._set_hint,
                  _hint_lbl_font_size=self._hint_lbl.setter('font_size'),
                  message_mode=self._set_mode)
        self.hint_anim_in = Animation(_hint_y=dp(34),
                                      _hint_lbl_font_size=sp(12), duration=.2,
                                      t='out_quad')

        self.hint_anim_out = Animation(_hint_y=dp(10),
                                       _hint_lbl_font_size=sp(16), duration=.2,
                                       t='out_quad')

    def _update_color(self, *args):
        self.line_color_normal = self.theme_cls.divider_color
        self.base_line_color_focus = list(self.theme_cls.primary_color)
        if not self.focus and not self.error:
            self.line_color_focus = self.theme_cls.primary_color
            Animation(duration=.2, _current_hint_text_color=self.theme_cls.disabled_hint_text_color).start(self)
            if self.mode == "persistent":
                Animation(duration=.1, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
        if self.focus and not self.error:
            self.cursor_color = self.theme_cls.primary_color

    def on_hint_text_color(self, instance, color):
        self._hint_txt_color = self.theme_cls.disabled_hint_text_color
        self.hint_text_color = (1, 1, 1, 0)

    def on_width(self, instance, width):
        if self.focus and instance is not None or self.error and instance is not None:
            self._line_width = width
        self.anim = Animation(_line_width=width, duration=.2, t='out_quad')
        self._msg_lbl.width = self.width
        self._hint_lbl.width = self.width

    def on_pos(self, *args):
        self.hint_anim_in = Animation(_hint_y=dp(34),
                                      _hint_lbl_font_size=sp(12), duration=.2,
                                      t='out_quad')
        self.hint_anim_out = Animation(_hint_y=dp(10),
                                       _hint_lbl_font_size=sp(16), duration=.2,
                                       t='out_quad')

    def on_focus(self, *args):
        if self.focus:
            Animation.cancel_all(self, '_line_width', '_hint_y',
                                 '_hint_lbl_font_size')
            if len(self.text) == 0:
                self.hint_anim_in.start(self)
            if self.error:
                Animation(duration=.2, _current_hint_text_color=self.error_color).start(self)
                if self.mode == "on_error":
                    Animation(duration=.2, _current_error_color=self.error_color).start(self)
                elif self.mode == "persistent":
                    Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
                elif self.mode == "on_focus":
                    Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
                else:
                    pass
            elif not self.error:
                self.on_width(None, self.width)
                self.anim.start(self)
                Animation(duration=.2, _current_hint_text_color=self.line_color_focus).start(self)
                if self.mode == "on_error":
                    Animation(duration=.2, _current_error_color=(0, 0, 0, 0)).start(self)
                if self.mode == "persistent":
                    Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
                elif self.mode == "on_focus":
                    Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
                else:
                    pass
        else:
            Animation.cancel_all(self, '_line_width', '_hint_y',
                                 '_hint_lbl_font_size')
            if len(self.text) == 0:
                self.hint_anim_out.start(self)
            if not self.error:
                self.line_color_focus = self.base_line_color_focus
                Animation(duration=.2, _current_line_color=self.line_color_focus,
                          _current_hint_text_color=self.theme_cls.disabled_hint_text_color).start(self)
                if self.mode == "on_error":
                    Animation(duration=.2, _current_error_color=(0, 0, 0, 0)).start(self)
                elif self.mode == "persistent":
                    Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
                elif self.mode == "on_focus":
                    Animation(duration=.2, _current_error_color=(0, 0, 0, 0)).start(self)

                self.on_width(None, 0)
                self.anim.start(self)
            elif self.error:
                Animation(duration=.2, _current_line_color=self.error_color,
                          _current_hint_text_color=self.error_color).start(self)
                if self.mode == "on_error":
                    Animation(duration=.2, _current_error_color=self.error_color).start(self)
                elif self.mode == "persistent":
                    Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
                elif self.mode == "on_focus":
                    Animation(duration=.2, _current_error_color=(0, 0, 0, 0)).start(self)

    def _set_hint(self, instance, text):
        self._hint_lbl.text = text

    def _set_msg(self, instance, text):
        self._msg_lbl.text = text
        self.message = text

    def _set_mode(self, instance, text):
        self.mode = text
        if self.mode == "persistent":
            Animation(duration=.1, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
Ejemplo n.º 38
0
 def on_width(self, instance, width):
     if self.focus and instance is not None or self.error and instance is not None:
         self._line_width = width
     self.anim = Animation(_line_width=width, duration=.2, t='out_quad')
     self._msg_lbl.width = self.width
     self._hint_lbl.width = self.width
Ejemplo n.º 39
0
 def on_touch_up(self, *args):
     Animation.stop_all(self)
     return super().on_touch_up(*args)
Ejemplo n.º 40
0
    def on_focus(self, *args):
        if self.focus:
            Animation.cancel_all(self, '_line_width', '_hint_y',
                                 '_hint_lbl_font_size')
            if len(self.text) == 0:
                self.hint_anim_in.start(self)
            if self.error:
                Animation(duration=.2, _current_hint_text_color=self.error_color).start(self)
                if self.mode == "on_error":
                    Animation(duration=.2, _current_error_color=self.error_color).start(self)
                elif self.mode == "persistent":
                    Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
                elif self.mode == "on_focus":
                    Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
                else:
                    pass
            elif not self.error:
                self.on_width(None, self.width)
                self.anim.start(self)
                Animation(duration=.2, _current_hint_text_color=self.line_color_focus).start(self)
                if self.mode == "on_error":
                    Animation(duration=.2, _current_error_color=(0, 0, 0, 0)).start(self)
                if self.mode == "persistent":
                    Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
                elif self.mode == "on_focus":
                    Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
                else:
                    pass
        else:
            Animation.cancel_all(self, '_line_width', '_hint_y',
                                 '_hint_lbl_font_size')
            if len(self.text) == 0:
                self.hint_anim_out.start(self)
            if not self.error:
                self.line_color_focus = self.base_line_color_focus
                Animation(duration=.2, _current_line_color=self.line_color_focus,
                          _current_hint_text_color=self.theme_cls.disabled_hint_text_color).start(self)
                if self.mode == "on_error":
                    Animation(duration=.2, _current_error_color=(0, 0, 0, 0)).start(self)
                elif self.mode == "persistent":
                    Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
                elif self.mode == "on_focus":
                    Animation(duration=.2, _current_error_color=(0, 0, 0, 0)).start(self)

                self.on_width(None, 0)
                self.anim.start(self)
            elif self.error:
                Animation(duration=.2, _current_line_color=self.error_color,
                          _current_hint_text_color=self.error_color).start(self)
                if self.mode == "on_error":
                    Animation(duration=.2, _current_error_color=self.error_color).start(self)
                elif self.mode == "persistent":
                    Animation(duration=.2, _current_error_color=self.theme_cls.disabled_hint_text_color).start(self)
                elif self.mode == "on_focus":
                    Animation(duration=.2, _current_error_color=(0, 0, 0, 0)).start(self)
Ejemplo n.º 41
0
    def twist(self):
        """Twist effect animation."""

        (Animation(rotate=25, t="out_quad", d=0.05) +
         Animation(rotate=0, t="out_elastic", d=0.5)).start(self)
Ejemplo n.º 42
0
    def goto(self, ref, *largs):
        '''Scroll to the reference. If it's not found, nothing will be done.

        For this text::

            .. _myref:

            This is something I always wanted.

        You can do::

            from kivy.clock import Clock
            from functools import partial

            doc = RstDocument(...)
            Clock.schedule_once(partial(doc.goto, 'myref'), 0.1)

        .. note::

            It is preferable to delay the call of the goto if you just loaded
            the document because the layout might not be finished or the
            size of the RstDocument has not yet been determined. In
            either case, the calculation of the scrolling would be
            wrong.

            You can, however, do a direct call if the document is already
            loaded.

        .. versionadded:: 1.3.0
        '''
        # check if it's a file ?
        if ref.endswith('.rst'):
            # whether it's a valid or invalid file, let source deal with it
            self.source = ref
            return

        # get the association
        ref = self.refs_assoc.get(ref, ref)

        # search into all the nodes containing anchors
        ax = ay = None
        for node in self.anchors_widgets:
            if ref in node.anchors:
                ax, ay = node.anchors[ref]
                break

        # not found, stop here
        if ax is None:
            return

        # found, calculate the real coordinate

        # get the anchor coordinate inside widget space
        ax += node.x
        ay = node.top - ay
        #ay += node.y

        # what's the current coordinate for us?
        sx, sy = self.scatter.x, self.scatter.top
        #ax, ay = self.scatter.to_parent(ax, ay)

        ay -= self.height

        dx, dy = self.convert_distance_to_scroll(0, ay)
        dy = max(0, min(1, dy))
        Animation(scroll_y=dy, d=.25, t='in_out_expo').start(self)
Ejemplo n.º 43
0
    def grow(self):
        """Grow effect animation."""

        (Animation(scale_x=1.2, scale_y=1.2, t="out_quad", d=0.03) +
         Animation(scale_x=1, scale_y=1, t="out_elastic", d=0.4)).start(self)
Ejemplo n.º 44
0
    def shrink(self):
        """Shrink effect animation."""

        Animation(scale_x=0.95, scale_y=0.95, t="out_quad", d=0.1).start(self)
Ejemplo n.º 45
0
    def animate_result_notification(self, result):
        # Change the result notification text accordingly.
        self.result_label.text = result

        if result == "¡Incorrecto!":
            # Change text color to red.
            animation = Animation(color=(1, 0, 0, 1), duration=0.1) & \
                        Animation(font_size=self.result_label.font_size+20, duration=0.1) + \
                        Animation(color=self.result_label.color, duration=0.5) + \
                        Animation(font_size=self.result_label.font_size, duration=0.5)
        elif result == "¡Correcto!":
            # Change text color to green.
            animation = Animation(color=(0, 1, 0, 1), duration=0.1) & \
                        Animation(font_size=self.result_label.font_size+20, duration=0.1) + \
                        Animation(color=self.result_label.color, duration=0.5) + \
                        Animation(font_size=self.result_label.font_size, duration=0.5)
        animation.start(self.result_label)
Ejemplo n.º 46
0
    def shake(self):
        """Shake effect animation."""

        (Animation(translate_x=50, t="out_quad", d=0.02) +
         Animation(translate_x=0, t="out_elastic", d=0.5)).start(self)
Ejemplo n.º 47
0
 def hide_floating_buttons(self):
     for btn in self.btn_list:
         Animation(y=25, d=.5, t='in_elastic').start(btn)
Ejemplo n.º 48
0
class PartylineScreen(SideScreen):
    def __init__(self, **kwargs):  # inicializace
        super(PartylineScreen, self).__init__(**kwargs)
        self.root.insertStrings.append((self, "STR_PARTYLINE"))
        self.input = TextInput(size_hint=(.8, .07),
                               pos_hint={
                                   'x': .08,
                                   'y': .024
                               })
        self.output = Label(markup=True,
                            font_name='font/Roboto-Regular.ttf',
                            font_size='16dp',
                            size_hint_y=None)
        self.SLayout = GridLayout(size_hint_y=None, cols=1, spacing=0)
        self.SLayout.bind(minimum_height=self.SLayout.setter('height'))
        self.scroll = ScrollView(size_hint=(1, .9),
                                 pos_hint={
                                     'center_x': .58,
                                     'y': .125
                                 },
                                 scroll_timeout=10000)
        self.scroll.do_scroll_x = False
        self.scroll.add_widget(self.SLayout)
        self.SLayout.add_widget(self.output)
        self.layout = RelativeLayout(size_hint=(.75, .83),
                                     pos_hint={
                                         'center_x': .437,
                                         'y': .02
                                     })
        self.send = DelButton(color=(1, 1, 1, 0),
                              text='SEND',
                              size_hint=(None, .1),
                              pos_hint={
                                  'x': .88,
                                  'y': .022
                              },
                              background_normal='crop/icons/send.png',
                              background_down='crop/icons/send.png')
        self.send.bind(on_press=self.sendMsg)
        self.input.bind(focus=self.on_focus)
        self.layout.content.add_widget(self.scroll)
        self.layout.content.add_widget(self.input)
        self.layout.content.add_widget(self.send)
        self.add_widget(self.layout)
        if self.root.onAndroid():
            self.LayouFocusOn = Animation(size_hint_y=.5,
                                          pos_hint={
                                              'center_x': .437,
                                              'y': .38
                                          },
                                          duration=.2)
            self.LayouFocusOut = Animation(size_hint_y=.83,
                                           pos_hint={
                                               'center_x': .437,
                                               'y': .02
                                           },
                                           duration=.2)

    def on_pre_enter(self, *args):
        # Voláno těsně před zobrazením obrazovky
        self.output.text_size = (self.root.root.size[0] * 0.75, None)

    def sendMsg(self, instance):
        # Odeslat zprávu do chatu
        if len(self.input.text) > 0:
            out = "pline " + str(self.root.id) + " " + self.input.text.replace(
                "\n", " ")
            self.root.send_message(out)
            self.root.print_message("{0}\xff".format(out))
            self.input.text = ""

    def on_focus(self, instance, value):
        # Při označení vstupního pole
        if self.root.onAndroid():
            if value:
                self.LayouFocusOn.start(self.layout)
            else:
                self.LayouFocusOut.start(self.layout)

    def prev(self):
        # Metoda pro návrat na předchozí obrazovku
        if self.input.focus:
            self.input.focus = False
        self.root.sm.transition = SlideTransition(direction="left")
        self.root.sm.current = 'GameScreen'
Ejemplo n.º 49
0
 def blink(self):
     # Animation that changes the blink size and opacity
     anim = Animation(outer_opacity=0, blink_size=50)
     # when yhe animation completes, reset the animation, then repeat
     anim.bind(on_complete=self.reset)
     anim.start(self)
Ejemplo n.º 50
0
 def hide_floating_labels(self):
     i = 1
     for lbl in self.lbl_list:
         i -= .3
         Animation(x=-lbl.width, d=i, t='out_elastic').start(lbl)
     self.hide_floating_buttons()
Ejemplo n.º 51
0
 def anim_resize_close(self, box):
     Animation(height=dp(68), d=.1, t='in_cubic').start(box)
Ejemplo n.º 52
0
 def show_floating_labels(self):
     i = 0
     for lbl in self.lbl_list:
         i += .3
         pos_x = Window.width - (lbl.width + dp(46 + 21 * 1.5))
         Animation(x=pos_x, d=i, t='out_elastic').start(lbl)
Ejemplo n.º 53
0
 def anim_chevron_down(self):
     chevron = self.ids.item_anim.children[0].children[0]
     angle = -90
     Animation(angle=angle, d=.2).start(chevron)
     self.anim_resize_open_item()
Ejemplo n.º 54
0
""" demonstrate bug/crash in kivy.animation.Animation.have_properties_to_animate().

NOTE: This bug got fixed in kivy master with the PR #5926, merged 7-May-2020.

"""
from kivy.animation import Animation
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.scrollview import ScrollView

anim_seq = Animation(x=100) + Animation(x=0) + Animation(x=200) + Animation(
    x=0)
anim_seq.repeat = True


class MyApp(App):
    """ test app """
    def build(self):
        """ build app.root """
        # NOTE: happening only in conjunction with ScrollView - using only the single Label as app.root does not crash
        # root = Label(text="animated label widget")
        root = ScrollView()
        root.add_widget(Label(text="animated label widget"))
        return root

    def on_start(self):
        """ start app """
        anim_seq.start(self.root)


if __name__ == '__main__':
Ejemplo n.º 55
0
 def on_pre_enter(self, *args):
     if self.music:
         anim = Animation(volume=1, d=.4)
         anim.start(self.music)
Ejemplo n.º 56
0
 def anim_chevron_up(self, inctance):
     angle = 0
     Animation(angle=angle, d=.2).start(inctance)
Ejemplo n.º 57
0
 def go_left(self, instance, value):
     animation = Animation(x=0)
     animation.bind(on_complete=self.go_right)
     animation.start(self)
Ejemplo n.º 58
0
 def on_pre_leave(self, *args):
     if self.music:
         anim = Animation(volume=0, d=.4)
         anim.start(self.music)
Ejemplo n.º 59
0
 def anim(self):
     an = Animation(opacity=1, duration=3)
     an.start(self.ids.fond)
Ejemplo n.º 60
0
 def go_right(self, instance, value):
     animation = Animation(right=self.parent.width)
     animation.bind(on_complete=self.go_left)
     animation.start(self)