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


Python clipboard.PyMimeData類代碼示例

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


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

示例1: test_pickle

 def test_pickle(self):
     md = PyMimeData(data=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,代碼行數:7,代碼來源:test_clipboard.py

示例2: test_cant_pickle

 def test_cant_pickle(self):
     unpicklable = lambda: None
     md = PyMimeData(data=unpicklable)
     self.assertEqual(md._local_instance, unpicklable)
     self.assertTrue(md.hasFormat(PyMimeData.NOPICKLE_MIME_TYPE))
     self.assertFalse(md.hasFormat(PyMimeData.MIME_TYPE))
     self.assertEqual(bytes(md.data(PyMimeData.NOPICKLE_MIME_TYPE)), str(id(unpicklable)))
開發者ID:FelixHartmann,項目名稱:traitsui,代碼行數:7,代碼來源:test_clipboard.py

示例3: test_nopickle

 def test_nopickle(self):
     md = PyMimeData(data=0, pickle=False)
     self.assertEqual(md._local_instance, 0)
     self.assertTrue(md.hasFormat(PyMimeData.NOPICKLE_MIME_TYPE))
     self.assertFalse(md.hasFormat(PyMimeData.MIME_TYPE))
     self.assertEqual(
         md.data(PyMimeData.NOPICKLE_MIME_TYPE).data(),
         str2bytes(str(id(0)))
     )
開發者ID:jthacker,項目名稱:traitsui,代碼行數:9,代碼來源:test_clipboard.py

示例4: test_coerce_list_pymimedata_mixed

 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,代碼行數:7,代碼來源:test_clipboard.py

示例5: test_coerce_list_pymimedata

 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,代碼行數:7,代碼來源:test_clipboard.py

示例6: test_coerce_list

 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,代碼行數:11,代碼來源:test_clipboard.py

示例7: _create_drag_event

    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,代碼行數:47,代碼來源:base_window.py

示例8: test_coerce_unpicklable

 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,代碼行數:6,代碼來源:test_clipboard.py

示例9: test_coerce_QMimeData

 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,代碼行數:6,代碼來源:test_clipboard.py

示例10: test_coerce_subclass

 def test_coerce_subclass(self):
     md = PMDSubclass(data=0)
     md2 = PyMimeData.coerce(md)
     self.assertEqual(md, md2)
開發者ID:jthacker,項目名稱:traitsui,代碼行數:4,代碼來源:test_clipboard.py

示例11: test_coerce_pymimedata

 def test_coerce_pymimedata(self):
     md = PyMimeData(data=0)
     md2 = PyMimeData.coerce(md)
     self.assertEqual(md, md2)
開發者ID:jthacker,項目名稱:traitsui,代碼行數:4,代碼來源:test_clipboard.py

示例12: test_instance_type_nopickle

 def test_instance_type_nopickle(self):
     md = PyMimeData(data=0, pickle=False)
     # remove local instance to simulate cross-process
     md._local_instance = None
     self.assertEqual(md.instanceType(), None)
開發者ID:jthacker,項目名稱:traitsui,代碼行數:5,代碼來源:test_clipboard.py

示例13: test_instance_type_unpickled

 def test_instance_type_unpickled(self):
     md = PyMimeData(data=0)
     # remove local instance to simulate cross-process
     md._local_instance = None
     self.assertEqual(md.instanceType(), int)
開發者ID:jthacker,項目名稱:traitsui,代碼行數:5,代碼來源:test_clipboard.py

示例14: test_instance_type

 def test_instance_type(self):
     md = PyMimeData(data=0)
     self.assertEqual(md.instanceType(), int)
開發者ID:jthacker,項目名稱:traitsui,代碼行數:3,代碼來源:test_clipboard.py

示例15: test_instance

 def test_instance(self):
     md = PyMimeData(data=0)
     self.assertEqual(md.instance(), 0)
開發者ID:jthacker,項目名稱:traitsui,代碼行數:3,代碼來源:test_clipboard.py


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