예제 #1
0
 def _location_analysis(self, bounds):
     self.clear_indicators()
     self._edge_indicator.update_idletasks()
     bounds = geometry.relative_bounds(bounds, self.container)
     x, y = bounds[0], bounds[1]
     col, row = self.container.grid_location(x, y)
     x, y = geometry.upscale_bounds(bounds, self.container)[:2]
     slaves = self.container.grid_slaves(max(0, row), max(0, col))
     if len(slaves) == 0:
         self.container.update_idletasks()
         bbox = self.container.grid_bbox(col, row)
         bounds = *bbox[:2], bbox[0] + bbox[2], bbox[1] + bbox[3]
         # Make bounds relative to designer
         bounds = geometry.upscale_bounds(bounds, self.container)
     else:
         bounds = geometry.bounds(slaves[0])
     y_offset, x_offset = 10, 10  # 0.15*(bounds[3] - bounds[1]), 0.15*(bounds[2] - bounds[0])
     # If the position is empty no need to alter the row or column
     resize = 1 if len(slaves) else 0
     if y - bounds[1] < y_offset:
         self._edge_indicator.top(bounds)
         return row, col, resize, 0
     elif bounds[3] - y < y_offset:
         self._edge_indicator.bottom(bounds)
         return row + resize, col, resize, 0
     elif x - bounds[0] < x_offset:
         self._edge_indicator.left(bounds)
         return row, col, 0, resize
     elif bounds[2] - x < x_offset:
         self._edge_indicator.right(bounds)
         return row, col + resize, 0, resize
     else:
         self._highlighter.highlight_bounds(bounds)
         return row, col, 0, 0
예제 #2
0
 def bbox(self, child):
     # return the canvas bbox if possible else use the normal bound
     # canvas bbox is more accurate
     if self._child_map.get(child) is not None:
         return self._frame.bbox(self._child_map[child])
     return geometry.relative_bounds(geometry.bounds(child), self._frame)
예제 #3
0
 def react_to(self, bounds):
     bounds = geometry.relative_bounds(bounds, self.container)
     col, row = self.container.grid_location(bounds[0], bounds[1])
     widget = self.container.grid_slaves(row, col)
     if len(widget):
         self._highlighter.highlight(widget[0])
예제 #4
0
 def _move(self, widget, bounds):
     # Make the bounds relative to the layout for proper positioning
     bounds = geometry.relative_bounds(bounds, self.container)
     self.container.position(widget, bounds)