vimtk.cplat module

class vimtk.cplat._PyQtWraper[source]

Bases: object

Lazy import of PyQt 4 or 5

CommandLine

python -m vimtk.cplat _PyQtWraper

Example

>>> # xdoctest: +REQUIRES(module:PyQt5)
>>> PyQt = import_pyqt()
>>> app1 = PyQt.ensure_app()
>>> app2 = PyQt.ensure_app()
>>> assert app1 is app2
ensure_app()[source]
vimtk.cplat.import_pyqt()[source]
vimtk.cplat.lorium_ipsum()[source]

Standard testing string

vimtk.cplat._ensure_clipboard_backend()[source]

CommandLine

pip install pyperclip
sudo apt-get install xclip
sudo apt-get install xsel
pip install PyQt5

# for windows
conda install pyqt

References

http://stackoverflow.com/questions/11063458/-text-to-clipboard http://stackoverflow.com/questions/579687using-python

Benchmark

import pyperclip import timerit ti = timerit.Timerit(verbose=2, unit=’ms’) # Qt is by far the fastest, followed by xsel, and then xclip backend_order = [‘xclip’, ‘xsel’, ‘qt’, ‘gtk’] backend_order = [‘qt’, ‘xsel’, ‘xclip’, ‘gtk’] for be in backend_order:

print(’—–‘) print(‘be = %r’ % (be,)) try:

pyperclip.set_clipboard(be) ti.reset(‘test-copy’).call(lambda: pyperclip.copy(‘a line of reasonable length text’)) ti.reset(‘test-paste’).call(lambda: pyperclip.paste())

except Exception:

print(‘Backend failed: {}’.format(be))

CommandLine

python -m vimtk.xctrl _ensure_clipboard_backend

Example

>>> from vimtk.xctrl import *  # NOQA
>>> import pytest
>>> import pyperclip
>>> result = _ensure_clipboard_backend()
>>> try:
>>>     prev = get_clipboard()
>>> except pyperclip.PyperclipException:
>>>     pytest.skip('no appropriate backend for pyperclip')
>>> text1 = 'foobar'
>>> text2 = 'bazbiz'
>>> copy_text_to_clipboard(text1)
>>> pasted1 = get_clipboard()
>>> copy_text_to_clipboard(text2)
>>> pasted2 = get_clipboard()
>>> assert pasted1 == text1
>>> assert pasted2 == text2
>>> copy_text_to_clipboard(prev)
vimtk.cplat.copy_text_to_clipboard(text)[source]

Copies text to the clipboard

vimtk.cplat.get_clipboard()[source]

References

http://stackoverflow.com/questions/11063458/python-script-to-copy-text-to-clipboard

vimtk.cplat._get_number_of_monitors()[source]
vimtk.cplat.get_resolution_info(monitor_num=0)[source]
Parameters:

monitor_num (int) – (default = 0)

Returns:

info

Return type:

dict

CommandLine

python -m vimtk.xctrl get_resolution_info

Example

>>> # xdoctest: +REQUIRES(module:PyQt5)
>>> monitor_num = 1
>>> for monitor_num in range(_get_number_of_monitors()):
>>>     info = get_resolution_info(monitor_num)
>>>     print('monitor(%d).info = %s' % (monitor_num, ub.repr2(info, precision=3)))