Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.img_ver_px_txt.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.img_ver_px_txt.setMaximumWidth(60)
self.img_hor_px_size_txt.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.img_hor_px_size_txt.setMaximumWidth(60)
self.img_ver_px_size_txt.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.img_ver_px_size_txt.setMaximumWidth(60)
self.img_hor_center_txt.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.img_hor_center_txt.setMaximumWidth(60)
self.img_ver_center_txt.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.img_ver_center_txt.setMaximumWidth(60)
self.img_hor_px_size_txt.setValidator(QtGui.QDoubleValidator())
self.img_ver_px_size_txt.setValidator(QtGui.QDoubleValidator())
self.img_hor_center_txt.setValidator(QtGui.QDoubleValidator())
self.img_ver_center_txt.setValidator(QtGui.QDoubleValidator())
self.img_hor_px_txt.setValidator(QtGui.QIntValidator())
self.img_ver_px_txt.setValidator(QtGui.QIntValidator())
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.ok_btn.setToolTip('# of files must equal # of points')
file = open(os.path.join(style_path, "stylesheet.qss"))
stylesheet = file.read()
self.setStyleSheet(stylesheet)
file.close()
def copy_to_clipboard(data):
"""
Uses the QGuiApplication to copy to the system clipboard.
:type data: str
:param data: The data that will be copied to the clipboard
:return:
"""
cb = QtGui.QGuiApplication.clipboard()
cb.setText(data, mode=cb.Clipboard)
fmap = {}
fmt = QtGui.QTextCharFormat()
fmt.setForeground(QtGui.QColor('red'))
fmap['error'] = fmt
fmt = QtGui.QTextCharFormat()
fmt.setForeground(QtGui.QColor('orange'))
fmap['warning'] = fmt
fmt = QtGui.QTextCharFormat()
fmt.setForeground(QtGui.QColor('blue'))
fmap['info'] = fmt
fmt = QtGui.QTextCharFormat()
fmt.setForeground(QtGui.QColor('gray'))
fmap['debug'] = fmt
fmt = QtGui.QTextCharFormat()
fmt.setFontWeight(QtGui.QFont.Bold)
fmap['cmd'] = fmt
return fmap
except ImportError:
ts = None
try:
import pandas as pd
except ImportError:
pd = None
from qtpy import QtCore, QtGui
from qtpy.QtCore import Qt
from qtpy import QtWidgets
import vitables.utils
from vitables.plugins.timeseries.aboutpage import AboutPage
_axis_font = QtGui.QFont()
_axis_font.setBold(True)
__docformat__ = 'restructuredtext'
__version__ = '2.1'
plugin_name = 'Time series formatter'
comment = 'Display time series in a human friendly format'
translate = QtWidgets.QApplication.translate
def findTS(leaf, node_kind):
"""Find out if the inspected leaf contains a time field.
**Existing time fields that cannot be formatted are skipped**:
- time series created via ``pandas`` module are ignored if that
def _DrawBackground( self, painter ):
new_options = HG.client_controller.new_options
painter.setBackground( QG.QBrush( new_options.GetColour( CC.COLOUR_MEDIA_BACKGROUND ) ) )
painter.eraseRect( painter.viewport() )
self._first_background_drawn = True
#'r - reset camera view',
#'X/x - snap to x axis',
#'Y/y - snap to y axis',
#'Z/z - snap to z axis',
#'',
#'h - show/hide legend & info',
'CTRL+I - take a screenshot (image)',
'CTRL+L - cycle results',
#'m/M - scale up/scale down by 1.1 times',
#'o/O - rotate counter-clockwise/clockwise 5 degrees',
's - view model as a surface',
'w - view model as a wireframe',
'',
'Reload Model: using the same filename reload the model',
]
QtGui.QMessageBox.about(self, "About pyCart3d GUI", "\n".join(about))
def jump_to_end(self):
"""
desc:
Restore the cursor to the end of the textedit.
"""
c = self.textCursor()
if not c.atEnd() and c.blockNumber()+1 < self.document().blockCount():
c.movePosition(QtGui.QTextCursor.End)
self.setTextCursor(c)
formats = ['*.{}'.format(fmt.data().decode())
for fmt in QtGui.QImageReader.supportedImageFormats()]
self.errorMessage(
self.tr('Error opening file'),
self.tr(
'<p>Make sure <i>{0}</i> is a valid image file.<br>'
'Supported image formats: {1}</p>'
).format(filename, ','.join(formats))
)
self.status(self.tr("Error reading %s") % filename)
return False
self.image = image
self.filename = filename
if self._config['keep_prev']:
prev_shapes = self.canvas.shapes
self.canvas.loadPixmap(QtGui.QPixmap.fromImage(image))
if self._config['flags']:
self.loadFlags({k: False for k in self._config['flags']})
if self.labelFile:
self.loadLabels(self.labelFile.shapes)
if self.labelFile.flags is not None:
self.loadFlags(self.labelFile.flags)
if self._config['keep_prev'] and not self.labelList.shapes:
self.loadShapes(prev_shapes, replace=False)
self.setClean()
self.canvas.setEnabled(True)
self.adjustScale(initial=True)
self.paintCanvas()
self.addRecentFile(self.filename)
self.toggleActions(True)
self.status(self.tr("Loaded %s") % osp.basename(str(filename)))
return True
def status_pixmap(attention=False):
"""A small icon to grab attention
Args:
attention (bool): pixmap is red if True, gray if otherwise
Returns:
QtGui.QPixmap: attention icon to display
"""
color = QtCore.Qt.red if attention else QtCore.Qt.lightGray
pm = QtGui.QPixmap(15, 15)
p = QtGui.QPainter(pm)
b = QtGui.QBrush(color)
p.fillRect(-1, -1, 20, 20, b)
return pm
def __init__(self, *args, **kwargs):
super(NumberTextField, self).__init__(*args, **kwargs)
self.setValidator(QtGui.QDoubleValidator())
self.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)