Skip to content

Commit 7fe9f43

Browse files
farhiEmmanuel FARHI
andauthored
McGui: show current instrument name in dialogues (#1989)
* mcgui: set main window title with instr name when opening it * mcgui: run dialog: show current instrument name --------- Co-authored-by: Emmanuel FARHI <emmanuel.farhi.1@gmail.com>
1 parent 421e6ee commit 7fe9f43

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

tools/Python/mcgui/mcgui.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,10 @@ def __init__(self):
501501
if not os.path.splitext(a)[1] == '.py':
502502
if self.state.getInstrumentFile() == '':
503503
self.state.loadInstrument(a)
504+
prefix = 'mx'
505+
if mccode_config.configuration["MCCODE"] == "mcstas":
506+
prefix = 'mc'
507+
self.view.mw.setWindowTitle(prefix + 'gui-py: ' + os.path.basename(str(a)))
504508

505509
# Shouldn't really be necessary, but otherwise App menu is inactive on macOS
506510
# (was initially put in message/status update mechanism, but that caused other side-effects, see
@@ -659,7 +663,9 @@ def get_compnames(text):
659663

660664
comps = get_compnames(text=open(self.state.getInstrumentFile(), 'rb').read().decode())
661665
_a, mcplots, mcdisplays, formats = mccode_config.get_options()
666+
# create or display the Run Dialog
662667
fixed_params, new_instr_params, inspect, mcdisplay, autoplotter, Format = self.view.showStartSimDialog(
668+
self.state.getInstrumentFile(),
663669
instr_params, comps, mcdisplays, mcplots, formats, mccode_config.configuration["NDBUFFERSIZE"])
664670

665671
if Format != None:
@@ -952,6 +958,11 @@ def handleOpenInstrument(self):
952958
self.state.loadInstrument(instr)
953959
self.emitter.message("Instrument opened: " + os.path.basename(str(instr)), gui=True)
954960
self.emitter.status("Instrument: " + os.path.basename(str(instr)))
961+
# set window title
962+
prefix = 'mx'
963+
if mccode_config.configuration["MCCODE"] == "mcstas":
964+
prefix = 'mc'
965+
self.view.mw.setWindowTitle(prefix + 'gui-py: ' + os.path.basename(str(instr)))
955966

956967
def handleMcdoc(self):
957968
cmd='%sdoc' % mccode_config.get_mccode_prefix()

tools/Python/mcgui/viewclasses.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@ def showChangeWorkDirDlg(self, lookDir):
173173
if dlg.exec():
174174
return dlg.selectedFiles()[0]
175175

176-
def showStartSimDialog(self, params, comps, mcdisplays, mcplots, formats, buffersize):
176+
def showStartSimDialog(self, instr, params, comps, mcdisplays, mcplots, formats, buffersize):
177177
if self.__ssd == None:
178178
self.__ssd = McStartSimDialog()
179+
self.__ssd.ui.gbxGrid.setTitle('Instrument parameters: '+ os.path.basename(str(instr)))
179180
self.__ssd.createParamsWidgets(params)
180181
self.__ssd.set_components(comps)
181182
self.__ssd.set_mcdisplays(mcdisplays)

0 commit comments

Comments
 (0)