Best Python code snippet using AutoItDriverServer_python
imageviewer.py
Source: imageviewer.py
1# ------------------------------------------------------------------------------2# Display an image in a window.3#4def showImage(image, title = '',5 new_window = False, resize_window = False, fit_to_window = False):6 if new_window:7 v = ImageViewer()8 resize_window = True9 else:10 from chimera import dialogs11 v = dialogs.find(ImageViewer.name, create=False)12 if v is None:13 v = dialogs.find(ImageViewer.name, create=True)14 resize_window = True15 v.set_image(image, resize_window, fit_to_window)16 if title:17 v.set_title(title)18 v.enter()19# ------------------------------------------------------------------------------20#21from chimera.baseDialog import ModelessDialog22class ImageViewer(ModelessDialog):23 title = "Image Viewer"24 name = "image viewer"25 buttons = ("Fit", "Full", "Window", "Save", "Close")26 help = 'UsersGuide/midas/segment.html#sliceimage-window'27 def fillInUI(self, parent):28 self.image = None29 self.shown_size = None30 self.image_tag = None31 import Tkinter32 parent.rowconfigure(0, weight=1)33 parent.columnconfigure(0, weight=1)34 self.canvas = c = Tkinter.Canvas(parent, highlightthickness = 0)35 c.grid(row = 0, column = 0, sticky = 'news')36 sv = Tkinter.Scrollbar(parent, orient=Tkinter.VERTICAL, command=c.yview)37 sv.grid(row = 0, column = 1, sticky = 'ns')38 sh = Tkinter.Scrollbar(parent, orient=Tkinter.HORIZONTAL,39 command=c.xview)40 sh.grid(row = 1, column = 0, sticky = 'ew')41 c.config(yscrollcommand=sv.set)42 c.config(xscrollcommand=sh.set)43 def set_title(self, title):44 self._toplevel.title(title)45 def set_image(self, image, resize_window = False, fit_to_window = False):46 self.image = image47 if fit_to_window and not resize_window:48 self.Fit()49 else:50 self.set_canvas_image(image, resize_window)51 def set_canvas_image(self, image, resize_window = False):52 from PIL.ImageTk import PhotoImage53 pi = PhotoImage(image)54 c = self.canvas55 c.save_image = pi # Tk Label keeps no count.56 t = c.create_image(0,0,anchor="nw",image=pi)57 if not self.image_tag is None:58 c.delete(self.image_tag)59 self.image_tag = t60 self.shown_size = w,h = image.size61 c.config(scrollregion=(0,0,w,h))62 if resize_window:63 self.Window()64 def Window(self):65 if self.shown_size is None:66 return67 # Resize window to fit image.68 w,h = self.shown_size69 self.canvas.config(width = w, height = h)70 self.uiMaster().winfo_toplevel().geometry('')71 def Fit(self):72 if self.image is None:73 return74 c = self.canvas75 w,h = c.winfo_width(), c.winfo_height()76 # Preserve aspect ratio.77 wi,hi = self.image.size78 if h*wi > w*hi:79 h = int((float(w)/wi)*hi)80 else:81 w = int((float(h)/hi)*wi)82 if w <= 0 or h <= 0:83 return84 from PIL import Image85 ri = self.image.resize((w,h), Image.ANTIALIAS)86 self.set_canvas_image(ri)87 def Full(self):88 if self.image is None:89 return90 self.set_canvas_image(self.image)91 def Save(self):92 if self.image is None:93 return94 def save(okay, dialog, self = self):95 if not okay:96 return97 paths_and_types = dialog.getPathsAndTypes()98 if len(paths_and_types) == 0:99 return100 path, format = paths_and_types[0]101 self.image.save(path, format)102 from OpenSave import SaveModeless103 SaveModeless(title = 'Save Image',104 filters = [('JPEG', '*.jpg', '.jpg'),105 ('PNG', '*.png', '.png'),106 ('TIFF', '*.tif', '.tif')],107 command = save )108# ------------------------------------------------------------------------------109#110from chimera import dialogs...
relative_resize.py
Source: relative_resize.py
...15 bottom_neighbors = neighbors.get('bottom')16 # has a neighbor on both sides17 if direction == 'left' and (left_neighbors and right_neighbors):18 # boss.active_tab.set_active_window(left_neighbors[0])19 boss.active_tab.resize_window('narrower', 1)20 # boss.active_tab.set_active_window(current_window_id)21 # only has left neighbor22 elif direction == 'left' and left_neighbors:23 boss.active_tab.resize_window('wider', 1)24 # only has right neighbor25 elif direction == 'left' and right_neighbors:26 boss.active_tab.resize_window('narrower', 1)27 # has a neighbor on both sides28 elif direction == 'right' and (left_neighbors and right_neighbors):29 # boss.active_tab.set_active_window(left_neighbors[0])30 boss.active_tab.resize_window('wider', 1)31 # boss.active_tab.set_active_window(current_window_id)32 # only has left neighbor33 elif direction == 'right' and left_neighbors:34 boss.active_tab.resize_window('narrower', 1)35 # only has right neighbor36 elif direction == 'right' and right_neighbors:37 boss.active_tab.resize_window('wider', 1)38 # has a neighbor above and below39 elif direction == 'up' and (top_neighbors and bottom_neighbors):40 # boss.active_tab.set_active_window(top_neighbors[0])41 boss.active_tab.resize_window('shorter', 1)42 # boss.active_tab.set_active_window(current_window_id)43 # only has top neighbor44 elif direction == 'up' and top_neighbors:45 boss.active_tab.resize_window('taller', 1)46 # only has bottom neighbor47 elif direction == 'up' and bottom_neighbors:48 boss.active_tab.resize_window('shorter', 1)49 # has a neighbor above and below50 elif direction == 'down' and (top_neighbors and bottom_neighbors):51 # boss.active_tab.set_active_window(top_neighbors[0])52 boss.active_tab.resize_window('taller', 1)53 # boss.active_tab.set_active_window(current_window_id)54 # only has top neighbor55 elif direction == 'down' and top_neighbors:56 boss.active_tab.resize_window('shorter', 1)57 # only has bottom neighbor58 elif direction == 'down' and bottom_neighbors:...
Check out the latest blogs from LambdaTest on this topic:
One of the essential parts when performing automated UI testing, whether using Selenium or another framework, is identifying the correct web elements the tests will interact with. However, if the web elements are not located correctly, you might get NoSuchElementException in Selenium. This would cause a false negative result because we won’t get to the actual functionality check. Instead, our test will fail simply because it failed to interact with the correct element.
In an ideal world, you can test your web application in the same test environment and return the same results every time. The reality can be difficult sometimes when you have flaky tests, which may be due to the complexity of the web elements you are trying to perform an action on your test case.
We launched LT Browser in 2020, and we were overwhelmed by the response as it was awarded as the #5 product of the day on the ProductHunt platform. Today, after 74,585 downloads and 7,000 total test runs with an average of 100 test runs each day, the LT Browser has continued to help developers build responsive web designs in a jiffy.
Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.
Recently, I was going through some of the design patterns in Java by reading the book Head First Design Patterns by Eric Freeman, Elisabeth Robson, Bert Bates, and Kathy Sierra.
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!!