Add rudimentary drag and drop
This commit is contained in:
parent
f50631521c
commit
fab41962fd
@ -86,8 +86,26 @@ class MainWindow(QMainWindow):
|
|||||||
# Measurement metadata
|
# Measurement metadata
|
||||||
self.w_metadata = MetadataInput(metadata_init_dict)
|
self.w_metadata = MetadataInput(metadata_init_dict)
|
||||||
self.w_lefttab.addTab(self.w_metadata, "Measurement metadata")
|
self.w_lefttab.addTab(self.w_metadata, "Measurement metadata")
|
||||||
|
# TODO: the call_f solution isnt pretty
|
||||||
|
# TODO: only accept single file?
|
||||||
|
class RightTab(QTabWidget):
|
||||||
|
def __init__(self, call_f, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.setAcceptDrops(True)
|
||||||
|
self.call_f = call_f
|
||||||
|
def dragEnterEvent(self, event):
|
||||||
|
if event.mimeData().hasUrls():
|
||||||
|
event.accept()
|
||||||
|
else:
|
||||||
|
event.ignore()
|
||||||
|
def dropEvent(self, event):
|
||||||
|
for url in event.mimeData().urls():
|
||||||
|
file_path = url.path()[1:]
|
||||||
|
if file_path.endswith("csv"):
|
||||||
|
self.call_f(file_path)
|
||||||
|
return
|
||||||
# Right: Tabs: Script, Plot
|
# Right: Tabs: Script, Plot
|
||||||
self.w_right_tab = QTabWidget()
|
self.w_right_tab = RightTab(self.measurement_load)
|
||||||
layout.addWidget(self.w_right_tab)
|
layout.addWidget(self.w_right_tab)
|
||||||
max_data_points = AppConfig.MAIN_CFG.get_or("plot_max_data_points", 40000)
|
max_data_points = AppConfig.MAIN_CFG.get_or("plot_max_data_points", 40000)
|
||||||
self.w_plot = Plot(max_data_points=max_data_points)
|
self.w_plot = Plot(max_data_points=max_data_points)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user