How to use resize_window method in toolium

Best Python code snippet using toolium_python

imageviewer.py

Source:imageviewer.py Github

copy

Full Screen

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...

Full Screen

Full Screen

relative_resize.py

Source:relative_resize.py Github

copy

Full Screen

...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:...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run toolium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful