mirror of https://github.com/m-labs/artiq.git
dashboard: use get_open_file_name
This commit is contained in:
parent
c44e786cc5
commit
c5fcb6b8d5
|
@ -8,7 +8,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
import h5py
|
import h5py
|
||||||
|
|
||||||
from artiq import __artiq_dir__ as artiq_dir
|
from artiq import __artiq_dir__ as artiq_dir
|
||||||
from artiq.gui.tools import LayoutWidget, log_level_to_name, getOpenFileName
|
from artiq.gui.tools import LayoutWidget, log_level_to_name, get_open_file_name
|
||||||
from artiq.gui.entries import argty_to_entry
|
from artiq.gui.entries import argty_to_entry
|
||||||
from artiq.protocols import pyon
|
from artiq.protocols import pyon
|
||||||
from artiq.master.worker import Worker
|
from artiq.master.worker import Worker
|
||||||
|
@ -346,7 +346,7 @@ class ExperimentsArea(QtWidgets.QMdiArea):
|
||||||
|
|
||||||
async def _select_experiment_task(self):
|
async def _select_experiment_task(self):
|
||||||
try:
|
try:
|
||||||
file = await getOpenFileName(
|
file = await get_open_file_name(
|
||||||
self, "Open experiment", self.current_dir,
|
self, "Open experiment", self.current_dir,
|
||||||
"Experiments (*.py);;All files (*.*)")
|
"Experiments (*.py);;All files (*.*)")
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
|
|
|
@ -7,7 +7,7 @@ from collections import OrderedDict
|
||||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
import h5py
|
import h5py
|
||||||
|
|
||||||
from artiq.gui.tools import LayoutWidget, log_level_to_name
|
from artiq.gui.tools import LayoutWidget, log_level_to_name, get_open_file_name
|
||||||
from artiq.gui.entries import argty_to_entry
|
from artiq.gui.entries import argty_to_entry
|
||||||
from artiq.protocols import pyon
|
from artiq.protocols import pyon
|
||||||
|
|
||||||
|
@ -330,18 +330,18 @@ class _ExperimentDock(QtWidgets.QMdiSubWindow):
|
||||||
self.layout.addWidget(self.argeditor, 0, 0, 1, 5)
|
self.layout.addWidget(self.argeditor, 0, 0, 1, 5)
|
||||||
|
|
||||||
def _load_hdf5_clicked(self):
|
def _load_hdf5_clicked(self):
|
||||||
dialog = QtWidgets.QFileDialog(self.manager.main_window,
|
asyncio.ensure_future(self._load_hdf5_task())
|
||||||
"Load HDF5", self.hdf5_load_directory,
|
|
||||||
"HDF5 files (*.h5 *.hdf5);;All files (*.*)")
|
async def _load_hdf5_task(self):
|
||||||
dialog.setFileMode(QtWidgets.QFileDialog.ExistingFile)
|
try:
|
||||||
def on_accept():
|
filename = await get_open_file_name(
|
||||||
filename = dialog.selectedFiles()[0]
|
self.manager.main_window, "Load HDF5",
|
||||||
self.hdf5_load_directory = os.path.dirname(filename)
|
self.hdf5_load_directory,
|
||||||
asyncio.ensure_future(self._load_hdf5_task(filename))
|
"HDF5 files (*.h5 *.hdf5);;All files (*.*)")
|
||||||
dialog.accepted.connect(on_accept)
|
except asyncio.CancelledError:
|
||||||
dialog.open()
|
return
|
||||||
|
self.hdf5_load_directory = os.path.dirname(filename)
|
||||||
|
|
||||||
async def _load_hdf5_task(self, filename):
|
|
||||||
try:
|
try:
|
||||||
with h5py.File(filename, "r") as f:
|
with h5py.File(filename, "r") as f:
|
||||||
expid = f["expid"][()]
|
expid = f["expid"][()]
|
||||||
|
|
|
@ -48,7 +48,7 @@ class LayoutWidget(QtWidgets.QWidget):
|
||||||
self.layout.addWidget(item, row, col, rowspan, colspan)
|
self.layout.addWidget(item, row, col, rowspan, colspan)
|
||||||
|
|
||||||
|
|
||||||
async def getOpenFileName(parent, caption, dir, filter):
|
async def get_open_file_name(parent, caption, dir, filter):
|
||||||
"""like QtWidgets.QFileDialog.getOpenFileName(), but a coroutine"""
|
"""like QtWidgets.QFileDialog.getOpenFileName(), but a coroutine"""
|
||||||
dialog = QtWidgets.QFileDialog(parent, caption, dir, filter)
|
dialog = QtWidgets.QFileDialog(parent, caption, dir, filter)
|
||||||
dialog.setFileMode(dialog.ExistingFile)
|
dialog.setFileMode(dialog.ExistingFile)
|
||||||
|
|
Loading…
Reference in New Issue