Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
GitLab will be unavailable Saturday, August 20, 2022, 7:00 - 8:00 pm, during planned maintenance.
Open sidebar
Zhang, Tong
Online Model App
Commits
7ca89f8b
Commit
7ca89f8b
authored
Aug 02, 2021
by
Tong Zhang
Browse files
ENH: Support export physics model to a FLAME lattice file.
parent
38dcbfe1
Changes
1
Show whitespace changes
Inline
Side-by-side
src/myApp/app.py
View file @
7ca89f8b
...
...
@@ -29,6 +29,7 @@ from mpl4qt.widgets import MatplotlibBaseWidget
from
phantasy
import
MachinePortal
from
phantasy_ui
import
BaseAppForm
from
phantasy_ui
import
milli_sleep
from
phantasy_ui
import
get_save_filename
from
phantasy_ui.widgets
import
ElementWidget
from
phantasy_ui.widgets
import
LatticeWidget
from
phantasy_apps.allison_scanner.data
import
draw_beam_ellipse_with_params
...
...
@@ -470,6 +471,27 @@ class MyAppWindow(BaseAppForm, Ui_MainWindow):
self
.
elemlist_cbb
.
setCurrentIndex
(
self
.
elemlist_cbb
.
count
()
-
1
)
self
.
elemlist_cbb
.
currentTextChanged
.
emit
(
self
.
elemlist_cbb
.
currentText
())
@
pyqtSlot
()
def
onExportLatfile
(
self
):
"""Export FLAME lattice file from the model.
"""
filename
,
ext
=
get_save_filename
(
self
,
caption
=
"Choose a file to save"
,
cdir
=
'.'
,
type_filter
=
"Lattice File (*.lat)"
)
if
filename
is
None
:
return
try
:
self
.
fm
.
generate_latfile
(
latfile
=
filename
)
except
:
QMessageBox
.
warning
(
self
,
"Export Lattice File"
,
"Failed to export model as a FLAME lattice file."
,
QMessageBox
.
Ok
,
QMessageBox
.
Ok
)
else
:
QMessageBox
.
information
(
self
,
"Export Lattice File"
,
f
"Export FLAME lattice file to
{
filename
}
."
,
QMessageBox
.
Ok
,
QMessageBox
.
Ok
)
if
__name__
==
"__main__"
:
from
PyQt5.QtWidgets
import
QApplication
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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