Best Python code snippet using lemoncheesecake
armedcheckswitch.py
Source:armedcheckswitch.py  
...23        :param armed: Boolean. Sets the initial armed state of the switch24        :param on_check: A callback function that returns a Boolean, and takes25            in a dictionary as its parameter. The switch cannot change to the True26            state unless this function returns True.27        :param off_check: Callback function. Similar to on_check(), prevents28            the switch from changing to False unless the this returns True29        """30        self._switch = ArmedSwitch(switched=switched, armed=armed)31        self.on_check = on_check32        self.off_check = off_check33    def switch(self, *args):34        """35        Method that attempts to change the switch to the opposite of its36        current state. Calls either switch_on() or switch_off() to accomplish37        this.38        :param kwargs: an variable length dictionary of key-pair arguments39            passed through to either switch_on() or switch_off()40        :return: Boolean. Returns True if the switch changes state41        """42        if self.is_switched():43            return self.switch_off(*args)44        else:45            return self.switch_on(*args)46    def switch_on(self, *args):47        """48        Sets the state of the switch to True if on_check() returns True,49        given the arguments provided in kwargs.50        :param kwargs: variable length dictionary of key-pair arguments51        :return: Boolean. Returns True if the operation is successful52        """53        if self.on_check(*args):54            return self._switch.switch(True)55        else:56            return False57    def switch_off(self, *args):58        """59        Sets the state of the switch to False if off_check() returns True,60        given the arguments provided in kwargs.61        :param kwargs: variable length dictionary of key-pair arguments62        :return: Boolean. Returns True if the operation is successful63        """64        if self.off_check(*args):65            return self._switch.switch(False)66        else:67            return False...check.py
Source:check.py  
...19    """20    :type check_handle:21        uv.Check22    """23    check_handle.on_check(check_handle)24@handle.HandleTypes.CHECK25class Check(handle.UVHandle):26    """27    Check handles will run the given callback once per loop iteration,28    right after polling for IO after they have been started.29    :raises uv.UVError:30        error while initializing the handle31    :param loop:32        event loop the handle should run on33    :param on_check:34        callback which should run right after polling for IO after the35        handle has been started36    :type loop:37        uv.Loop38    :type on_check:39        ((uv.Check) -> None) | ((Any, uv.Check) -> None)40    """41    __slots__ = ['uv_check', 'on_check']42    uv_handle_type = 'uv_check_t*'43    uv_handle_init = lib.uv_check_init44    def __init__(self, loop=None, on_check=None):45        super(Check, self).__init__(loop)46        self.uv_check = self.base_handle.uv_object47        self.on_check = on_check or common.dummy_callback48        """49        Callback which should run right after polling for IO after the50        handle has been started.51        .. function:: on_check(check_handle)52            :param check_handle:53                handle the call originates from54            :type check_handle:55                uv.Check56        :readonly:57            False58        :type:59            ((uv.Check) -> None) | ((Any, uv.Check) -> None)60        """61    def start(self, on_check=None):62        """63        Start the handle. The callback will be called once per loop64        iteration right after polling for IO from now on.65        :raises uv.UVError:...ui.py
Source:ui.py  
1## 0.1 Search class AniImageBox(Window): ... after this class add :23class CheckBox(Window):4	def __init__(self):5		Window.__init__(self)6		7		self.backgroundImage = None8		self.checkImage = None910		self.eventFunc = { "ON_CHECK" : None, "ON_UNCKECK" : None, }11		self.eventArgs = { "ON_CHECK" : None, "ON_UNCKECK" : None, }12	13		self.CreateElements()14		15	def __del__(self):16		Window.__del__(self)17		18		self.backgroundImage = None19		self.checkImage = None20		21		self.eventFunc = { "ON_CHECK" : None, "ON_UNCKECK" : None, }22		self.eventArgs = { "ON_CHECK" : None, "ON_UNCKECK" : None, }23		24	def CreateElements(self):25		self.backgroundImage = ImageBox()26		self.backgroundImage.SetParent(self)27		self.backgroundImage.AddFlag("not_pick")28		self.backgroundImage.LoadImage("d:/ymir work/ui/game/refine/checkbox.tga")29		self.backgroundImage.Show()30		31		self.checkImage = ImageBox()32		self.checkImage.SetParent(self)33		self.checkImage.AddFlag("not_pick")34		self.checkImage.SetPosition(0, -4)35		self.checkImage.LoadImage("d:/ymir work/ui/game/refine/checked.tga")36		self.checkImage.Hide()37		38		self.textInfo = TextLine()39		self.textInfo.SetParent(self)40		self.textInfo.SetPosition(20, -2)41		self.textInfo.Show()42		43		self.SetSize(self.backgroundImage.GetWidth() + self.textInfo.GetTextSize()[0], self.backgroundImage.GetHeight() + self.textInfo.GetTextSize()[1])44		45	def SetTextInfo(self, info):46		if self.textInfo:47			self.textInfo.SetText(info)48			49		self.SetSize(self.backgroundImage.GetWidth() + self.textInfo.GetTextSize()[0], self.backgroundImage.GetHeight() + self.textInfo.GetTextSize()[1])50		51	def SetCheckStatus(self, flag):52		if flag:53			self.checkImage.Show()54		else:55			self.checkImage.Hide()56	57	def GetCheckStatus(self):58		if self.checkImage:59			return self.checkImage.IsShow()60			61		return False62		63	def SetEvent(self, func, *args) :64		result = self.eventFunc.has_key(args[0])		65		if result :66			self.eventFunc[args[0]] = func67			self.eventArgs[args[0]] = args68		else :69			print "[ERROR] ui.py SetEvent, Can`t Find has_key : %s" % args[0]70		71	def OnMouseLeftButtonUp(self):72		if self.checkImage:73			if self.checkImage.IsShow():74				self.checkImage.Hide()7576				if self.eventFunc["ON_UNCKECK"]:77					apply(self.eventFunc["ON_UNCKECK"], self.eventArgs["ON_UNCKECK"])78			else:79				self.checkImage.Show()8081				if self.eventFunc["ON_CHECK"]:
...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!!
