コード例 #1
0
ファイル: contextWin.py プロジェクト: slawekwaga/BEE2.4
def adjust_position(e=None):
    """Move the properties window onto the selected item.

    We call this constantly, so the property window will not go outside
    the screen, and snap back to the item when the main window returns.
    """
    if not is_open or selected_sub_item is None:
        return

    # Calculate the pixel offset between the window and the subitem in
    # the properties dialog, and shift if needed to keep it inside the
    # window
    icon_widget = wid['subitem', pos_for_item()]

    loc_x, loc_y = utils.adjust_inside_screen(
        x=(
            selected_sub_item.winfo_rootx()
            + prop_window.winfo_rootx()
            - icon_widget.winfo_rootx()
        ),
        y=(
            selected_sub_item.winfo_rooty()
            + prop_window.winfo_rooty()
            - icon_widget.winfo_rooty()
        ),
        win=prop_window,
    )

    prop_window.geometry('+{x!s}+{y!s}'.format(x=loc_x, y=loc_y))
コード例 #2
0
ファイル: contextWin.py プロジェクト: GLiTcH2/BEE2.4
def adjust_position(_=None):
    """Move the properties window onto the selected item.

    We call this constantly, so the property window will not go outside
    the screen, and snap back to the item when the main window returns.
    """
    if not is_open or selected_sub_item is None:
        return

    # Calculate the pixel offset between the window and the subitem in
    # the properties dialog, and shift if needed to keep it inside the
    # window
    icon_widget = wid['subitem', pos_for_item()]

    loc_x, loc_y = utils.adjust_inside_screen(
        x=(
            selected_sub_item.winfo_rootx()
            + prop_window.winfo_rootx()
            - icon_widget.winfo_rootx()
        ),
        y=(
            selected_sub_item.winfo_rooty()
            + prop_window.winfo_rooty()
            - icon_widget.winfo_rooty()
        ),
        win=prop_window,
    )

    prop_window.geometry('+{x!s}+{y!s}'.format(x=loc_x, y=loc_y))
コード例 #3
0
    def move(self, x: int=None, y: int=None, width: int=None, height: int=None) -> None:
        """Move the window to the specified position.

        Effectively an easier-to-use form of Toplevel.geometry(), that
        also updates relX and relY.
        """
        # If we're resizable, keep the current size. Otherwise autosize to
        # contents.
        if width is None:
            width = self.winfo_width() if self.can_resize_x else self.winfo_reqwidth()
        if height is None:
            height = self.winfo_height() if self.can_resize_y else self.winfo_reqheight()
        if x is None:
            x = self.winfo_x()
        if y is None:
            y = self.winfo_y()

        x, y = utils.adjust_inside_screen(x, y, win=self)
        self.geometry('{!s}x{!s}+{!s}+{!s}'.format(
            max(10, width),
            max(10, height),
            x,
            y,
        ))

        self.relX = x - self.parent.winfo_x()
        self.relY = y - self.parent.winfo_y()
        self.save_conf()
コード例 #4
0
    def move(self, x=None, y=None, width=None, height=None):
        """Move the window to the specified position.

        Effectively an easier-to-use form of Toplevel.geometry(), that
        also updates relX and relY.
        """
        if width is None:
            width = self.winfo_reqwidth()
        if height is None:
            height = self.winfo_reqheight()
        if x is None:
            x = self.winfo_x()
        if y is None:
            y = self.winfo_y()

        x, y = utils.adjust_inside_screen(x, y, win=self)
        self.geometry('{!s}x{!s}+{!s}+{!s}'.format(
            str(width),
            str(height),
            str(x),
            str(y),
        ))

        self.relX = x - self.parent.winfo_x()
        self.relY = y - self.parent.winfo_y()
        self.save_conf()
コード例 #5
0
ファイル: SubPane.py プロジェクト: Coolasp1e/BEE2.4
    def move(self, x=None, y=None, width=None, height=None):
        """Move the window to the specified position.

        Effectively an easier-to-use form of Toplevel.geometry(), that
        also updates relX and relY.
        """
        if width is None:
            width = self.winfo_reqwidth()
        if height is None:
            height = self.winfo_reqheight()
        if x is None:
            x = self.winfo_x()
        if y is None:
            y = self.winfo_y()

        x, y = utils.adjust_inside_screen(x, y, win=self)
        self.geometry('{!s}x{!s}+{!s}+{!s}'.format(
            str(width),
            str(height),
            str(x),
            str(y),
        ))

        self.relX = x - self.parent.winfo_x()
        self.relY = y - self.parent.winfo_y()
        self.save_conf()
