• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python clipboard.PyMimeData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中traitsui.qt4.clipboard.PyMimeData的典型用法代码示例。如果您正苦于以下问题:Python PyMimeData类的具体用法?Python PyMimeData怎么用?Python PyMimeData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了PyMimeData类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: test_coerce_object

 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(bytes(md.data(PyMimeData.MIME_TYPE)), dumps(int)+dumps(0))
开发者ID:FelixHartmann,项目名称:traitsui,代码行数:6,代码来源:test_clipboard.py



注:本文中的traitsui.qt4.clipboard.PyMimeData类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python _tools.store_exceptions_on_all_threads函数代码示例发布时间:2022-05-27
下一篇:
Python api.raise_to_debug函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap