當前位置: 首頁>>代碼示例>>Python>>正文


Python PyMimeData.coerce方法代碼示例

本文整理匯總了Python中traitsui.qt4.clipboard.PyMimeData.coerce方法的典型用法代碼示例。如果您正苦於以下問題:Python PyMimeData.coerce方法的具體用法?Python PyMimeData.coerce怎麽用?Python PyMimeData.coerce使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在traitsui.qt4.clipboard.PyMimeData的用法示例。


在下文中一共展示了PyMimeData.coerce方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_coerce_list_pymimedata_mixed

# 需要導入模塊: from traitsui.qt4.clipboard import PyMimeData [as 別名]
# 或者: from traitsui.qt4.clipboard.PyMimeData import coerce [as 別名]
 def test_coerce_list_pymimedata_mixed(self):
     md1 = PyMimeData(data=0, pickle=False)
     md2 = PyMimeData(data=0)
     md = PyMimeData.coerce([md1, md2])
     self.assertEqual(md._local_instance, [0, 0])
     self.assertFalse(md.hasFormat(PyMimeData.MIME_TYPE))
     self.assertTrue(md.hasFormat(PyMimeData.NOPICKLE_MIME_TYPE))
開發者ID:jthacker,項目名稱:traitsui,代碼行數:9,代碼來源:test_clipboard.py

示例2: test_coerce_list_pymimedata

# 需要導入模塊: from traitsui.qt4.clipboard import PyMimeData [as 別名]
# 或者: from traitsui.qt4.clipboard.PyMimeData import coerce [as 別名]
 def test_coerce_list_pymimedata(self):
     md = PyMimeData(data=0)
     md2 = PyMimeData.coerce([md])
     self.assertEqual(md2._local_instance, [0])
     self.assertTrue(md2.hasFormat(PyMimeData.MIME_TYPE))
     self.assertFalse(md2.hasFormat(PyMimeData.NOPICKLE_MIME_TYPE))
     self.assertEqual(bytes(md2.data(PyMimeData.MIME_TYPE)), dumps(list)+dumps([0]))
開發者ID:FelixHartmann,項目名稱:traitsui,代碼行數:9,代碼來源:test_clipboard.py

示例3: test_coerce_object

# 需要導入模塊: from traitsui.qt4.clipboard import PyMimeData [as 別名]
# 或者: from traitsui.qt4.clipboard.PyMimeData import coerce [as 別名]
 def test_coerce_object(self):
     md = PyMimeData.coerce(0)
     self.assertEqual(md._local_instance, 0)
     self.assertTrue(md.hasFormat(PyMimeData.MIME_TYPE))
     self.assertFalse(md.hasFormat(PyMimeData.NOPICKLE_MIME_TYPE))
     self.assertEqual(
         md.data(
             PyMimeData.MIME_TYPE).data(),
         dumps(int) +
         dumps(0))
開發者ID:jthacker,項目名稱:traitsui,代碼行數:12,代碼來源:test_clipboard.py

示例4: test_coerce_list

# 需要導入模塊: from traitsui.qt4.clipboard import PyMimeData [as 別名]
# 或者: from traitsui.qt4.clipboard.PyMimeData import coerce [as 別名]
 def test_coerce_list(self):
     md = PyMimeData.coerce([0])
     self.assertEqual(md._local_instance, [0])
     self.assertTrue(md.hasFormat(PyMimeData.MIME_TYPE))
     self.assertFalse(md.hasFormat(PyMimeData.NOPICKLE_MIME_TYPE))
     self.assertEqual(
         md.data(
             PyMimeData.MIME_TYPE).data(),
         dumps(list) +
         dumps(
             [0]))
開發者ID:jthacker,項目名稱:traitsui,代碼行數:13,代碼來源:test_clipboard.py

示例5: _create_drag_event

# 需要導入模塊: from traitsui.qt4.clipboard import PyMimeData [as 別名]
# 或者: from traitsui.qt4.clipboard.PyMimeData import coerce [as 別名]
    def _create_drag_event(self, event):
        
        # If the control no longer exists, don't send mouse event
        if self.control is None:
            return None
        # If the event (if there is one) doesn't contain the mouse position,
        # modifiers and buttons then get sensible defaults.
        try:
            x = event.x()
            y = event.y()
        except AttributeError:
            pos = self.control.mapFromGlobal(QtGui.QCursor.pos())
            x = pos.x()
            y = pos.y()

        self.control.handler.last_mouse_pos = (x, y)
        
        # extract an object from the event, if we can
        try:
            mimedata = event.mimeData()
            copy = event.proposedAction() == QtCore.Qt.CopyAction
        except AttributeError:
            # this is a DragLeave event
            return DragEvent(x=x, y=self._flip_y(y), obj=None, copy=False,
                        window=self, mimedata=None)
            
        try:
            from traitsui.qt4.clipboard import PyMimeData
        except ImportError:
            # traitsui isn't available, just make mimedata available on event
            obj = None
        else:
            mimedata = PyMimeData.coerce(mimedata)
            obj = mimedata.instance()
            if obj is None:
                files = mimedata.localPaths()
                if files:
                    try:
                        # try to extract file info from mimedata
                        # XXX this is for compatibility with what wx does
                        from apptools.io.api import File
                        obj = [File(path=path) for path in files]
                    except ImportError:
                        pass
        
        return DragEvent(x=x, y=self._flip_y(y), obj=obj, copy=copy,
                        window=self, mimedata=mimedata)
開發者ID:burnpanck,項目名稱:enable,代碼行數:49,代碼來源:base_window.py

示例6: test_coerce_unpicklable

# 需要導入模塊: from traitsui.qt4.clipboard import PyMimeData [as 別名]
# 或者: from traitsui.qt4.clipboard.PyMimeData import coerce [as 別名]
 def test_coerce_unpicklable(self):
     unpicklable = lambda: None
     md = PyMimeData.coerce(unpicklable)
     self.assertEqual(md._local_instance, unpicklable)
     self.assertFalse(md.hasFormat(PyMimeData.MIME_TYPE))
     self.assertTrue(md.hasFormat(PyMimeData.NOPICKLE_MIME_TYPE))
開發者ID:jthacker,項目名稱:traitsui,代碼行數:8,代碼來源:test_clipboard.py

示例7: test_coerce_QMimeData

# 需要導入模塊: from traitsui.qt4.clipboard import PyMimeData [as 別名]
# 或者: from traitsui.qt4.clipboard.PyMimeData import coerce [as 別名]
 def test_coerce_QMimeData(self):
     md = QtCore.QMimeData()
     md.setText("test")
     md2 = PyMimeData.coerce(md)
     self.assertTrue(md2.hasText())
     self.assertEqual(md2.text(), "test")
開發者ID:jthacker,項目名稱:traitsui,代碼行數:8,代碼來源:test_clipboard.py

示例8: test_coerce_subclass

# 需要導入模塊: from traitsui.qt4.clipboard import PyMimeData [as 別名]
# 或者: from traitsui.qt4.clipboard.PyMimeData import coerce [as 別名]
 def test_coerce_subclass(self):
     md = PMDSubclass(data=0)
     md2 = PyMimeData.coerce(md)
     self.assertEqual(md, md2)
開發者ID:jthacker,項目名稱:traitsui,代碼行數:6,代碼來源:test_clipboard.py

示例9: test_coerce_pymimedata

# 需要導入模塊: from traitsui.qt4.clipboard import PyMimeData [as 別名]
# 或者: from traitsui.qt4.clipboard.PyMimeData import coerce [as 別名]
 def test_coerce_pymimedata(self):
     md = PyMimeData(data=0)
     md2 = PyMimeData.coerce(md)
     self.assertEqual(md, md2)
開發者ID:jthacker,項目名稱:traitsui,代碼行數:6,代碼來源:test_clipboard.py


注:本文中的traitsui.qt4.clipboard.PyMimeData.coerce方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。