Best Python code snippet using fMBT_python
toast.py
Source:toast.py  
...40        # ãªãã¹ããã¼ã¹ãã¦ã£ã³ãã¦ã¨åæè¡¨ç¤ºãããã®ã§ãããããã³ã°ã§ãã©ã¤ããã(0.5ç§)41        url = f'https://i1.ytimg.com/vi/{self.vid}/mqdefault.jpg'42        try:43            data = urlopen(url, timeout=0.5).read()44            self.drawIcon(data)45            return46        except (HTTPError, URLError, timeout):47            pass48        # èªã¿è¾¼ã¿ãé
ãã£ãå ´åï¼0.5ç§ä»¥ä¸ï¼ããã«é£ã¶ã49        # èªã¿è¾¼ã¿ä¸ã®ãã¬ã¼ã¹ãã«ãè¨å®50        self.setIcon(QIcon(QPixmap("./res/img/place_holder.bmp")))51        # ããã¯ã°ã©ã¦ã³ãã§ç»åèªã¿è¾¼ã¿ãéå§52        self.thread = QThread()53        self.loader = LazyLoader()54        self.loader.drawIcon.connect(self.drawIcon)55        self.loader.done.connect(self.thread.quit)56        self.loader.moveToThread(self.thread)57        self.thread.started.connect(partial(self.loader.load, self.vid))58        self.thread.start()59    def drawIcon(self, data: bytes):60        pixmap = QPixmap()61        pixmap.loadFromData(data)62        scaled = pixmap.scaledToHeight(70, Qt.SmoothTransformation)63        icon = QIcon()64        # ã¢ã¤ãã é¸ææã«ã¢ã¤ã³ã³ãéããªããªãããã«ãnormalã¨selectedã«åãç»åãç»é²ããã65        icon.addPixmap(scaled, QIcon.Normal)66        icon.addPixmap(scaled, QIcon.Selected)67        self.setIcon(icon)68class VideoItemList(QListWidget):69    def __init__(self, parent, already_open_browser):70        super(VideoItemList, self).__init__(parent)71        self.setFrameStyle(QFrame.NoFrame)72        self.setIconSize(QSize(125, 70))73        self.setWordWrap(True)...EditorGlobals.py
Source:EditorGlobals.py  
1from pandac.PandaModules import *2from direct.interval.IntervalGlobal import *3from direct.showbase.DirectObject import *4from pirates.mockup import PythonNodePath5from pirates.effects import DynamicLight6from pirates.creature import Creature7from pirates.creature.Alligator import Alligator8from pirates.creature.Bat import Bat9from pirates.creature.Chicken import Chicken10from pirates.creature.Crab import Crab11from pirates.creature.Dog import Dog12from pirates.creature.FlyTrap import FlyTrap13from pirates.creature.Monkey import Monkey14from pirates.creature.Pig import Pig15from pirates.creature.Rooster import Rooster16from pirates.creature.Scorpion import Scorpion17from pirates.creature.Seagull import Seagull18from pirates.creature.Stump import Stump19from pirates.creature.Wasp import Wasp20from pirates.pirate import AvatarTypes21from pirates.ship import ShipGlobals22from pirates.effects import SoundFX23LOD_STATE_NORMAL = 024LOD_STATE_HIGH = 125LOD_STATE_LOW = 226LOD_STATE_MED = 327flickerTracks = []28def LightDynamic(objData, parent = render, drawIcon = True):29    if objData and objData.has_key('Pos'):30        objPos = objData['Pos']31    else:32        objPos = Vec3(0, 0, 0)33    if objData and objData.has_key('Hpr'):34        objHpr = objData['Hpr']35    else:36        objHpr = Vec3(0, 0, 0)37    color = None38    if objData and objData.has_key('Visual'):39        if objData['Visual'].has_key('Color'):40            color = objData['Visual']['Color']41    attenuation = None42    if objData and objData.has_key('Attenuation'):43        attenuation = (0, 0, float(objData['Attenuation']))44    45    intensity = None46    if objData and objData.has_key('Intensity'):47        intensity = float(objData['Intensity'])48    49    coneAngle = None50    dropOff = None51    if objData and objData.has_key('ConeAngle'):52        coneAngle = float(objData['ConeAngle'])53        if coneAngle == 0.0:54            objData['ConeAngle'] = '60.0'55            coneAngle = 60.056    57    if objData and objData.has_key('DropOff'):58        dropOff = float(objData['DropOff'])59    60    exponent = None61    flickering = False62    if objData and objData.has_key('Flickering') and objData['Flickering'] == True:63        flickering = True64    65    flickRate = 1.066    if objData and objData.has_key('FlickRate'):67        flickRate = float(objData['FlickRate'])68    69    lightType = DynamicLight.DYN_LIGHT_POINT70    if objData and objData.has_key('LightType'):71        typeString = objData['LightType']72        if typeString == 'AMBIENT':73            lightType = DynamicLight.DYN_LIGHT_AMBIENT74        elif typeString == 'DIRECTIONAL':75            lightType = DynamicLight.DYN_LIGHT_DIRECTIONAL76        elif typeString == 'SPOT':77            lightType = DynamicLight.DYN_LIGHT_SPOT78    light = DynamicLight.DynamicLight(type = lightType, parent = parent, pos = objPos, hpr = objHpr, color = color, atten = attenuation, exp = exponent, flicker = flickering, drawIcon = drawIcon)79    light.turnOff()80    if intensity:81        light.setIntensity(intensity)82    83    if coneAngle:84        light.setConeAngle(coneAngle)85    86    if dropOff:87        light.setDropOff(dropOff)88    89    light.setFlickRate(flickRate)90    light.turnOn()91    if hasattr(base, 'pe'):92        base.pe.dynamicLights.append(light)93    94    return light95def CreateAnimal(species = None):96    if not species:97        species = 'Pig'98    99    exec 'animal = %s()' % species100    animal.generateCreature()101    return animal102def CreateCreature(species = None):103    if not species:104        species = 'Crab'105    106    exec 'creature = %s()' % species107    creature.show()108    creature.generateCreature()109    return creature110def CreateSFX(sfxFile = None, volume = 0.5, looping = True, delayMin = 0, delayMax = 0, pos = None, hpr = None, parent = None, drawIcon = True):111    soundFX = SoundFX.SoundFX(sfxFile = sfxFile, volume = volume, looping = looping, delayMin = delayMin, delayMax = delayMax, pos = pos, hpr = hpr, parent = parent, listenerNode = base.cam, drawIcon = drawIcon)112    return soundFX113shipList = ShipGlobals.SHIP_CLASS_LIST114notUsedShipList = [115    'DINGHY',116    'INTERCEPTORL4',117    'MERCHANTL4',118    'WARSHIPL4',119    'DAUNTLESS',120    'FLYING_DUTCHMAN',121    'SKEL_WARSHIPL3',122    'SKEL_INTERCEPTORL3']123numShips = len(shipList) - 1124for index in range(numShips, -1, -1):125    if shipList[index] in notUsedShipList:...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!!
