本文整理汇总了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;未经允许,请勿转载。 |
请发表评论