diff --git a/environment.yml b/environment.yml new file mode 100644 index 00000000..6b437b49 --- /dev/null +++ b/environment.yml @@ -0,0 +1,5 @@ +name: vitables-dev +dependencies: + - python=3.11 + - h5py + - ipython diff --git a/setup.py b/setup.py index 978e14b1..0ea920a3 100644 --- a/setup.py +++ b/setup.py @@ -29,10 +29,8 @@ def read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read() -install_requires = ['qtpy (>=1.2.1)', 'numpy (>=1.4.1)', 'numexpr (>=2.0)', +install_requires = ['qtpy', 'pyqt6', 'numpy (>=1.4.1)', 'numexpr (>=2.0)', 'tables (>=3.0)', 'setuptools'] -if 'CONDA_PREFIX' not in os.environ: - install_requires.append('PyQt5 (>=5.5.1)') setup(name='ViTables', version=read('VERSION').rstrip('\r\n'), diff --git a/tests/test_vtconfig.py b/tests/test_vtconfig.py index 794da285..feae5651 100644 --- a/tests/test_vtconfig.py +++ b/tests/test_vtconfig.py @@ -20,7 +20,7 @@ def config(self, launcher): # Tear down code cfg.writeValue('Logger/Paper', QtGui.QColor("#ffffff")) cfg.writeValue('Logger/Text', QtGui.QColor("#000000")) - cfg.writeValue('Logger/Font', QtWidgets.qApp.font()) + cfg.writeValue('Logger/Font', QtWidgets.QApplication.font()) cfg.writeValue('Workspace/Background', QtGui.QBrush(QtGui.QColor("#ffffff"))) cfg.writeValue('Look/currentStyle', cfg.default_style) diff --git a/vitables/csv/export_csv.py b/vitables/csv/export_csv.py index 41718103..f14be4be 100644 --- a/vitables/csv/export_csv.py +++ b/vitables/csv/export_csv.py @@ -264,7 +264,7 @@ def export(self): filepath, add_header = export_info try: - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) with open(filepath, 'ab') as out_handler: if add_header: from functools import reduce @@ -280,7 +280,7 @@ def export(self): # we must explicitly ensure we get an integer nchunks = numpy.floor_divide(nrows, chunk_size) for i in numpy.arange(0, nchunks + 1): - QtWidgets.qApp.processEvents() + QtWidgets.QApplication.processEvents() cstart = chunk_size * i if cstart >= nrows: break @@ -292,4 +292,4 @@ def export(self): except OSError: vitables.utils.formatExceptionInfo() finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() diff --git a/vitables/csv/import_csv.py b/vitables/csv/import_csv.py index a0eaf4d7..c1fc9d1f 100644 --- a/vitables/csv/import_csv.py +++ b/vitables/csv/import_csv.py @@ -266,8 +266,8 @@ def csv2Table(self): # Import the CSV content try: - QtWidgets.qApp.processEvents() - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.processEvents() + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) input_handler = open(filepath, 'r+') try: (nrows, descr, has_header) = csvutils.tableInfo(input_handler) @@ -306,7 +306,7 @@ def csv2Table(self): except: vitables.utils.formatExceptionInfo() finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() input_handler.close() def csv2EArray(self): @@ -322,8 +322,8 @@ def csv2EArray(self): # Import the CSV content try: - QtWidgets.qApp.processEvents() - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.processEvents() + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) chunk_size = 10000 input_handler = open(filepath, 'r+') (nrows, atom, array_shape) = csvutils.earrayInfo(input_handler) @@ -359,7 +359,7 @@ def csv2EArray(self): except: vitables.utils.formatExceptionInfo() finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() input_handler.close() def csv2CArray(self): @@ -375,8 +375,8 @@ def csv2CArray(self): # Import the CSV content try: - QtWidgets.qApp.processEvents() - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.processEvents() + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) chunk_size = 10000 input_handler = open(filepath, 'r+') (atom, array_shape) = csvutils.carrayInfo(input_handler) @@ -415,7 +415,7 @@ def csv2CArray(self): except: vitables.utils.formatExceptionInfo() finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() input_handler.close() def csv2Array(self): @@ -431,8 +431,8 @@ def csv2Array(self): # Import the CSV content try: - QtWidgets.qApp.processEvents() - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.processEvents() + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) # The dtypes are determined by the contents of each column # Multidimensional columns will have string datatype data = numpy.genfromtxt(filepath, delimiter=',', dtype=None) @@ -458,4 +458,4 @@ def csv2Array(self): vitables.utils.formatExceptionInfo() finally: del data - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() diff --git a/vitables/h5db/dbstreemodel.py b/vitables/h5db/dbstreemodel.py index b1df24c3..029d6908 100644 --- a/vitables/h5db/dbstreemodel.py +++ b/vitables/h5db/dbstreemodel.py @@ -284,7 +284,7 @@ def createDBDoc(self, filepath, is_tmp_db=False): """ try: - QtWidgets.qApp.setOverrideCursor( + QtWidgets.QApplication.setOverrideCursor( QtGui.QCursor(QtCore.Qt.WaitCursor)) # Create the dbdoc try: @@ -311,7 +311,7 @@ def createDBDoc(self, filepath, is_tmp_db=False): self.links_delta = frozenset([]) self.insertRows(0, 1) finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() return db_doc def __createTempDB(self): @@ -342,7 +342,7 @@ def deleteNode(self, index): """ try: - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) node = self.nodeFromIndex(index) # Deletes the node from the database node.editor().delete(node.nodepath) @@ -363,7 +363,7 @@ def deleteNode(self, index): except KeyError: pass finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() def copy_node(self, index): """Mark a node from the tree of databases view as copied. @@ -372,7 +372,7 @@ def copy_node(self, index): """ try: - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) node = self.nodeFromIndex(index) self.ccni = {'is_copied': True, 'nodename': node.name, @@ -380,7 +380,7 @@ def copy_node(self, index): 'nodepath': node.nodepath, 'target': getattr(node, 'target', None)} finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() def cutNode(self, index): """Cut a `tables.Node`. @@ -391,7 +391,7 @@ def cutNode(self, index): """ try: - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) node = self.nodeFromIndex(index) self.ccni = {'is_copied': False, 'nodename': node.name, @@ -414,7 +414,7 @@ def cutNode(self, index): current = self.index(position - 1, 0, parent) self.vtgui.dbs_tree_view.selectNode(current) finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() def pasteNode(self, index, childname, overwrite=False): """Paste a tables.Node. @@ -429,7 +429,7 @@ def pasteNode(self, index, childname, overwrite=False): """ try: - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) parent = self.nodeFromIndex(index) # If the overwritten node (if any) exists in the tree of @@ -454,7 +454,7 @@ def pasteNode(self, index, childname, overwrite=False): # Select the pasted node self.selectIndex(index, childname) finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() def copiedNode(self): """The tables.Node currently copied/cut. @@ -481,7 +481,7 @@ def create_group(self, index, childname, overwrite=False): """ try: - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) parent = self.nodeFromIndex(index) # If the overwritten node (if any) exists in the tree of # databases view then delete it @@ -498,7 +498,7 @@ def create_group(self, index, childname, overwrite=False): # Select the pasted node self.selectIndex(index, childname) finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() def rename_node(self, index, new_name, overwrite=False): """Rename a node. @@ -511,7 +511,7 @@ def rename_node(self, index, new_name, overwrite=False): """ try: - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) node = self.nodeFromIndex(index) initial_nodepath = node.nodepath parent_index = self.parent(index) @@ -534,7 +534,7 @@ def rename_node(self, index, new_name, overwrite=False): except KeyError: pass finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() def updateDBTree(self, index, new_name, node): """ @@ -595,7 +595,7 @@ def move_node(self, src_filepath, childpath, parent_index, overwrite=False): """ try: - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) parent_node = self.nodeFromIndex(parent_index) # full path of the destination database and new parent dst_filepath = parent_node.filepath @@ -624,7 +624,7 @@ def move_node(self, src_filepath, childpath, parent_index, overwrite=False): movedname = editor.move(childpath, self.getDBDoc(dst_filepath), parentpath, nodename) finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() return movedname def validateNodename(self, src_filepath, childpath, dst_filepath, diff --git a/vitables/preferences/vtconfig.py b/vitables/preferences/vtconfig.py index 041a7507..c570ad4f 100644 --- a/vitables/preferences/vtconfig.py +++ b/vitables/preferences/vtconfig.py @@ -137,9 +137,9 @@ def __init__(self): is UserScope. """ - organization = QtWidgets.qApp.organizationName() - product = QtWidgets.qApp.applicationName() - version = QtWidgets.qApp.applicationVersion() + organization = QtWidgets.QApplication.organizationName() + product = QtWidgets.QApplication.applicationName() + version = QtWidgets.QApplication.applicationVersion() if sys.platform.startswith('win'): # organizationName() -> product # applicationName() -> version @@ -206,7 +206,7 @@ def loggerFont(self): """ key = 'Logger/Font' - default_value = QtWidgets.qApp.font() + default_value = QtWidgets.QApplication.font() setting_value = self.value(key) if isinstance(setting_value, QtGui.QFont): return setting_value @@ -570,7 +570,7 @@ def applyUserPreferences(self, config): if key in config: self.current_style = config[key] # Default style is provided by the underlying window manager - QtWidgets.qApp.setStyle(self.current_style) + QtWidgets.QApplication.setStyle(self.current_style) key = 'Plugins/Enabled' if key in config: diff --git a/vitables/queries/query.py b/vitables/queries/query.py index a858cdc6..672ae3d6 100644 --- a/vitables/queries/query.py +++ b/vitables/queries/query.py @@ -131,7 +131,7 @@ def queryWithIndex(self, src_dict): # Selection is done in several steps. It saves a *huge* # amount of memory when querying large tables for i in numpy.arange(0, div+1): - QtWidgets.qApp.processEvents() + QtWidgets.QApplication.processEvents() lstart = start + chunk_size*i if lstart > stop: lstart = stop @@ -187,7 +187,7 @@ def queryWithNoIndex(self, src_dict): # Selection is done in several steps. It saves a *huge* # amount of memory when querying large tables for i in numpy.arange(0, div+1): - QtWidgets.qApp.processEvents() + QtWidgets.QApplication.processEvents() lstart = start + chunk_size*i if lstart > stop: lstart = stop diff --git a/vitables/queries/querydlg.py b/vitables/queries/querydlg.py index 2202edca..cca217b1 100644 --- a/vitables/queries/querydlg.py +++ b/vitables/queries/querydlg.py @@ -115,7 +115,7 @@ def __init__(self, info, ft_names, counter, initial_query, table): # # Create the dialog and customise the content of some widgets # - super(QueryDlg, self).__init__(QtWidgets.qApp.activeWindow()) + super(QueryDlg, self).__init__(QtWidgets.QApplication.activeWindow()) self.setupUi(self) self.setWindowTitle(translate('QueryDlg', 'New query on table: {0}', diff --git a/vitables/queries/querymgr.py b/vitables/queries/querymgr.py index 4e3b6d16..26fd062b 100644 --- a/vitables/queries/querymgr.py +++ b/vitables/queries/querymgr.py @@ -199,7 +199,7 @@ def newQuery(self): new_query = query.Query(tmp_h5file, table_uid, table, query_description) new_query.query_completed.connect(self.addQueryResult) - QtWidgets.qApp.setOverrideCursor(QtCore.Qt.WaitCursor) + QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) new_query.run() def getQueryInfo(self, info, table): @@ -231,7 +231,7 @@ def getQueryInfo(self, info, table): finally: query_description = dict(query_dlg.query_info) del query_dlg - QtWidgets.qApp.processEvents() + QtWidgets.QApplication.processEvents() if not query_description['condition']: return None @@ -298,7 +298,7 @@ def addQueryResult(self, completed, table_uid): - `table_uid`: the UID of the table just queried """ - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() if not completed: log.error(translate('QueriesManager', 'Query on table {0} failed!', diff --git a/vitables/utils.py b/vitables/utils.py index 51414e16..11f616ee 100644 --- a/vitables/utils.py +++ b/vitables/utils.py @@ -56,7 +56,7 @@ def getVTApp(): """ vtapp = None - for widget in QtWidgets.qApp.topLevelWidgets(): + for widget in QtWidgets.QApplication.topLevelWidgets(): if widget.objectName() == 'VTGUI': vtapp = widget.vtapp break diff --git a/vitables/vtapp.py b/vitables/vtapp.py index d239e0c7..d389b878 100644 --- a/vitables/vtapp.py +++ b/vitables/vtapp.py @@ -550,12 +550,12 @@ def fileSaveAs(self): # Make a copy of the selected file try: - QtWidgets.qApp.setOverrideCursor( + QtWidgets.QApplication.setOverrideCursor( QtGui.QCursor(QtCore.Qt.WaitCursor)) dbdoc = self.gui.dbs_tree_model.getDBDoc(initial_filepath) dbdoc.copy_file(filepath) finally: - QtWidgets.qApp.restoreOverrideCursor() + QtWidgets.QApplication.restoreOverrideCursor() # Close the copied file (which is not necessarely selected in # the tree view because closing an overwritten file can change diff --git a/vitables/vtgui.py b/vitables/vtgui.py index 15d7bb8c..cd00dc7a 100644 --- a/vitables/vtgui.py +++ b/vitables/vtgui.py @@ -151,8 +151,6 @@ def addComponents(self): # The signal mapper used to keep the the Window menu updated self.window_mapper = QtCore.QSignalMapper(self) - self.window_mapper.mapped[QtWidgets.QWidget].connect( - self.workspace.setActiveSubWindow) self.workspace.installEventFilter(self) self.dbs_tree_view.clicked.connect(self.selection_changed) @@ -678,7 +676,7 @@ def closeEvent(self, event): # Quit event.accept() - QtWidgets.qApp.quit() + QtWidgets.QApplication.quit() def makeCopy(self): """Copy text/leaf depending on which widget has focus. diff --git a/vitables/vtsplash.py b/vitables/vtsplash.py index 7f76a11e..0bbcdbdb 100644 --- a/vitables/vtsplash.py +++ b/vitables/vtsplash.py @@ -74,7 +74,7 @@ def drawMessage(self, msg): :Parameter msg: the message to be displayed """ - QtWidgets.qApp.processEvents() + QtWidgets.QApplication.processEvents() self.msg = msg self.showMessage(self.msg) time.sleep(0.500) diff --git a/vitables/vttables/datasheet.py b/vitables/vttables/datasheet.py index abf6443e..cb83cae1 100644 --- a/vitables/vttables/datasheet.py +++ b/vitables/vttables/datasheet.py @@ -110,7 +110,7 @@ def closeEvent(self, event): QtWidgets.QMdiSubWindow.closeEvent(self, event) if not self.vtgui.workspace.subWindowList(): - self.vtgui.dbs_tree_view.setFocus(True) + self.vtgui.dbs_tree_view.setFocus() def focusInEvent(self, event): """Specialised handler for focus events. @@ -125,7 +125,7 @@ def focusInEvent(self, event): # clicked is counter intuitive) QtWidgets.QMdiSubWindow.focusInEvent(self, event) self.syncTreeView() - self.setFocus(True) + self.setFocus() def syncTreeView(self): """