Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jan Zelenka
prasopes
Commits
b5048827
Commit
b5048827
authored
Sep 06, 2018
by
3Yan
Browse files
Improved file open dialog
parent
45e9c492
Changes
3
Hide whitespace changes
Inline
Side-by-side
prasopes/__main__.py
View file @
b5048827
...
...
@@ -15,15 +15,25 @@ import prasopes.config as cf
import
sys
import
matplotlib
import
logging
import
os.path
matplotlib
.
use
(
"Qt5Agg"
)
def
load_file
(
chrom_plot
,
spc
,
d_set
,
ms_s
,
fn
,
chrom_s
,
settings
):
"""populates dataset and plots it"""
lf
=
ft
.
open_dial
(
d_set
,
settings
)
if
lf
is
not
None
:
directory
=
settings
.
value
(
"open_folder"
)
if
fn
[
0
]
is
not
None
:
directory
=
fn
[
0
]
filename
=
QtWidgets
.
QFileDialog
.
getOpenFileName
(
caption
=
"Open spectrum"
,
directory
=
directory
,
filter
=
"Finnigan RAW files (*.raw, *.RAW)"
)[
0
]
if
filename
is
not
''
:
d_set
[
'chrom_dat'
],
d_set
[
'masses'
],
d_set
[
'matrix'
]
\
=
load_raw
(
filename
,
settings
.
value
(
"tmp_location"
))
gt
.
populate
(
chrom_plot
,
spc
,
d_set
,
ms_s
,
chrom_s
)
fn
[
0
]
=
lf
fn
[
0
]
=
filename
def
update_spectrum
(
event
,
chromatogram
,
spect
,
ds
,
ms
,
fn
,
chrom
,
config
):
...
...
@@ -37,7 +47,6 @@ def update_spectrum(event, chromatogram, spect, ds,
spect
.
get_figure
().
canvas
.
draw
()
def
main
():
# ds for data_set, ms for mass_spec_dataset, chrom for chrom_dataset
ds
=
dict
(
chrom_dat
=
None
,
masses
=
None
,
matrix
=
None
)
...
...
prasopes/config.py
View file @
b5048827
...
...
@@ -10,13 +10,27 @@ def settings():
return
settings
def
tmp_dial
(
tmp_text
,
config
):
def
pathsearch
(
text
,
value
,
config
):
filename
=
QtWidgets
.
QFileDialog
.
getExistingDirectory
()
if
filename
is
not
''
:
tmp_
text
.
setText
(
filename
)
config
.
setValue
(
"tmp_location"
,
filename
)
text
.
setText
(
filename
)
config
.
setValue
(
value
,
filename
)
def
pathlayout
(
label
,
value
,
config
):
"""adds generic filepath config line"""
textfield
=
QtWidgets
.
QLineEdit
(
config
.
value
(
value
))
textfield
.
editingFinished
.
connect
(
lambda
:
config
.
setValue
(
value
,
textfield
.
text
()))
browse_button
=
QtWidgets
.
QPushButton
(
"Browse.."
)
browse_button
.
clicked
.
connect
(
lambda
:
pathsearch
(
textfield
,
value
,
config
))
layout
=
QtWidgets
.
QHBoxLayout
()
layout
.
addWidget
(
QtWidgets
.
QLabel
(
"{}:"
.
format
(
label
)))
layout
.
addWidget
(
textfield
)
layout
.
addWidget
(
browse_button
)
return
layout
def
dial
(
parent
):
"""constructs a dialog window"""
...
...
@@ -25,28 +39,18 @@ def dial(parent):
dialog
.
resize
(
600
,
-
1
)
config
=
settings
()
tmp_text
=
QtWidgets
.
QLineEdit
(
config
.
value
(
"tmp_location"
))
tmp_text
.
editingFinished
.
connect
(
lambda
:
config
.
setValue
(
"tmp_location"
,
tmp_text
.
text
()))
browse_button
=
QtWidgets
.
QPushButton
(
"Browse.."
)
browse_button
.
clicked
.
connect
(
lambda
:
tmp_dial
(
tmp_text
,
config
))
close_button
=
QtWidgets
.
QPushButton
(
"Close"
)
close_button
.
clicked
.
connect
(
dialog
.
close
)
layout
=
QtWidgets
.
QVBoxLayout
(
dialog
)
butt_layout
=
QtWidgets
.
QHBoxLayout
()
tmp_layout
=
QtWidgets
.
QHBoxLayout
()
tmp_layout
.
addWidget
(
QtWidgets
.
QLabel
(
"Acquisition temp folder:"
))
tmp_layout
.
addWidget
(
tmp_text
)
tmp_layout
.
addWidget
(
browse_button
)
butt_layout
.
addWidget
(
close_button
)
butt_layout
.
addStretch
(
1
)
layout
.
addLayout
(
tmp_layout
)
layout
=
QtWidgets
.
QVBoxLayout
(
dialog
)
layout
.
addLayout
(
pathlayout
(
"Acquisition temp folder"
,
"tmp_location"
,
config
))
layout
.
addLayout
(
pathlayout
(
"Default open folder"
,
"open_folder"
,
config
))
layout
.
addStretch
(
1
)
layout
.
addLayout
(
butt_layout
)
...
...
prasopes/filetools.py
View file @
b5048827
...
...
@@ -3,19 +3,6 @@ from rawprasslib import load_raw
import
os.path
def
open_dial
(
d_set
,
settings
):
"""Populates dataset, returns filename"""
filename
=
QtWidgets
.
QFileDialog
.
getOpenFileName
(
caption
=
"Open spectrum"
,
filter
=
"Finnigan RAW files (*.raw, *.RAW)"
)[
0
]
if
filename
is
not
''
:
d_set
[
'chrom_dat'
],
d_set
[
'masses'
],
d_set
[
'matrix'
]
\
=
load_raw
(
filename
,
settings
.
value
(
"tmp_location"
))
return
filename
else
:
return
None
def
get_save_filename
(
caption
,
fnfilter
,
suffix
,
parent
):
"""fix Qt5 "feature" - it does add sufix when exporting
and thus also cant check for file with the selected suffix"""
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment