Best Python code snippet using localstack_python
slider.py
Source:slider.py
1from . import widget2from browser import doc,html3class Slider(widget.Widget):4 def __init__(self, id=None, label=False):5 self._div_shell=html.DIV(Class="ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all")6 widget.Widget.__init__(self, self._div_shell, 'slider', id)7 self._handle=html.A(Class="ui-slider-handle ui-state-default ui-corner-all",8 Href='#', style={'left': '0px'})9 self._value=010 self._isMouseDown=False11 self.m0 = [None, None]12 def startSlide(ev):13 self._isMouseDown=True14 self._upperBound = self._div_shell.offsetWidth - self._handle.offsetWidth15 pos = widget.getMousePosition(ev)16 self._startMouseX=pos['x']17 print('left', self._handle.style.left,'ev.x',ev.x)18 self._lastElementLeft = int(self._handle.left)19 print('left', self._lastElementLeft)20 updatePosition(ev)21 def updatePosition(ev):22 #pos = widget.getMousePosition(ev)23 #print('mose pos',pos)24 _newPos = self._lastElementLeft + ev.x - self._startMouseX25 26 _newPos = max(0, _newPos)27 _newPos = min(_newPos, self._upperBound)28 self._handle.left = _newPos29 print('new position',self._handle.style.left)30 self._lastElementLeft = _newPos31 def moving(e):32 if self._isMouseDown:33 updatePosition(e)34 def dropCallback(e):35 self._isMouseDown=False36 self._handle.unbind('mousemove', moving)37 self._handle.bind('mousemove', moving)38 self._handle.bind('mouseup', dropCallback)39 #self._handle.bind('mouseout', dropCallback)40 self._handle.bind('mousedown', startSlide)41 def mouseover(e):42 _class=self._handle.getAttribute('class')43 self._handle.setAttribute('class', '%s %s' % (_class, 'ui-state-hover'))44 def mouseout(e):45 self._isMouseDown=False46 _class=self._handle.getAttribute('class')47 self._handle.setAttribute('class', _class.replace('ui-state-hover', ''))48 self._handle.bind('mouseover', mouseover)49 self._handle.bind('mouseout', mouseout)50 self._div_shell <= self._handle51 def get_value(self):52 return self._value53 #def set_value(self, value):54 # self._value=value...
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!!