Skip to content

Commit 3346cf4

Browse files
committed
enh: allow loading data via drag&drop
1 parent b693d95 commit 3346cf4

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
2.0.1
22
- fix: correctly distinguish prereleases when checking for new versions
3+
- enh: allow loading data via drag&drop
34
2.0.0
45
- initial release

shapeout2/gui/main.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,26 @@ def add_plot_window(self, plot_id):
372372
sub.setFixedSize(sub.sizeHint())
373373
sub.show()
374374

375+
def dragEnterEvent(self, e):
376+
"""Whether files are accepted"""
377+
if e.mimeData().hasUrls():
378+
e.accept()
379+
else:
380+
e.ignore()
381+
382+
def dropEvent(self, e):
383+
"""Add dropped files to view"""
384+
urls = e.mimeData().urls()
385+
pathlist = []
386+
for ff in urls:
387+
pp = pathlib.Path(ff.toLocalFile())
388+
if pp.is_dir():
389+
pathlist += list(pp.rglob("*.rtdc"))
390+
elif pp.suffix == ".rtdc":
391+
pathlist.append(pp)
392+
if pathlist:
393+
self.add_dataslot(paths=sorted(pathlist))
394+
375395
def init_analysis_view(self):
376396
sub = widgets.MDISubWindowWOButtons(self)
377397
self.widget_ana_view = analysis.AnalysisView()

shapeout2/gui/main.ui

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<height>670</height>
1111
</rect>
1212
</property>
13+
<property name="acceptDrops">
14+
<bool>true</bool>
15+
</property>
1316
<property name="windowTitle">
1417
<string>Shape-Out</string>
1518
</property>

0 commit comments

Comments
 (0)