Best Python code snippet using lisa_python
spinner.py
Source:spinner.py
...61 self.theme_cls.bind(primary_color=self._update_color)62 if self.determinate:63 self._start_determinate()64 else:65 self._start_loop()66 def _update_color(self, *args):67 self.color = self.theme_cls.primary_color68 def _start_determinate(self, *args):69 self._alpha_anim_in.start(self)70 _rot_anim = Animation(_rotation_angle=0,71 duration=self.determinate_time * .7,72 t='out_quad')73 _rot_anim.start(self)74 _angle_start_anim = Animation(_angle_end=360,75 duration=self.determinate_time,76 t='in_out_quad')77 _angle_start_anim.bind(on_complete=lambda *x: \78 self._alpha_anim_out.start(self))79 _angle_start_anim.start(self)80 def _start_loop(self, *args):81 if self._alpha == 0:82 _rot_anim = Animation(_rotation_angle=0,83 duration=2,84 t='linear')85 _rot_anim.start(self)86 self._alpha = 187 self._alpha_anim_in.start(self)88 _angle_start_anim = Animation(_angle_end=self._angle_end + 270,89 duration=.6,90 t='in_out_cubic')91 _angle_start_anim.bind(on_complete=self._anim_back)92 _angle_start_anim.start(self)93 def _anim_back(self, *args):94 _angle_back_anim = Animation(_angle_start=self._angle_end - 8,95 duration=.6,96 t='in_out_cubic')97 _angle_back_anim.bind(on_complete=self._start_loop)98 _angle_back_anim.start(self)99 def on__rotation_angle(self, *args):100 if self._rotation_angle == 0:101 self._rotation_angle = 360102 if not self.determinate:103 _rot_anim = Animation(_rotation_angle=0,104 duration=2)105 _rot_anim.start(self)106 def _reset(self, *args):107 Animation.cancel_all(self, '_angle_start', '_rotation_angle',108 '_angle_end', '_alpha')109 self._angle_start = 0110 self._angle_end = 8111 self._rotation_angle = 360112 self._alpha = 0113 self.active = False114 def on_active(self, *args):115 if not self.active:116 self._reset()117 else:118 if self.determinate:119 self._start_determinate()120 else:...
loopingset.py
Source:loopingset.py
...29 self.loops[f] = Element(30 loop=twisted.internet.task.LoopingCall(f),31 period=minimum_period32 )33 _start_loop(self.loops[f].loop, self.loops[f].period)34 if minimum_period != self.loops[f].period:35 self.loops[f].loop.stop()36 self.loops[f] = Element(37 loop=twisted.internet.task.LoopingCall(f),38 period=minimum_period39 )40 _start_loop(self.loops[f].loop, self.loops[f].period)41 def stop(self):42 for element in self.loops.values():43 if element.loop.running:44 element.loop.stop()45 def start(self):46 for element in self.loops.values():47 if not element.loop.running:48 _start_loop(element.loop, element.period)49def _start_loop(loop, period):50 loop_deferred = loop.start(period)51 loop_deferred.addErrback(epyqlib.utils.twisted.errbackhook)52if __name__ == '__main__':53 # TODO: move this to a unit test and actually check it's result54 # automatically55 import twisted.internet.reactor56 a = lambda: print('a')57 b = lambda: print('b')58 requests = (59 (1, Request(f=a, period=0.5)),60 (0, Request(f=a, period=2)),61 (0, Request(f=a, period=1)),62 (0, Request(f=b, period=1)),63 )...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!