コード例 #6
0
 def follow_main(self, e=None) -> None:
     """When the main window moves, sub-windows should move with it."""
     self.allow_snap = False
     x, y = utils.adjust_inside_screen(
         x=self.parent.winfo_x()+self.relX,
         y=self.parent.winfo_y()+self.relY,
         win=self,
         )
     self.geometry('+'+str(x)+'+'+str(y))
     self.parent.focus()
コード例 #7
0
ファイル: SubPane.py プロジェクト: Coolasp1e/BEE2.4
 def follow_main(self, _=None):
     """When the main window moves, sub-windows should move with it."""
     self.allow_snap = False
     x, y = utils.adjust_inside_screen(
         x=self.parent.winfo_x()+self.relX,
         y=self.parent.winfo_y()+self.relY,
         win=self,
         )
     self.geometry('+'+str(x)+'+'+str(y))
     self.parent.focus()
コード例 #8
0
ファイル: contextWin.py プロジェクト: SpyyZ158/BEE2.4
def show_prop(widget, warp_cursor=False):
    """Show the properties window for an item.

    wid should be the UI.PalItem widget that represents the item.
    If warp_cursor is  true, the cursor will be moved relative to this window so
    it stays on top of the selected subitem.
    """
    global selected_item, selected_sub_item, is_open
    if warp_cursor and is_open:
        cursor_x, cursor_y = prop_window.winfo_pointerxy()
        off_x = cursor_x-prop_window.winfo_rootx()
        off_y = cursor_y-prop_window.winfo_rooty()
    else:
        off_x, off_y = None, None
    prop_window.deiconify()
    prop_window.lift(TK_ROOT)
    selected_item = widget.item
    selected_sub_item = widget
    is_open = True

    icon_widget = wid['subitem'][pos_for_item()]

    # Calculate the pixel offset between the window and the subitem in
    # the properties dialog, and shift if needed to keep it inside the
    # window
    loc_x, loc_y = utils.adjust_inside_screen(
        x=(
            widget.winfo_rootx()
            + prop_window.winfo_rootx()
            - icon_widget.winfo_rootx()
        ),
        y=(
            widget.winfo_rooty()
            + prop_window.winfo_rooty()
            - icon_widget.winfo_rooty()
        ),
        win=prop_window,
    )

    prop_window.geometry('+{x!s}+{y!s}'.format(x=loc_x, y=loc_y))
    prop_window.relX = loc_x-TK_ROOT.winfo_x()
    prop_window.relY = loc_y-TK_ROOT.winfo_y()

    if off_x is not None and off_y is not None:
        # move the mouse cursor
        prop_window.event_generate('<Motion>', warp=True, x=off_x, y=off_y)

    load_item_data()
コード例 #9
0
ファイル: contextWin.py プロジェクト: Stendec-UA/BEE2.4
def show_prop(widget, warp_cursor=False):
    """Show the properties window for an item.

    wid should be the UI.PalItem widget that represents the item.
    If warp_cursor is  true, the cursor will be moved relative to this window so
    it stays on top of the selected subitem.
    """
    global selected_item, selected_sub_item, is_open
    if warp_cursor and is_open:
        cursor_x, cursor_y = prop_window.winfo_pointerxy()
        off_x = cursor_x - prop_window.winfo_rootx()
        off_y = cursor_y - prop_window.winfo_rooty()
    else:
        off_x, off_y = None, None
    prop_window.deiconify()
    prop_window.lift(TK_ROOT)
    selected_item = widget.item
    selected_sub_item = widget
    is_open = True

    icon_widget = wid['subitem'][pos_for_item()]

    # Calculate the pixel offset between the window and the subitem in
    # the properties dialog, and shift if needed to keep it inside the
    # window
    loc_x, loc_y = utils.adjust_inside_screen(
        x=(widget.winfo_rootx() + prop_window.winfo_rootx() -
           icon_widget.winfo_rootx()),
        y=(widget.winfo_rooty() + prop_window.winfo_rooty() -
           icon_widget.winfo_rooty()),
        win=prop_window,
    )

    prop_window.geometry('+{x!s}+{y!s}'.format(x=loc_x, y=loc_y))
    prop_window.relX = loc_x - TK_ROOT.winfo_x()
    prop_window.relY = loc_y - TK_ROOT.winfo_y()

    if off_x is not None and off_y is not None:
        # move the mouse cursor
        prop_window.event_generate('<Motion>', warp=True, x=off_x, y=off_y)

    load_item_data()