Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
['mode#@#filepath1#@#nodepath1#@#nodepath2, ...',
'mode#@#filepath2#@#nodepath1#@#nodepath2, ...', ...]
"""
# Get the list of open files (temporary database is not included)
for file_data in self.config.session_files_nodes:
item = file_data.split('#@#')
# item looks like [mode, filepath1, nodepath1, nodepath2, ...]
mode = item.pop(0)
filepath = item.pop(0)
filepath = vitables.utils.forwardPath(filepath)
# Open the database --> add the root group to the tree view.
if self.gui.dbs_tree_model.openDBDoc(filepath, mode):
self.gui.dbs_tree_view.setCurrentIndex(
self.gui.dbs_tree_model.index(0, 0, QtCore.QModelIndex()))
db_doc = self.gui.dbs_tree_model.getDBDoc(filepath)
if db_doc is None:
continue
# Update the history file
self.updateRecentFiles(filepath, mode)
# For opening a node the groups in the nodepath are expanded
# left to right letting the lazy population feature to work
for nodepath in item: # '/group1/group2/...groupN/leaf'
# Check if the node still exists because the database
# could have changed since last ViTables session
node = db_doc.get_node(nodepath)
if node is None:
continue
# groups is ['', 'group1', 'group2', ..., 'groupN']
groups = nodepath.split('/')[:-1]
show_cb = QtWidgets.QCheckBox()
show_cb.setChecked(True)
show_cb.stateChanged.connect(partial(self.show_cb_changed, show_cb))
show_cb.setStyleSheet("background-color: transparent")
self.overlay_tw.setCellWidget(current_rows, 0, show_cb)
self.show_cbs.append(show_cb)
color_button = FlatButton()
color_button.setStyleSheet("background-color: " + color)
color_button.clicked.connect(partial(self.color_btn_click, color_button))
self.overlay_tw.setCellWidget(current_rows, 1, color_button)
self.color_btns.append(color_button)
name_item = QtWidgets.QTableWidgetItem(name)
name_item.setFlags(name_item.flags() & ~QtCore.Qt.ItemIsEditable)
self.overlay_tw.setItem(current_rows, 2, QtWidgets.QTableWidgetItem(name))
scale_sb = DoubleSpinBoxAlignRight()
scale_sb.setMinimum(-9999999)
scale_sb.setMaximum(9999999)
scale_sb.setValue(1)
scale_sb.setSingleStep(self.scale_step_msb.value())
scale_sb.valueChanged.connect(partial(self.scale_sb_callback, scale_sb))
self.overlay_tw.setCellWidget(current_rows, 3, scale_sb)
self.scale_sbs.append(scale_sb)
offset_sb = DoubleSpinBoxAlignRight()
offset_sb.setMinimum(-9999999)
offset_sb.setMaximum(9999999)
offset_sb.setValue(0)
offset_sb.setSingleStep(self.offset_step_msb.value())
@QtCore.Slot(QtCore.QThread)
def moveToThread(self, thread):
super().moveToThread(thread)
from qtpy import QtCore
import vitables.utils
from vitables.vttables import buffer
from vitables.vttables import filenodebuffer
__docformat__ = 'restructuredtext'
#: The maximum number of rows to be read from the data source.
CHUNK_SIZE = 10000
log = logging.getLogger(__name__)
class LeafModel(QtCore.QAbstractTableModel):
"""
The model for real data contained in leaves.
The data is read from data sources (i.e., `HDF5/PyTables` nodes) by
the model.
The dataset number of rows is potentially huge but tables are read and
displayed in chunks.
:param parent:
The parent of the model, passed as is in the superclass.
:attribute leaf:
the underlying hdf5 data
:attribute rbuffer:
Code for chunking and inspecting the undelying data.
:attribute leaf_numrows:
def __init__(self, parent, title="Please wait", text="Saving..."):
super().__init__(parent)
self.setWindowTitle(title)
self.setWindowModality(QtCore.Qt.WindowModal)
self.setAttribute(QtCore.Qt.WA_ShowWithoutActivating)
# Dialog layout
self.text = QtWidgets.QLabel("<font size="16">" + text + "</font>")
self.hbox = QtWidgets.QHBoxLayout()
self.hbox.addSpacerItem(QtWidgets.QSpacerItem(50, 0))
self.hbox.addWidget(self.text)
self.hbox.addSpacerItem(QtWidgets.QSpacerItem(50, 0))
self.setLayout(self.hbox)
from __future__ import absolute_import, division, print_function
from qtpy import QtCore
__all__ = ['PyMimeData']
class PyMimeData(QtCore.QMimeData):
"""
A custom MimeData object that stores live python objects
Associate specific objects with a mime type by passing
mime type / object key/value pairs to the __init__ method
If a single object is passed to the init method, that
object is associated with the PyMimeData.MIME_TYPE mime type
"""
MIME_TYPE = 'application/py_instance'
def __init__(self, instance=None, **kwargs):
"""
:param instance: The python object to store
kwargs: Optional mime type / objects pairs to store as objects
# Make tuple of all colors
colors = (CN_COLORS, BASE_COLORS, CSS4_COLORS)
# Determine the cumulative lengths of all four sets
cum_len = np.cumsum(list(map(len, colors)))
# Make combobox for colors
color_box = QW_QEditableComboBox()
# Fill combobox with all colors
for i, color in enumerate(chain(*colors)):
# If color is a tuple, it consists of (color, tooltip)
if isinstance(color, tuple):
color_box.addItem(color[0])
color_box.setItemData(i, color[1], QC.Qt.ToolTipRole)
else:
color_box.addItem(color)
# Add some separators
for i in reversed(cum_len[:-1]):
color_box.insertSeparator(i)
# Set remaining properties
color_box.setToolTip("Select or type (in HEX) the color")
color_box.highlighted[str].connect(self.set_color_label)
color_box.popup_hidden[str].connect(self.set_color_label)
color_box.currentTextChanged.connect(self.set_color)
return(color_box)
@param QtCore.QThread thread: thread to register with unique objectName
"""
with self._lock:
name = thread.objectName()
if name in self._thread_names:
if self.get_thread_by_name(name) is thread:
return None
raise Exception('Different thread with name "{0}" already registered in '
'ThreadManager'.format(name))
row = len(self._threads)
self.beginInsertRows(QtCore.QModelIndex(), row, row)
self._threads.append(thread)
self._thread_names.append(name)
thread.finished.connect(
partial(self.unregister_thread, name=name), QtCore.Qt.QueuedConnection)
self.endInsertRows()
MAIN_THREAD = APP.thread()
try:
from asyncio import Future, ensure_future, CancelledError, \
set_event_loop, TimeoutError
except ImportError: # this occurs in python 2.7
logger.debug("asyncio not found, we will use concurrent.futures "
"instead of python 3.5 Futures.")
from concurrent.futures import Future, CancelledError, TimeoutError
else:
import quamash
set_event_loop(quamash.QEventLoop())
class MainThreadTimer(QtCore.QTimer):
"""
To be able to start a timer from any (eventually non Qt) thread,
we have to make sure that the timer is living in the main thread (in Qt,
each thread potentially has a distinct eventloop...).
For example, this is required to use the timer within timeit.
we might decide one day to allow 2 event loops to run concurrently in
separate threads, but
1. That should be QThreads and not python threads
2. We would have to make sure that all the gui operations are performed
in the main thread (for instance, by moving all widgets in the
mainthread, and probably, we would have to change some connections in
QueuedConnections)
==> but this is not a supported feature for the moment and I don't see
the advantage because the whole point of using an eventloop is to
def retranslateUi(self, DockWidget):
_translate = QtCore.QCoreApplication.translate
DockWidget.setWindowTitle(_translate("DockWidget", "Containers - Tabs"))
self.label_5.setText(_translate("DockWidget", "Enabled"))
self.label_6.setText(_translate("DockWidget", "Disabled"))
self.label_52.setText(_translate("DockWidget", "Inside TabWidget North Closable Tab 1"))
self.tabWidgetNorth.setTabText(self.tabWidgetNorth.indexOf(self.tab_7), _translate("DockWidget", "Tab 1"))
self.label_48.setText(_translate("DockWidget", "Inside TabWidget North Closable Tab 2"))
self.tabWidgetNorth.setTabText(self.tabWidgetNorth.indexOf(self.tab_8), _translate("DockWidget", "Tab 2"))
self.label_53.setText(_translate("DockWidget", "Inside TabWidget North Closable Tab 1"))
self.tabWidgetNorth_2.setTabText(self.tabWidgetNorth_2.indexOf(self.tab_9), _translate("DockWidget", "Tab 1"))
self.label_49.setText(_translate("DockWidget", "Inside TabWidget North Closable Tab 2"))
self.tabWidgetNorth_2.setTabText(self.tabWidgetNorth_2.indexOf(self.tab_10), _translate("DockWidget", "Tab 2"))
self.label_39.setText(_translate("DockWidget", "Inside TabWidget West Tab 1"))
self.tabWidgetWest.setTabText(self.tabWidgetWest.indexOf(self.tab_5), _translate("DockWidget", "Tab 1"))
self.label_54.setText(_translate("DockWidget", "Inside TabWidget West Tab 2"))
self.tabWidgetWest.setTabText(self.tabWidgetWest.indexOf(self.tab_6), _translate("DockWidget", "Tab 2"))
self.label_50.setText(_translate("DockWidget", "Inside TabWidget West Tab 1"))