Best Python code snippet using ATX
08b15.py
Source:08b15.py
...34 :return: None35 """36 self.screen_handler.draw_screen(self.document, self.using_mode)37 pygame.display.update()38 def save_screen(self):39 """40 Saves screenshot into /screens41 :return: None42 """43 path = 'screens/output_%s.png' % str(datetime.datetime.now())[:-7].replace(":", ",")44 save_screen = pygame.Surface((self.screen_handler.size[0] * 2, self.screen_handler.size[1] * 2))45 save_screen.blit(self.screen_handler.screen, (0, 0))46 save_screen.blit(pygame.transform.flip(self.screen_handler.screen, 0, 1), (0, self.screen_handler.size[1]))47 save_screen.blit(pygame.transform.flip(self.screen_handler.screen, 1, 0), (self.screen_handler.size[0], 0))48 save_screen.blit(pygame.transform.flip(self.screen_handler.screen, 1, 1), (self.screen_handler.size[0],49 self.screen_handler.size[1]))50 pygame.image.save(save_screen, path)51pygame.init()52X = Main((1000, 1000))...
download_image.py
Source:download_image.py
1from tempfile import NamedTemporaryFile2from cv2 import imread, imwrite, resize, IMREAD_UNCHANGED3import requests4def save_screen(element, driver):5 file = NamedTemporaryFile(delete=False, suffix=".png")6 element.get_element(driver).screenshot(file.name)7 im_width, im_height = driver.execute_script(8 "return [arguments[0].naturalWidth, arguments[0].naturalHeight];", element.get_element(driver)9 )10 image = imread(file.name, IMREAD_UNCHANGED)11 imwrite(file.name, resize(image, (im_width, im_height)))12 return file13def wont_read_or_rgba(image_file):14 cv_image = imread(image_file.name, IMREAD_UNCHANGED)15 return cv_image is None or len(cv_image.shape) == 3 and cv_image.shape[2] == 416def get_image_element(driver, element, force_screenshot=False):17 """download this image or cut screen"""18 def on_element_lost():19 print("Element lost")20 def get_src(elem):21 return driver.execute_script("return arguments[0].src;", elem.get_element(driver))22 src = element.safe_operation_wrapper(get_src, on_element_lost)23 if force_screenshot:24 return save_screen(element, driver)25 if src is not None:26 if src.find(".svg") != -1:27 print("\nsrc svg")28 return save_screen(element, driver)29 try:30 file = NamedTemporaryFile(delete=False, suffix=".png")31 r = requests.get(src, stream=True, allow_redirects=False)32 if r.status_code == 200 and len(r.content):33 file.write(r.content)34 file.seek(0)35 return file36 except (37 requests.exceptions.MissingSchema,38 requests.exceptions.InvalidURL,39 requests.exceptions.InvalidSchema,40 requests.exceptions.ConnectionError,41 ) as exc:42 print("\nexception", exc)43 print("\nno source or src request returned an exception", save_screen)...
s_params_generator.py
Source:s_params_generator.py
...17 self.generate_screen = screens.GenerateScreen(input_data, measurements_text, self.conf)18 self.generate_screen.switch_window.connect(self.show_save_screen)19 self.input_screen.close()20 self.generate_screen.showMaximized()21 def show_save_screen(self, numerical_data):22 self.save_screen = screens.SaveScreen(numerical_data, self.conf['touchstone'])23 self.save_screen.exit_signal.connect(exit_application)24 self.save_screen.restart_signal.connect(self.restart_application)25 self.save_screen.cancel_signal.connect(self.cancel_save)26 self.save_screen.exec()27 def restart_application(self):28 self.conf = read_configurations()29 self.save_screen.close()30 self.generate_screen.close()31 self.show_input_screen()32 self.input_screen.show()33 def cancel_save(self):34 self.save_screen.close()35def exit_application():...
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!!