tests.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:opcua-widgets 作者: FreeOpcUa 项目源码 文件源码
def modify_item(self, text, val, match_to_use=0):
        """
        modify the current item and set its displayed value to 'val'
        """
        idxlist = self.widget.model.match(self.widget.model.index(0, 0), Qt.DisplayRole, text, match_to_use + 1, Qt.MatchExactly | Qt.MatchRecursive)
        if not idxlist:
            raise RuntimeError("Item with text '{}' not found".format(text))
        idx = idxlist[match_to_use]
        self.widget.view.setCurrentIndex(idx)
        idx = idx.sibling(idx.row(), 1)
        self.widget.view.edit(idx)
        editor = self.widget.view.focusWidget()
        if not editor:
            print(app.focusWidget())
            print("NO EDITOR WIDGET")
            #QTest.keyClick(self.widget.view, Qt.Key_Return)
            from IPython import embed 
            embed()
            raise RuntimeError("Could not get editor widget!, it does not have the focus")

        if hasattr(editor, "_current_node"):
            editor._current_node = val
        elif hasattr(editor, "setCurrentText"):
            editor.setCurrentText(val)
        else:
            editor.setText(val)
        self.widget.view.commitData(editor)
        self.widget.view.closeEditor(editor, QAbstractItemDelegate.NoHint)
        self.widget.view.reset()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号