本文整理汇总了Python中CDMLib.dlgSimpleMsg方法的典型用法代码示例。如果您正苦于以下问题:Python CDMLib.dlgSimpleMsg方法的具体用法?Python CDMLib.dlgSimpleMsg怎么用?Python CDMLib.dlgSimpleMsg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDMLib
的用法示例。
在下文中一共展示了CDMLib.dlgSimpleMsg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ExportSimResult
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def ExportSimResult(self, event):
evt_id = event.GetId()
if evt_id == cdml.IDF_BUTTON1:
id_sim = self.cc_id_sim.GetValue() # Retrieve simulation ID from combo box
if id_sim == "":
return
id_sim = int(id_sim)
target_id = [
result.ID
for result in DB.SimulationResults.values()
if result.ID == id_sim and result.ProjectID == self.idPrj
]
if len(target_id) != 1:
return None
NewPath = self.GetExportFileName()
if NewPath == None:
return
else:
self.Path = NewPath # replace previous path with current path
try:
DB.SimulationResults[id_sim].ExportAsCSV(self.Path)
except:
msg = "Could not complete saving into the selected file, check if the file is not in use or otherwise locked"
cdml.dlgSimpleMsg("ERROR", msg, wx.OK, wx.ICON_ERROR, Parent=self)
return False
return True
示例2: CopyTransitionsFromAnotherStudyModel
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def CopyTransitionsFromAnotherStudyModel(self, event=None):
"""
Allow the user to copy all the transitions from an existing study/model
This will bring a dialog box for the user and allow choosing the study
to copy transitions from.
"""
DestinationStudyModelID = self.openData
if DestinationStudyModelID == None or DestinationStudyModelID not in DB.StudyModels.keys():
raise ValueError, "ASSERTION ERROR: invalid destination study model while copying"
return
SortedByNameStudyModelKeys = sorted(DB.StudyModels.keys(), key = lambda Entry: ( DB.StudyModels[Entry].Name , Entry))
# For a study show studies to copy from, for a model show models.
SourceStudyModelNames = map (lambda Entry: str(DB.StudyModels[Entry].Name), SortedByNameStudyModelKeys)
dlg = wx.SingleChoiceDialog(self, 'Please select a Model to copy transitions from', 'Copy all Transitions From a Model', SourceStudyModelNames, wx.CHOICEDLG_STYLE )
if dlg.ShowModal() == wx.ID_OK: # then open blank project form
SelectionIndex = dlg.GetSelection()
if 0 <= SelectionIndex <= (len(SourceStudyModelNames)-1):
SourceStudyModelID = SortedByNameStudyModelKeys[SelectionIndex]
frame = self.GetTopLevelParent()
(RecordsCopied,RecordsToCopy) = DB.StudyModels[DestinationStudyModelID].CopyTransitionsFromAnotherStudyModel(SourceStudyModelID, ProjectBypassID = frame.idPrj)
cdml.dlgSimpleMsg('Completed transition copying from another model', str(RecordsCopied) +' out of ' + str(RecordsToCopy) +' transitions were copied. ', wx.OK, wx.ICON_INFORMATION, Parent = self)
self.InitTransitions()
示例3: DeleteObjective
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def DeleteObjective(self):
"Deletes an objective from the objectives list box"
idx = self.lc_objectives.GetFirstSelected()
if idx == -1 :
cdml.dlgSimpleMsg('ERROR', 'Please select an item to remove', Parent = self)
return
# Remove from list
(obj_filter_expr, obj_stat_expr, obj_stat_func, obj_target, obj_weight, obj_calculated, obj_error) = self.Objectives.pop(idx)
# remove from list control display
self.lc_objectives.DeleteItem(idx)
if len(self.Objectives)>idx:
self.lc_objectives.Select(idx, True)
# update the text boxes with the deleted values
self.tc_obj_filter_expr.SetValue(obj_filter_expr)
self.tc_obj_stat_expr.SetValue(obj_stat_expr)
self.cc_obj_stat_func.GetTextCtrl().SetValue(obj_stat_func)
self.tc_obj_target.SetValue(DB.SmartStr(obj_target))
self.tc_obj_weight.SetValue(DB.SmartStr(obj_weight))
# handle hiding/showing controls according to distribution status
if self.lc_objectives.GetItemCount() == 0:
if self.lc_column.GetItemCount() == 0:
self.HasDistribution = None
self.ShowTabData()
self.lc_dist.Enable(not self.HasDistribution)
self.tc_dist_text.Enable(not self.HasDistribution)
示例4: ShowSimResult
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def ShowSimResult(self):
""" Get user response to select simulation result file and open EXCEL to display CSV file"""
RelevantSimulations = [ result.ID for result in DB.SimulationResults.values() if result.ProjectID == self.idPrj ]
if RelevantSimulations != [] :
cdml.OpenForm("ResultViewer", key=self.idPrj, parent=self, id_prj=self.idPrj)
else:
cdml.dlgSimpleMsg('INFO', 'No results exist for this project, run the simulation successfully to create results for this project', wx.OK, wx.ICON_INFORMATION, Parent = self)
return
示例5: OnListDblClick
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def OnListDblClick(self, event):
"""Open Parameter form when the text control is clicked twice"""
item = str(event.GetEventObject().GetValue())
if item not in DB.Params.keys():
if item != "":
cdml.dlgSimpleMsg('ERROR', "Can not find a parameter named " + item, Parent = self)
self.OnRefresh(None)
return
types = AllowedParameterTypesThatCanBeUsed
cdml.OpenForm("Parameters", self, cdml.ID_MODE_SINGL, item, types)
示例6: DelSimResult
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def DelSimResult(self, event):
id = event.GetId()
try:
if id == wx.ID_DELETE:
id = self.cc_id_sim.GetValue() # Retrieve simulation ID from combo box
if id == "":
cdml.dlgSimpleMsg("ERROR", "No Result ID was selected", Parent=self)
return
if self.cc_id_sim.GetCount() == 1:
msg = "This is the last simulation result. "
msg += "After deleting this result, the form will be closed automatically."
msg += "\nDo you want to continue?"
ans = cdml.dlgSimpleMsg("WARNING", msg, wx.YES_NO, wx.ICON_WARNING, Parent=self)
if ans == wx.ID_NO:
return
id_sim = int(id)
target_id = [
result.ID
for result in DB.SimulationResults.values()
if result.ID == id_sim and result.ProjectID == self.idPrj
]
if target_id == []:
return
DB.SimulationResults.Delete(target_id[0], ProjectBypassID=self.idPrj)
self.cc_id_sim.Delete(self.cc_id_sim.GetSelection())
self.grid.ClearGrid()
if self.cc_id_sim.GetCount() == 0:
self.cc_id_sim.Clear()
self.cc_id_sim.SetValue("")
else:
self.cc_id_sim.SetSelection(0)
self.ShowSimResult()
else:
for result in DB.SimulationResults.values():
if result.ProjectID != self.idPrj:
continue
DB.SimulationResults.Delete(result.ID, ProjectBypassID=self.idPrj)
self.cc_id_sim.Clear()
self.cc_id_sim.SetValue("")
self.grid.ClearGrid() # Clear current values in grid control
except:
cdml.dlgErrorMsg()
示例7: OnButtonClick
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def OnButtonClick(self, event):
""" Event handler for buttons """
btn_id = event.GetId()
try:
if btn_id == cdml.IDF_BUTTON2: # Import
self.ImportCSV()
if btn_id == cdml.IDF_BUTTON3: # Export
try:
self.SaveData()
self.ShowData(self.DataColumns, self.Data, self.Objectives)
except :
cdml.dlgErrorMsg(Parent = self)
else:
if self.Data == []:
cdml.dlgSimpleMsg('INFO', 'No data has been defined so exporting makes no sense', wx.OK, wx.ICON_INFORMATION, Parent = self)
else:
self.ExportCSV(self.DataColumns, self.Data)
elif btn_id == cdml.IDF_BUTTON4 : # Undo
self.Undo()
elif btn_id == cdml.IDF_BUTTON5 or \
event.GetEventType() == wx.wxEVT_CLOSE_WINDOW : # Ok or Close
try:
self.SaveData()
except :
cdml.dlgErrorMsg(Parent = self)
else :
cdml.CloseForm(self, False)
elif btn_id == wx.ID_ADD: # Up Arrow : Add new State/Distribution
self.AddColumn()
elif btn_id == wx.ID_DELETE: # Down Arrow : Delete State/Distribution
self.DeleteColumn()
elif btn_id == cdml.IDF_BUTTON7: # Down Arrow in objective pane
self.DeleteObjective()
elif btn_id == cdml.IDF_BUTTON8: # Up Arrow in objective pane
self.AddObjective()
except:
cdml.dlgErrorMsg(Parent = self)
示例8: OnMenuSelected
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def OnMenuSelected(self, event):
""" Do something when action buttons are clicked.
Action buttons are Save, Run Simulation, View Result and Close"""
menuId = event.GetId()
evtType = event.GetEventType()
if evtType==wx.wxEVT_COMMAND_MENU_SELECTED:
if menuId not in [cdml.ID_MENU_REPORT_ALL]:
# Use the default handler first and if no more processing needed return
if cdml.OnMenuSelected(self, event):
return
try:
# In any case, if a button - Save, Run, View Result - is clicked, data will be save
save_ok = self.CheckData()
if evtType == wx.wxEVT_CLOSE_WINDOW: # Close Window Event
#cdml.CloseForm(self, True, self.Collection, self.idPrj)
cdml.CloseForm(self, True)
return
elif menuId == cdml.ID_MENU_COPY_RECORD:
copy_ok = self.CopyProject()
if not copy_ok: return
cdml.dlgSimpleMsg('INFO', 'The project has been successfully copied - you are now working on the new copy', wx.OK, wx.ICON_INFORMATION, Parent = self)
elif menuId == wx.ID_SAVE :
if not save_ok: return
cdml.dlgSimpleMsg('INFO', 'The project data has been saved successfully', wx.OK, wx.ICON_INFORMATION, Parent = self)
elif menuId == wx.ID_APPLY: # Run Simulation
self.RunSimulation()
elif menuId == wx.ID_VIEW_DETAILS: # View Results / Extract PopulationSets
self.ShowSimResult()
elif menuId == wx.ID_CLEAR:
result_ids = [ result.ID for result in DB.SimulationResults.values()
if result.ProjectID == self.idPrj ]
if result_ids == [] :
cdml.dlgSimpleMsg('ERROR', "There are no simulation results for this project", Parent = self)
else:
ans = cdml.dlgSimpleMsg('WARNING', 'Simulation results will be deleted permanently.\nDo you want to continue with deletion?', wx.YES_NO, wx.ICON_WARNING, Parent = self)
if ans == wx.ID_NO: return
for id in result_ids:
DB.SimulationResults.Delete(id, ProjectBypassID = self.idPrj)
cdml.dlgSimpleMsg('INFO', 'All simulation results were deleted', wx.OK, wx.ICON_INFORMATION, Parent = self)
except:
(ExceptType, ExceptValue, ExceptTraceback) = sys.exc_info()
need_ans = cdml.iif(evtType == wx.wxEVT_CLOSE_WINDOW, True, False)
if cdml.dlgErrorMsg(yesno=need_ans, Parent = self) == wx.ID_NO:
cdml.CloseForm(self, False)
示例9: OnMenuSelected
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def OnMenuSelected(self, event):
""" Event handler for buttons and menu items in main form"""
menuId = event.GetId()
if menuId in [ wx.ID_NEW, wx.ID_OPEN ]: # New and Open menu
self.OpenDB(menuId) # open dialog to select database file
elif menuId == cdml.ID_MENU_COPY_RECORD:
self.CopyProjectRecord()
elif menuId == cdml.ID_MENU_DELETE_RECORD:
self.DeleteProjectRecord()
elif menuId in [ wx.ID_SAVE, wx.ID_SAVEAS ]: # save or save as menu
self.SaveDB(menuId)
elif menuId in range(cdml.IDF_BUTTON1, cdml.IDF_BUTTON10): # Items in Data Menu and buttons
# check database was loaded
if not self._db_opened:
cdml.dlgSimpleMsg('WARNING', "No data is loaded to the system. Please select 'New' or 'Open' in File menu", wx.OK, wx.ICON_WARNING, Parent = self)
return
btn = self.FindWindowById(menuId) # synchronize selected menu to a button
if btn.userData == None : return # target for should be assigned to each button
# as user data to avoid import statement.
# See __set_properties method
if btn.userData == 'Transitions' and len(DB.StudyModels) == 0:
cdml.dlgSimpleMsg('ERROR', 'A Model should be defined', Parent = self)
return
cdml.OpenForm(btn.userData, self) # open a form as default mode(=None)
elif menuId in [cdml.ID_MENU_ABOUT, cdml.ID_MENU_HELP, cdml.ID_MENU_HELP_GENERAL]:
cdml.OnMenuSelected(self, event)
elif menuId == cdml.ID_MENU_REPORT_THIS: # Create a report for a specific project
index = self.lc_project.GetFirstSelected()
if index in [ -1, 0 ]: # -1 : nothing selected, 0 'New Project' selected
return
ProjectCode = self.IndexToPID[index]
if ProjectCode in DB.Projects.keys():
cdml.OpenForm("ReportViewer",self, key=(DB.Projects[ProjectCode],None) )
elif menuId == cdml.ID_MENU_REPORT_ALL: # Create a report for all projects
CollectionObject = DB.Projects
if CollectionObject != None:
cdml.OpenForm("ReportViewer",self,key=(CollectionObject,None) )
示例10: OnLeftDblClick
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def OnLeftDblClick(self, event):
""" Event handler to open 'State' form"""
cc = event.GetEventObject().GetParent()
id = cc.GetValue()
frame = self.GetTopLevelParent()
if id not in DB.States.keys():
# If this is a listed subprocess - there may be a problem
# Therefore, add the assertion check for this
if id != 0:
cdml.dlgSimpleMsg('Error', "ASSERTION ERROR: Can't find Main Process:" , Parent = self)
return
cdml.OpenForm('States', self, cdml.ID_MODE_SINGL, -1, 'process', frame.idPrj)
else:
cdml.OpenForm('States', self, cdml.ID_MODE_SINGL, id, 'process', frame.idPrj)
示例11: OpenDB
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def OpenDB(self, menuId):
if DB.AccessDirtyStatus():
ans = cdml.dlgSimpleMsg('WARNING', "The data is not saved in a file. Do you want to save it?", wx.YES_NO|wx.CANCEL, wx.ICON_WARNING, Parent = self)
if ans == wx.ID_YES :
if not self.SaveDB(wx.ID_SAVE): return
if ans == wx.ID_CANCEL:
return
if menuId == wx.ID_NEW: # if New menu selected,
path = os.getcwd() + os.sep + 'new_file.zip' # set dummy path
else:
path = self.GetNameDB(wx.OPEN) # else get database name
if path == None : return
if not os.path.isfile(path):
cdml.dlgSimpleMsg('ERROR', 'The file does not exist, please make sure the path is valid', Parent = self)
return
wx.BeginBusyCursor()
reload(DB)
try:
if os.path.isfile(path):
# test the version of the file:
(FileVersion, IsCompatible, IsUpgradable, DidLoad, HasResults) = DB.ReconstructDataFileAndCheckCompatibility(InputFileName = path, JustCheckCompatibility = True, RegenerationScriptName = None, ConvertResults = False, KnownNumberOfErrors = 0, CatchError = True)
if IsCompatible:
# If versions are compatible, just load the file
DB.LoadAllData(path) # If Open menu, load data
elif IsUpgradable:
if HasResults:
wx.EndBusyCursor()
AnswerForConvertResults = cdml.dlgSimpleMsg('Data Conversion', 'This file was generated with an older version of data definitions.: ' + str(FileVersion) + '. It was converted to the new version ' + str (DB.Version) + ' . Converting simulation results may take a long time and such results may not be reproducible with the current version. Even if simulation results are not loaded, the parameters, states, models, Population sets and projects will be loaded.\nDo you wish to convert simulation results from this file? ', wx.YES_NO, wx.ICON_QUESTION, Parent = self)
AnswerForConvertResultsBoolean = AnswerForConvertResults == wx.ID_YES
wx.BeginBusyCursor()
else:
AnswerForConvertResultsBoolean = False
print '*** Converting file to the new version. Please wait - this may take a while ***'
# if a version upgrade is needed, convert the data
(FileVersion, IsCompatible, IsUpgradable, DidLoad, HasResults) = DB.ReconstructDataFileAndCheckCompatibility(InputFileName = path, JustCheckCompatibility = False, RegenerationScriptName = None, ConvertResults = AnswerForConvertResultsBoolean, KnownNumberOfErrors = 0, CatchError = True)
self.ShowProjectList(None)
self.SetTitle("MIST - " + path)
self._db_opened = True
self._path = path
except:
cdml.dlgErrorMsg(Parent = self)
wx.EndBusyCursor()
示例12: DeleteProjectRecord
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def DeleteProjectRecord(self):
""" Delete the Project record pointed on in the list"""
index = self.lc_project.GetFirstSelected()
if index in [ -1, 0 ]: # -1 : nothing selected, 0 : or selected 'New Project'
return
msg = 'Selected project will be deleted permanently.\n'
msg += 'Are you sure you want to delete the selected project?'
ans = cdml.dlgSimpleMsg('WARNING', msg, wx.YES_NO, wx.ICON_WARNING, Parent = self)
if ans == wx.ID_NO: return
ProjectIndex = self.lc_project.GetItemData(index)
pid = self.IndexToPID[ProjectIndex]
if pid not in DB.Projects.keys(): return
try:
DB.Projects.Delete(pid) # delete database object
self.ShowProjectList()
# set the focus on the next record after the deleted one
self.lc_project.Select(index)
except:
cdml.dlgErrorMsg(Parent = self)
示例13: SaveReport
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def SaveReport(self, menuId=wx.ID_SAVE):
""" Save current report"""
if '*' in self.Path or menuId == wx.ID_SAVEAS:
NewPath = self.GetReportFileName()
if NewPath == None:
return False
else:
self.Path = NewPath # replace previous path with current path
try:
OutputFileName = open(self.Path,'w')
OutputFileName.write(self.ReportText)
OutputFileName.close()
except:
msg = 'Could not complete saving into the selected file, check if the file is not in use or otherwise locked'
cdml.dlgSimpleMsg('ERROR', msg, wx.OK, wx.ICON_ERROR, Parent = self)
return False
return True
示例14: OnButtonClick
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def OnButtonClick(self, event):
"""
Event handler to respond to the button click event.
Open Transition Form or create a copy of current Model
New control mechanism may need to make more general method to open and manage child form
"""
id = event.GetId()
if id == cdml.IDP_BUTTON1: # open transition form
if self.Id == 0 :
cdml.dlgSimpleMsg('ERROR', "This model is Empty. Please enter data before transitions", Parent = self)
return
frame = self.GetTopLevelParent()
cdml.OpenForm('Transitions', self, cdml.ID_MODE_MULTI, self.Key, None, frame.idPrj)
elif id == cdml.IDP_BUTTON2:
cdml.dlgNotPrepared()
示例15: ExportCSV
# 需要导入模块: import CDMLib [as 别名]
# 或者: from CDMLib import dlgSimpleMsg [as 别名]
def ExportCSV(self, DataColumns, Data ):
""" Export Population Data from a CSV file"""
wildcard = "CSV File (*.csv)|*.csv| All files (*.*)|*.*"
dialog = wx.FileDialog(None, "Choose a file name to save the data", os.getcwd(), "", wildcard, wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
if dialog.ShowModal() == wx.ID_OK:
try:
# convert the columns from tuples to strings
ColumnHeadersToUse = map(lambda (ColumnName , Distribution) : ColumnName, DataColumns)
DB.ExportDataToCSV(dialog.GetPath(), Data, ColumnHeadersToUse)
except:
cdml.dlgErrorMsg(Parent = self)
else:
# successfully saved the exported data
cdml.dlgSimpleMsg('INFO', 'The data has been successfully saved to file', wx.OK, wx.ICON_INFORMATION, Parent = self)
self.Raise()
dialog.Destroy() # Destroy file selection dialog