|
1 | 1 | # Built-in |
2 | 2 | import logging |
3 | | -import ast |
| 3 | +from functools import partial |
4 | 4 | try: |
5 | 5 | from collections.abc import Iterable |
6 | 6 | except ImportError: |
@@ -814,12 +814,12 @@ def __init__(self, node_path, parent=None): |
814 | 814 | action = QtWidgets.QAction(text, self) |
815 | 815 | if menu_data.get(self.SELECTOR_ITEM_ATTR) == 'True': |
816 | 816 | title = menu_data.get(self.SELECTOR_TITLE_ATTR) |
817 | | - action.triggered.connect(lambda p=menu_item_path, t=title: |
818 | | - self.selection_widget(p, t)) |
| 817 | + action.triggered.connect(partial(self.selection_widget, |
| 818 | + node_path, title)) |
819 | 819 | else: |
820 | | - action.triggered.connect(lambda p=menu_item_path, |
821 | | - a=self.ITEM_PATH_ATTR: |
822 | | - self.execute_node_path(p, a)) |
| 820 | + action.triggered.connect(partial(self.execute_node_path, |
| 821 | + menu_item_path, |
| 822 | + self.ITEM_PATH_ATTR)) |
823 | 823 | items.append(action) |
824 | 824 |
|
825 | 825 | ContextMenu(stage_model=self.stage_model, |
@@ -870,9 +870,9 @@ def selection_widget(self, node_path, title): |
870 | 870 | else: |
871 | 871 | items = [] |
872 | 872 | # selector dialog |
873 | | - screen = QtWidgets.QApplication.desktop().screenNumber( |
874 | | - QtWidgets.QApplication.desktop().cursor().pos()) |
875 | | - center = QtWidgets.QApplication.desktop().screenGeometry(screen).center() |
| 873 | + cursor_pos = QtGui.QCursor.pos() |
| 874 | + screen = QtWidgets.QApplication.screenAt(cursor_pos) |
| 875 | + center = screen.geometry().center() if screen else QtCore.QPoint(0, 0) |
876 | 876 | dialog = SelectionDialog(title=title, items=items, pos=center, parent=self) |
877 | 877 | dialog.exec_() |
878 | 878 | if not dialog.result(): |
|
0 commit comments