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
VIGNET Pierre
cadbiom
Commits
0376b3d1
Commit
0376b3d1
authored
Nov 23, 2019
by
VIGNET Pierre
Browse files
[gui] Memorize previous writtent/opened folders
parent
3bec6ee1
Changes
1
Hide whitespace changes
Inline
Side-by-side
gui/cadbiom_gui/gt_gui/charter.py
View file @
0376b3d1
...
...
@@ -41,7 +41,7 @@
"""
Main class for Cadbiom gui
"""
import
os
import
gtk
import
webbrowser
...
...
@@ -98,6 +98,10 @@ class Charter(object):
self
.
simul_strict
=
True
self
.
sim_flat_graph
=
False
# working folders for FileChooser
self
.
previously_opened_folder
=
os
.
getcwd
()
self
.
previously_written_folder
=
os
.
getcwd
()
# common clipboard
self
.
clipboard
=
ChartClipboard
()
# gui
...
...
@@ -654,6 +658,7 @@ class Charter(object):
"""
fch
=
FileChooser
(
"Export to xml Cadbiom model"
,
"bcx files"
,
"*.bcx"
)
fch
.
set_current_name
(
self
.
current_edit_mvc
.
model
.
name
+
".bcx"
)
fch
.
set_current_folder
(
self
.
previously_written_folder
)
fch
.
do_action
(
self
.
create_xml_file
)
...
...
@@ -670,6 +675,7 @@ class Charter(object):
mfile
=
open
(
xml_file
,
'w'
)
mfile
.
write
(
xml
.
return_xml
())
mfile
.
close
()
self
.
previously_written_folder
=
os
.
path
.
dirname
(
xml_file
)
except
XmlException
as
xec
:
cancel_warn
(
xec
.
message
)
return
...
...
@@ -680,22 +686,25 @@ class Charter(object):
"""
fch
=
FileChooser
(
"Import xml Cadbiom model"
,
"bcx files"
,
"*.bcx"
,
save_window
=
False
)
fch
.
set_current_folder
(
self
.
previously_opened_folder
)
fch
.
do_action
(
self
.
import_from_xml_file
)
def
import_from_xml_file
(
self
,
f
file
):
def
import_from_xml_file
(
self
,
xml_
file
):
"""
As it says
"""
self
.
import_from_xml
(
ffile
,
ffile
=
True
)
self
.
import_from_xml
(
xml_file
,
ffile
=
True
)
self
.
previously_opened_folder
=
os
.
path
.
dirname
(
xml_file
)
def
import_from_xml
(
self
,
xml_
cont
,
ffile
=
False
):
def
import_from_xml
(
self
,
xml_
file
,
ffile
=
False
):
"""
open and parse an xml file or from db
"""
if
ffile
:
parsing
=
MakeModelFromXmlFile
(
xml_
cont
)
parsing
=
MakeModelFromXmlFile
(
xml_
file
)
else
:
parsing
=
MakeModelFromXmlString
(
xml_cont
)
parsing
=
MakeModelFromXmlString
(
xml_file
)
# chart model
model
=
parsing
.
get_model
()
model
.
modified
=
False
...
...
@@ -708,6 +717,7 @@ class Charter(object):
"""
fch
=
FileChooser
(
"Import from Cadbiom-chart lang"
,
"cadbiom-l"
,
"*.cal"
,
save_window
=
False
)
fch
.
set_current_folder
(
self
.
previously_opened_folder
)
fch
.
do_action
(
self
.
import_from_cl_file
)
def
import_from_cl_file
(
self
,
ffile
):
...
...
@@ -725,6 +735,7 @@ class Charter(object):
if
crep
.
error
:
DisplayError
(
crep
,
ffile
)
return
self
.
previously_opened_folder
=
os
.
path
.
dirname
(
ffile
)
model
=
parser
.
model
self
.
add_edit_mvc
(
model
.
name
,
model
,
False
)
self
.
do_layout
(
None
,
"hierarchical_LR"
)
...
...
@@ -751,6 +762,7 @@ class Charter(object):
"""
fch
=
FileChooser
(
"Export to Cadbiom-chart lang"
,
"cadbiom-l"
,
"*.cal"
)
fch
.
set_current_name
(
self
.
current_edit_mvc
.
model
.
name
+
".cal"
)
fch
.
set_current_folder
(
self
.
previously_written_folder
)
fch
.
do_action
(
self
.
compile_to_lang
)
def
compile_to_lang
(
self
,
file_name
):
...
...
@@ -762,6 +774,7 @@ class Charter(object):
lvi
=
LangVisitor
(
out
)
self
.
current_edit_mvc
.
model
.
accept
(
lvi
)
out
.
close
()
self
.
previously_written_folder
=
os
.
path
.
dirname
(
file_name
)
def
show_doc
(
self
,
widget
):
"""
...
...
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