Best Python code snippet using localstack_python
aux_viewport.py
Source:aux_viewport.py
1from ..base import *2from ..button import Button3from ..tooltip import ToolTip4from ..dialogs import *5from direct.interval.IntervalGlobal import LerpColorScaleInterval, Sequence6class ViewportButton(Button):7 def __init__(self, parent, name, icon_id, tooltip_text):8 gfx_ids = Skin.atlas.gfx_ids["viewport_button"]9 Button.__init__(self, parent, gfx_ids, "", icon_id, tooltip_text,10 button_type="viewport_button")11 self._cursor_region = MouseWatcherRegion(f"viewport_button_{name}", 0., 0., 0., 0.)12 self.mouse_region.sort = 1113 def get_cursor_region(self):14 return self._cursor_region15 def update_mouse_region_frames(self, exclude="", recurse=True):16 Button.update_mouse_region_frames(self, exclude, recurse)17 x, y = self.get_pos(net=True)18 w, h = self.get_size()19 w_ref, h_ref = Mgr.get("window_size")20 l, r, b, t = get_relative_region_frame(x, y, w, h, w_ref, h_ref)21 self._cursor_region.frame = (2. * l - 1., 2. * r - 1., 2. * b - 1., 2. * t - 1.)22class ViewportButtonBar(WidgetCard):23 height = 024 def __init__(self, parent):25 WidgetCard.__init__(self, "viewport_button_bar", parent)26 self.sizer = Sizer("horizontal")27 self._is_hidden = False28 self._btns = []29 def add_button(self, name, icon_id, tooltip_text, command, proportions=(0., 0.)):30 sizer = self.sizer31 btn = ViewportButton(self, name, icon_id, tooltip_text)32 btn.command = command33 sizer.add(btn, proportions=proportions)34 self._btns.append(btn)35 if not self.height:36 ViewportButtonBar.height = btn.min_size[1]37 @property38 def buttons(self):39 return self._btns40 def update_images(self):41 if self._is_hidden:42 return43 self._sizer.update_images()44 width, height = self.get_size()45 img = PNMImage(width, height, 4)46 x, y = self.get_pos()47 for widget in self._sizer.get_widgets(include_children=False):48 x_w, y_w = widget.get_pos(net=True)49 x_w -= x50 y_w -= y51 widget_img = widget.get_image()52 if widget_img:53 img.copy_sub_image(widget_img, x_w, y_w, 0, 0)54 tex = self.texture55 tex.load(img)56 l = x57 r = x + width58 b = -(y + height)59 t = -y60 quad = self.create_quad((l, r, b, t))61 quad.set_texture(tex)62 self._image = img63 def update_mouse_region_frames(self, exclude=""):64 self._sizer.update_mouse_region_frames(exclude)65 def hide(self):66 if self._is_hidden:67 return False68 mouse_watcher = self.mouse_watcher69 for widget in self._sizer.get_widgets():70 mouse_region = widget.mouse_region71 if mouse_region and not widget.is_hidden():72 mouse_watcher.remove_region(mouse_region)73 self.quad.hide()74 self._is_hidden = True75 return True76 def show(self):77 if not self._is_hidden:78 return False79 mouse_watcher = self.mouse_watcher80 for widget in self.sizer.get_widgets():81 mouse_region = widget.mouse_region82 if mouse_region and not widget.is_hidden(check_ancestors=False):83 mouse_watcher.add_region(mouse_region)84 self.quad.show()85 self._is_hidden = False86 self.update_images()87 return True88 def is_hidden(self, check_ancestors=True):89 return self._is_hidden90class ViewportBorder(Widget):91 _frame_viz = None92 _sequence = None93 @classmethod94 def init(cls):95 vertex_format = GeomVertexFormat.get_v3()96 vertex_data = GeomVertexData("viewport_frame_viz", vertex_format, Geom.UH_static)97 pos_writer = GeomVertexWriter(vertex_data, "vertex")98 pos_writer.add_data3(0., 0., 0.)99 pos_writer.add_data3(-1., 0., 0.)100 pos_writer.add_data3(-1., 0., 1.)101 pos_writer.add_data3(0., 0., 1.)102 geom_node = GeomNode("viewport_frame_viz")103 geom = Geom(vertex_data)104 geom_node.add_geom(geom)105 lines = GeomLines(Geom.UH_static)106 geom.add_primitive(lines)107 lines.add_vertices(0, 1)108 lines.add_vertices(1, 2)109 lines.add_vertices(2, 3)110 lines.add_vertices(0, 3)111 cls._frame_viz = viz = Mgr.get("gui_root").attach_new_node(geom_node)112 viz.hide()113 viz.set_bin("gui", 4)114 lerp_interval1 = LerpColorScaleInterval(viz, .5, 0., 1., blendType="easeInOut")115 lerp_interval2 = LerpColorScaleInterval(viz, .5, 1., blendType="easeInOut")116 cls._sequence = Sequence(lerp_interval1, lerp_interval2)117 def __init__(self, parent, viewport, size, resize_dir=""):118 Widget.__init__(self, "draggable_viewport_border", parent, {}, "", True)119 self._size = self._min_size = size120 self._resize_dir = resize_dir121 self._viewport = viewport122 self.mouse_region.sort = 11123 prefix = resize_dir if resize_dir else "corner"124 name = f"{prefix}_viewport_border"125 self._cursor_region = MouseWatcherRegion(name, 0., 0., 0., 0.)126 self._mouse_start_pos = ()127 self._listener = DirectObject()128 def get_cursor_region(self):129 return self._cursor_region130 def update_images(self, recurse=True, size=None): pass131 def update_mouse_region_frames(self, exclude="", recurse=True):132 Widget.update_mouse_region_frames(self, exclude, recurse)133 x, y = self.get_pos(net=True)134 w, h = self.get_size()135 w_ref, h_ref = Mgr.get("window_size")136 l, r, b, t = get_relative_region_frame(x, y, w, h, w_ref, h_ref)137 self._cursor_region.frame = (2. * l - 1., 2. * r - 1., 2. * b - 1., 2. * t - 1.)138 def __get_offsets(self):139 mouse_pointer = Mgr.get("mouse_pointer", 0)140 mouse_start_x, mouse_start_y = self._mouse_start_pos141 mouse_x, mouse_y = mouse_pointer.x, mouse_pointer.y142 resize_dir = self._resize_dir143 if resize_dir == "vertical":144 return (int(mouse_x - mouse_start_x), 0)145 elif resize_dir == "horizontal":146 return (0, int(mouse_y - mouse_start_y))147 else:148 return (int(mouse_x - mouse_start_x), int(mouse_y - mouse_start_y))149 def _resize_aux_viewport(self, task):150 mouse_pointer = Mgr.get("mouse_pointer", 0)151 mouse_x, mouse_y = mouse_pointer.x, mouse_pointer.y152 viz = self._frame_viz153 w_v, h_v = GD["viewport"]["size"]154 resize_dir = self._resize_dir155 if resize_dir == "vertical":156 sx = min(w_v, max(1, viz.get_pos()[0] - mouse_x))157 viz.set_sx(sx)158 elif resize_dir == "horizontal":159 sz = min(h_v, max(1, -mouse_y - viz.get_pos()[2]))160 viz.set_sz(sz)161 else:162 x, _, y = viz.get_pos()163 sx = min(w_v, max(1, x - mouse_x))164 sz = min(h_v, max(1, -mouse_y - y))165 viz.set_scale(sx, 1., sz)166 return task.cont167 def on_left_down(self):168 viz = self._frame_viz169 viz.show()170 self._sequence.loop()171 sizer = self._viewport.sizer172 x, y = sizer.get_pos(net=True)173 w, h = sizer.get_size()174 viz.set_pos(x + w, 0., -y - h)175 viz.set_scale(w, 1., h)176 mouse_pointer = Mgr.get("mouse_pointer", 0)177 self._mouse_start_pos = (mouse_pointer.x, mouse_pointer.y)178 Mgr.add_task(self._resize_aux_viewport, "resize_aux_viewport")179 self._listener.accept("gui_mouse1-up", self.__on_left_up)180 cancel_resize = lambda: self.__on_left_up(cancel_resize=True)181 self._listener.accept("gui_mouse3", cancel_resize)182 self._listener.accept("focus_loss", cancel_resize)183 Mgr.do("enable_gui", False)184 Mgr.enter_state("inactive")185 interface_ids = GD["viewport"]186 if interface_ids[2] is not None:187 interface_id = interface_ids[2 if interface_ids[1] == "main" else 1]188 Mgr.enter_state("inactive", interface_id)189 def __on_left_up(self, cancel_resize=False):190 Mgr.do("enable_gui")191 Mgr.exit_state("inactive")192 interface_ids = GD["viewport"]193 if interface_ids[2] is not None:194 interface_id = interface_ids[2 if interface_ids[1] == "main" else 1]195 Mgr.exit_state("inactive", interface_id)196 Mgr.remove_task("resize_aux_viewport")197 self._sequence.finish()198 self._listener.ignore_all()199 self._frame_viz.hide()200 delta_x, delta_y = self.__get_offsets()201 self._mouse_start_pos = ()202 if not cancel_resize:203 self._viewport.resize(delta_x, delta_y)204class AdjacentViewportBorder(ViewportBorder):205 def __init__(self, parent, viewport, size):206 ViewportBorder.__init__(self, parent, viewport, size, "vertical")207 def _resize_aux_viewport(self, task):208 viz = self._frame_viz209 sizer = self._viewport.sizer210 w = GD["viewport"]["size"][0] + Skin.options["viewport_border_thickness"]211 w += sizer.get_size()[0]212 sx = min(w, max(1, viz.get_pos()[0] - Mgr.get("mouse_pointer", 0).x))213 viz.set_sx(sx)214 return task.cont215class AuxiliaryViewport:216 def __init__(self, window, viewport_sizer, adjacent_viewport_sizer):217 ViewportBorder.init()218 self._interface_name = ""219 self._placement = "overlaid" # alternative: "adjacent"220 self._viewport_sizer = viewport_sizer221 self._viewport_sizer_adj = adjacent_viewport_sizer222 self.display_region = None223 self._cursor_region = MouseWatcherRegion("viewport2", 0., 0., 0., 0.)224 Mgr.expose("viewport2_cursor_region", lambda: self._cursor_region)225 self._mouse_region_mask = mask = MouseWatcherRegion("aux_viewport_mask", 0., 0., 0., 0.)226 flags = MouseWatcherRegion.SF_mouse_button | MouseWatcherRegion.SF_mouse_position227 mask.suppress_flags = flags228 mask.sort = 900229 self._spacer_h_cell = viewport_sizer.add((0, 0), proportions=(100., 0.))230 sizer = Sizer("vertical")231 self._sizer = subsizer = Sizer("horizontal")232 border_sizer = Sizer("vertical")233 self._btn_sizer = subsizer2 = Sizer("vertical")234 self._display_sizer = display_sizer = Sizer("horizontal")235 w_d, h_d = 300, 200236 display_sizer.default_size = (w_d, h_d)237 l, r, b, t = Skin.atlas.inner_borders["aux_viewport"]238 r = b = thickness = Skin.options["viewport_border_thickness"]239 self._spacer_v_cell = sizer.add((0, 0), proportions=(0., 100.))240 sizer.add(subsizer, proportions=(1., 1.))241 subsizer.add(border_sizer)242 subsizer.add(subsizer2, (1., 1.))243 self._border_topleft = border = ViewportBorder(window, self, (l, t))244 border_sizer.add(border)245 self._border_left = border = ViewportBorder(window, self, (l, h_d), "vertical")246 border_sizer.add(border, (0., 1.))247 self._border_top = border = ViewportBorder(window, self, (w_d, t), "horizontal")248 subsizer2.add(border, (1., 0.))249 borders = (0, r, 0, 0)250 subsizer2.add(display_sizer, (1., 1.), borders=borders)251 btn_bar = ViewportButtonBar(window)252 btn_bar.add_button("swap", "icon_viewport_swap", "Swap viewports",253 self.__swap_viewports, proportions=(1., 0.))254 btn_bar.add_button("make_adjacent", "icon_viewport_adjacent", "Place viewports side-by-side",255 lambda: self.__overlay(False), proportions=(1., 0.))256 btn_bar.add_button("exit", "icon_viewport_exit", "",257 self.__close, proportions=(1., 0.))258 self._on_close = None259 self._btn_bar = btn_bar260 borders = (0, r, b, 0)261 cell = subsizer2.add(btn_bar, borders=borders)262 subsizer2.remove_cell(cell)263 cell = viewport_sizer.add(sizer, (1., 1.))264 viewport_sizer.remove_cell(cell)265 self.sizer_cell = cell266 # Create the adjacent viewport components267 self._sizer_adj = sizer = Sizer("horizontal")268 self._display_sizer_adj = display_sizer = Sizer("horizontal")269 display_sizer.default_size = (w_d, h_d)270 height = h_d + 2 * thickness271 self._border_adj = border = AdjacentViewportBorder(window, self, (l, height))272 sizer.add(border)273 borders = (0,) + (thickness,) * 3274 self._btn_sizer_adj = subsizer = Sizer("vertical")275 sizer.add(subsizer, (1., 1.), borders=borders)276 subsizer.add(display_sizer, (1., 1.))277 cell = adjacent_viewport_sizer.add(sizer, (1., 1.))278 adjacent_viewport_sizer.remove_cell(cell)279 self._sizer_cell_adj = cell280 GD["viewport"]["aux_region"] = (0, 0, 0, 0)281 Mgr.accept("open_aux_viewport", self.__open)282 Mgr.accept("close_aux_viewport", self.__request_close)283 @property284 def sizer(self):285 return self._sizer if self._placement == "overlaid" else self._sizer_adj286 def update(self):287 sizer = self._display_sizer if self._placement == "overlaid" else self._display_sizer_adj288 x, y = sizer.get_pos(net=True)289 w, h = sizer.get_size()290 w_ref, h_ref = Mgr.get("window_size")291 GD["viewport"]["pos_aux"] = (x, y)292 GD["viewport"]["size_aux"] = (w, h)293 GD["viewport"]["frame_aux"] = get_relative_region_frame(x, y, w, h, w_ref, h_ref)294 l, r, b, t = Skin.atlas.inner_borders["aux_viewport"]295 r = b = thickness = Skin.options["viewport_border_thickness"]296 if self._placement == "adjacent":297 t = thickness298 x -= l299 y -= t300 w += l + r301 h += ViewportButtonBar.height + b + t302 GD["viewport"]["aux_region"] = (x, y, w, h)303 l, r, b, t = get_relative_region_frame(x, y, w, h, w_ref, h_ref)304 self.display_region.dimensions = (l, r, b, t)305 l_v, r_v, b_v, t_v = GD["viewport"]["frame"]306 w = r_v - l_v307 h = t_v - b_v308 l = (l - l_v) / w309 r = (r - l_v) / w310 b = (b - b_v) / h311 t = (t - b_v) / h312 self._mouse_region_mask.frame = (2. * l - 1., 2. * r - 1., 2. * b - 1., 2. * t - 1.)313 def __on_enter(self, *args):314 viewport1_id = GD["viewport"][1]315 mask = self._mouse_region_mask316 if viewport1_id == "main":317 GD.mouse_watcher.add_region(mask)318 else:319 for mw in GD["viewport"]["mouse_watchers2"]:320 mw.add_region(mask)321 def __on_leave(self, *args):322 viewport1_id = GD["viewport"][1]323 mask = self._mouse_region_mask324 if viewport1_id == "main":325 GD.mouse_watcher.remove_region(mask)326 else:327 for mw in GD["viewport"]["mouse_watchers2"]:328 mw.remove_region(mask)329 def __swap_viewports(self):330 viewport1_id = GD["viewport"][1]331 viewport2_id = GD["viewport"][2]332 GD["viewport"][1] = viewport2_id333 GD["viewport"][2] = viewport1_id334 color1 = GD["viewport"]["border_color1"]335 color2 = GD["viewport"]["border_color2"]336 GD["viewport"]["border_color1"] = color2337 GD["viewport"]["border_color2"] = color1338 index = GD["viewport"]["active"]339 color = GD["viewport"][f"border_color{index}"]340 GD["viewport"][f"border{index}"].clear_color = color341 Mgr.update_app("viewport")342 mask = self._mouse_region_mask343 interface_id = GD["viewport"][index]344 Mgr.do("set_interface_status", interface_id)345 if viewport1_id == "main":346 GD.mouse_watcher.remove_region(mask)347 for mw in GD["viewport"]["mouse_watchers2"]:348 mw.add_region(mask)349 Mgr.update_app("viewport_region_sort_incr", 22)350 for dr in GD["viewport"]["display_regions"]:351 dr.sort += 22352 for dr in GD["viewport"]["display_regions2"]:353 dr.sort -= 22354 else:355 GD.mouse_watcher.add_region(mask)356 for mw in GD["viewport"]["mouse_watchers2"]:357 mw.remove_region(mask)358 Mgr.update_app("viewport_region_sort_incr", -22)359 for dr in GD["viewport"]["display_regions"]:360 dr.sort -= 22361 for dr in GD["viewport"]["display_regions2"]:362 dr.sort += 22363 def __overlay(self, overlaid=True):364 self._placement = "overlaid" if overlaid else "adjacent"365 Mgr.remove_cursor_regions("aux_viewport")366 Mgr.add_cursor_region("aux_viewport", self._cursor_region)367 for btn in self._btn_bar.buttons:368 cursor_region = btn.get_cursor_region()369 Mgr.add_cursor_region("aux_viewport", cursor_region)370 if overlaid:371 self._border_adj.hide()372 self._viewport_sizer_adj.remove_cell(self._sizer_cell_adj)373 self._viewport_sizer_adj.sizer_cell.proportions = (0., 0.)374 self._border_topleft.show()375 cursor_region = self._border_topleft.get_cursor_region()376 Mgr.add_cursor_region("aux_viewport", cursor_region)377 cursor_id = "move_nwse"378 Mgr.set_cursor(cursor_id, cursor_region.name)379 self._border_top.show()380 cursor_region = self._border_top.get_cursor_region()381 Mgr.add_cursor_region("aux_viewport", cursor_region)382 cursor_id = "move_ns"383 Mgr.set_cursor(cursor_id, cursor_region.name)384 self._border_left.show()385 cursor_region = self._border_left.get_cursor_region()386 Mgr.add_cursor_region("aux_viewport", cursor_region)387 cursor_id = "move_ew"388 Mgr.set_cursor(cursor_id, cursor_region.name)389 r = b = Skin.options["viewport_border_thickness"]390 self._btn_bar.sizer_cell.borders = (0, r, b, 0)391 btn = self._btn_bar.buttons[1]392 btn.command = lambda: self.__overlay(False)393 btn.tooltip_text = "Place viewports side-by-side"394 btn.set_icon_id("icon_viewport_adjacent")395 self._btn_sizer_adj.remove_cell(self._btn_bar.sizer_cell)396 self._btn_sizer.add_cell(self._btn_bar.sizer_cell)397 viewport_sizer = self._viewport_sizer398 viewport_sizer.add_cell(self.sizer_cell)399 else:400 self._border_topleft.hide()401 self._border_top.hide()402 self._border_left.hide()403 self._viewport_sizer.remove_cell(self.sizer_cell)404 self._border_adj.show()405 cursor_region = self._border_adj.get_cursor_region()406 Mgr.add_cursor_region("aux_viewport", cursor_region)407 cursor_id = "move_ew"408 Mgr.set_cursor(cursor_id, cursor_region.name)409 self._btn_bar.sizer_cell.borders = None410 btn = self._btn_bar.buttons[1]411 btn.command = self.__overlay412 btn.tooltip_text = "Overlay auxiliary viewport"413 btn.set_icon_id("icon_viewport_overlaid")414 self._btn_sizer.remove_cell(self._btn_bar.sizer_cell)415 self._btn_sizer_adj.add_cell(self._btn_bar.sizer_cell)416 viewport_sizer = self._viewport_sizer_adj417 viewport_sizer.add_cell(self._sizer_cell_adj)418 viewport_sizer.sizer_cell.proportions = (1., 1.)419 viewport_sizer.update(viewport_sizer.get_size())420 viewport_sizer.update_images()421 viewport_sizer.update_mouse_region_frames()422 Mgr.do("update_window")423 def resize(self, delta_x=0, delta_y=0):424 if not (delta_x or delta_y):425 return426 if self._placement == "overlaid":427 viewport_sizer = self._viewport_sizer428 w_v, h_v = viewport_sizer.get_size()429 w, h = self._sizer.get_size()430 w -= delta_x431 h -= delta_y432 w = min(w_v, max(1, w))433 h = min(h_v, max(1, h))434 if delta_x:435 proportion = (w_v - w) / w436 self._spacer_h_cell.proportions = (proportion, 0.)437 if delta_y:438 proportion = (h_v - h) / h439 self._spacer_v_cell.proportions = (0., proportion)440 viewport_sizer.set_min_size_stale()441 viewport_sizer.update(viewport_sizer.get_size())442 viewport_sizer.update_images()443 viewport_sizer.update_mouse_region_frames()444 self.update()445 Mgr.update_app("viewport")446 else:447 viewport_sizer = self._viewport_sizer_adj448 w1 = self._viewport_sizer.get_size()[0]449 w2 = viewport_sizer.get_size()[0]450 w1 += w2451 sizer_cell = self._viewport_sizer.sizer_cell452 w2 -= delta_x453 w2 = min(w1, max(1, w2))454 proportion = max(.0001, (w1 - w2) / w2)455 sizer_cell.proportions = (proportion, 1.)456 viewport_sizer.update(viewport_sizer.get_size())457 viewport_sizer.update_images()458 viewport_sizer.update_mouse_region_frames()459 Mgr.do("update_window")460 def __open(self, button_prefix="", interface_name="", on_close=None):461 self._interface_name = interface_name462 self._on_close = on_close463 btn = self._btn_bar.buttons[-1]464 btn.tooltip_text = f"Exit {interface_name} interface"465 ToolTip.hide()466 self._btn_bar.show()467 for btn in self._btn_bar.buttons:468 cursor_region = btn.get_cursor_region()469 Mgr.add_cursor_region("aux_viewport", cursor_region)470 Mgr.add_cursor_region("aux_viewport", self._cursor_region)471 if self._placement == "overlaid":472 self._border_topleft.show()473 cursor_region = self._border_topleft.get_cursor_region()474 Mgr.add_cursor_region("aux_viewport", cursor_region)475 cursor_id = "move_nwse"476 Mgr.set_cursor(cursor_id, cursor_region.name)477 self._border_top.show()478 cursor_region = self._border_top.get_cursor_region()479 Mgr.add_cursor_region("aux_viewport", cursor_region)480 cursor_id = "move_ns"481 Mgr.set_cursor(cursor_id, cursor_region.name)482 self._border_left.show()483 cursor_region = self._border_left.get_cursor_region()484 Mgr.add_cursor_region("aux_viewport", cursor_region)485 cursor_id = "move_ew"486 Mgr.set_cursor(cursor_id, cursor_region.name)487 self._btn_sizer.add_cell(self._btn_bar.sizer_cell)488 viewport_sizer = self._viewport_sizer489 viewport_sizer.add_cell(self.sizer_cell)490 else:491 self._border_adj.show()492 cursor_region = self._border_adj.get_cursor_region()493 Mgr.add_cursor_region("aux_viewport", cursor_region)494 cursor_id = "move_ew"495 Mgr.set_cursor(cursor_id, cursor_region.name)496 self._btn_sizer_adj.add_cell(self._btn_bar.sizer_cell)497 viewport_sizer = self._viewport_sizer_adj498 viewport_sizer.add_cell(self._sizer_cell_adj)499 viewport_sizer.sizer_cell.proportions = (1., 1.)500 viewport_sizer.update(viewport_sizer.get_size())501 viewport_sizer.update_images()502 viewport_sizer.update_mouse_region_frames()503 self.display_region = region = GD.window.make_display_region(0., 1., 0., 1.)504 region.active = True505 region.sort = 21506 color = Skin.colors["viewport_frame_inactive"]507 region.clear_color = color508 region.clear_depth = 1000.509 region.set_clear_color_active(True)510 region.set_clear_depth_active(True)511 GD["viewport"]["border2"] = region512 l, r, b, t = GD["viewport"]["frame"]513 region = GD.window.make_display_region(l, r, b, t)514 region.active = True515 color = GD.window.get_display_region(1).clear_color516 region.clear_color = color517 region.clear_depth = 1000.518 region.set_clear_color_active(True)519 region.set_clear_depth_active(True)520 GD["viewport"]["display_regions2"].append(region)521 input_ctrl = GD.showbase.mouseWatcher.parent522 mouse_watcher_node = MouseWatcher("main")523 mouse_watcher_node.set_display_region(region)524 mouse_watcher_node.set_modifier_buttons(ModifierButtons())525 mouse_watcher_node.add_region(self._mouse_region_mask)526 GD["viewport"]["mouse_watchers2"].append(mouse_watcher_node)527 mouse_watcher = input_ctrl.attach_new_node(mouse_watcher_node)528 btn_thrower_node = ButtonThrower(f"btn_thrower_{button_prefix}")529 btn_thrower_node.prefix = f"{button_prefix}_"530 btn_thrower_node.modifier_buttons = ModifierButtons()531 mouse_watcher.attach_new_node(btn_thrower_node)532 self.update()533 Mgr.update_app("viewport")534 Mgr.update_app("viewport_region_sort_incr", 22)535 for dr in GD["viewport"]["display_regions"]:536 dr.sort += 22537 return region, mouse_watcher_node538 def __close(self):539 self._interface_name = ""540 index = GD["viewport"]["active"]541 interface_id = GD["viewport"][index]542 if interface_id != "main":543 Mgr.do("set_interface_status")544 GD["viewport"]["active"] = 1545 if GD["viewport"][1] != "main":546 self.__swap_viewports()547 else:548 color = GD["viewport"]["border_color1"]549 GD["viewport"]["border1"].clear_color = color550 GD["viewport"][2] = None551 w, h = Mgr.get("window_size")552 l, r, b, t = GD["viewport"]["frame"]553 GD["fps_meter_display_region"].dimensions = (r - 800./w, r, b, b + 600./h)554 GD.mouse_watcher.remove_region(self._mouse_region_mask)555 Mgr.remove_cursor_regions("aux_viewport")556 self._btn_bar.hide()557 cell = self._btn_bar.sizer_cell558 cell.sizer.remove_cell(cell)559 if self._placement == "overlaid":560 self._border_topleft.hide()561 self._border_top.hide()562 self._border_left.hide()563 self._viewport_sizer.remove_cell(self.sizer_cell)564 else:565 self._border_adj.hide()566 self._viewport_sizer_adj.remove_cell(self._sizer_cell_adj)567 self._viewport_sizer_adj.sizer_cell.proportions = (0., 0.)568 region = self.display_region569 self.display_region = None570 GD["viewport"]["border1"] = GD.window571 GD["viewport"]["border2"] = None572 GD.window.remove_display_region(region)573 del GD["viewport"]["display_regions2"][:]574 del GD["viewport"]["mouse_watchers2"][:]575 if self._on_close:576 self._on_close()577 def __request_close(self, on_close):578 if GD["viewport"][2] is None:579 on_close()580 return581 def on_yes():582 self.__close()583 command = lambda task: on_close()584 Mgr.do_next_frame(command, "on_close_aux_viewport")585 title = f"Exit {self._interface_name} interface"586 message = f"The {self._interface_name} interface needs to be exited and any changes saved."587 message += "\n\nContinue?"588 MessageDialog(title=title,589 message=message,590 choices="yesno",591 on_yes=on_yes,...
ascii-mapper.py
Source:ascii-mapper.py
...202 w = map_width * scale + offset * 2203 h = map_height * scale + offset * 2204 viewport["scrollregion"] = (0, 0, w, h)205 props_dlg.withdraw()206def cancel_resize():207 user_width.set(map_width)208 user_height.set(map_height)209 props_dlg.withdraw()210filename_label = ttk.Label(props_dlg, text="Filename: (untitled)")211filename_label.grid(row=0, column=0, columnspan=2, padx=4, pady=4)212filler_label = ttk.Label(props_dlg, text="Filler char: " + filler)213filler_label.grid(row=1, column=0, columnspan=2, padx=4, pady=4)214def set_filler_from_brush():215 global filler216 filler = brush217 filler_label["text"] = "Filler char: " + filler218ttk.Button(219 props_dlg,220 text="Set from brush",...
client.py
Source:client.py
...18 def batch_modify_cluster_snapshots(self, SnapshotIdentifierList: List, ManualSnapshotRetentionPeriod: int = None, Force: bool = None) -> Dict:19 pass20 def can_paginate(self, operation_name: str = None):21 pass22 def cancel_resize(self, ClusterIdentifier: str) -> Dict:23 pass24 def copy_cluster_snapshot(self, SourceSnapshotIdentifier: str, TargetSnapshotIdentifier: str, SourceSnapshotClusterIdentifier: str = None, ManualSnapshotRetentionPeriod: int = None) -> Dict:25 pass26 def create_cluster(self, ClusterIdentifier: str, NodeType: str, MasterUsername: str, MasterUserPassword: str, DBName: str = None, ClusterType: str = None, ClusterSecurityGroups: List = None, VpcSecurityGroupIds: List = None, ClusterSubnetGroupName: str = None, AvailabilityZone: str = None, PreferredMaintenanceWindow: str = None, ClusterParameterGroupName: str = None, AutomatedSnapshotRetentionPeriod: int = None, ManualSnapshotRetentionPeriod: int = None, Port: int = None, ClusterVersion: str = None, AllowVersionUpgrade: bool = None, NumberOfNodes: int = None, PubliclyAccessible: bool = None, Encrypted: bool = None, HsmClientCertificateIdentifier: str = None, HsmConfigurationIdentifier: str = None, ElasticIp: str = None, Tags: List = None, KmsKeyId: str = None, EnhancedVpcRouting: bool = None, AdditionalInfo: str = None, IamRoles: List = None, MaintenanceTrackName: str = None, SnapshotScheduleIdentifier: str = None) -> Dict:27 pass28 def create_cluster_parameter_group(self, ParameterGroupName: str, ParameterGroupFamily: str, Description: str, Tags: List = None) -> Dict:29 pass30 def create_cluster_security_group(self, ClusterSecurityGroupName: str, Description: str, Tags: List = None) -> Dict:31 pass32 def create_cluster_snapshot(self, SnapshotIdentifier: str, ClusterIdentifier: str, ManualSnapshotRetentionPeriod: int = None, Tags: List = None) -> Dict:33 pass34 def create_cluster_subnet_group(self, ClusterSubnetGroupName: str, Description: str, SubnetIds: List, Tags: List = None) -> Dict:35 pass36 def create_event_subscription(self, SubscriptionName: str, SnsTopicArn: str, SourceType: str = None, SourceIds: List = None, EventCategories: List = None, Severity: str = None, Enabled: bool = None, Tags: List = None) -> Dict:...
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!!