当前位置: 首页>>代码示例>>Python>>正文


Python CDMLib类代码示例

本文整理汇总了Python中CDMLib的典型用法代码示例。如果您正苦于以下问题:Python CDMLib类的具体用法?Python CDMLib怎么用?Python CDMLib使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CDMLib类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: OnClose

    def OnClose(self, event):
        """ Event handler activated when this dialog is closed"""

        if event.GetId() == wx.ID_OK:
            type_wizard = cdml.iif( 'Cost' in self.cb_type.GetValue(), 0, 1)
            ival = self.ed_ival.GetValue()

            coef, val = [], []
            item_num = self.lc_vector.GetItemCount()
            for i in range(item_num):
                coef.append(str(self.lc_vector.GetItem(i,0).GetText()))
                val.append(str(self.lc_vector.GetItem(i,1).GetText()))

            wizard_output = [ type_wizard, ival, coef, val ]
            try :
                CostWizardOutput = DB.ConstructCostWizardString(wizard_output)
                cdml.SetRefreshInfo(self, '', CostWizardOutput)

            except:
                CostWizardOutput = None
                ans = cdml.dlgErrorMsg(0, True, Parent = self)
                if ans == wx.ID_YES : return
            cdml.CloseForm(self, True, '', CostWizardOutput)

        else:
            cdml.CloseForm(self, False)
开发者ID:Jacob-Barhak,项目名称:MIST,代码行数:26,代码来源:Wizard.py

示例2: ExportSimResult

    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
开发者ID:Jacob-Barhak,项目名称:MIST,代码行数:29,代码来源:ResultViewer.py

示例3: CopyTransitionsFromAnotherStudyModel

    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()
开发者ID:Jacob-Barhak,项目名称:MIST,代码行数:26,代码来源:Transitions.py

示例4: ImportCSV

    def ImportCSV(self):
        """ Import Population Data from a CSV file"""

        wildcard = "CSV File (*.csv)|*.csv| All files (*.*)|*.*"
        dialog = wx.FileDialog(None, "Choose a file", os.getcwd(), "", wildcard, wx.OPEN)

        if dialog.ShowModal() == wx.ID_OK:
            try:
                (DataColumns, Data) = DB.ImportDataFromCSV(dialog.GetPath())
                Objectives = [] # currently no objectives imported
                # Make sure that DataColumns is composed of strings
                # alone and not numbers or other data types
                # this is a minimal precaution - no other validity checks
                # are made other than what made in ImportDataFromCSV
                AllStrings = all(map(lambda (ColumnName,Distribution): DB.IsStr(ColumnName), DataColumns))
                if not AllStrings:
                    raise ValueError, 'Error Loading CSV file - headers are not all strings'
            except:
                cdml.dlgErrorMsg(Parent = self)
            else:
                # set the HasDistribution flag to False since loading
                # a distribution is not currently supported.
                self.HasDistribution = False
                self.lc_dist.Enable(not self.HasDistribution)
                self.tc_dist_text.Enable(not self.HasDistribution)
                # also load this data to the object
                self.ShowTabData()
                self.DataColumns = DataColumns
                self.Data = Data
                self.Objectives = Objectives
                self.ShowData(DataColumns, Data, Objectives)

        self.Raise()
        dialog.Destroy() # Destroy file selection dialog
开发者ID:arturochian,项目名称:MIST,代码行数:34,代码来源:PopulationData.py

示例5: DeleteProjectRecord

    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)
开发者ID:arturochian,项目名称:MIST,代码行数:25,代码来源:MISTGUI.py

示例6: LoadReportOptions

 def LoadReportOptions(self):
     """ Load report options from file"""
     path = self.GetReportOptionsFileName(wx.FD_OPEN)
     if path != None:
         try:
             BackupFormatOptions = copy.deepcopy(self.FormatOptions)
             FormatOptions = DB.LoadOptionList(path)
             KeyFilterOptionValue = DB.HandleOption('KeyFilter', self.FormatOptions, Value = None, UseNewValue = False, DeleteThisOption = False)
             if KeyFilterOptionValue != None:
                 DB.HandleOption('KeyFilter', FormatOptions, Value = KeyFilterOptionValue, UseNewValue = True, DeleteThisOption = False)
             # now load the data to the controls to reflect the newly loaded data
             # note that not validity checks are made, so if the file loaded
             # properly and had bad data this may be reflected as bad text in
             # the control or even raise an error that can be caught. Since this
             # is not disruptive to data stored in the system no additional
             # checks are made beyond what the system will allow in the controls
             self.PopulateOptionsOnScreen(FormatOptions)
             # now after data was updated update self with the new options
             self.FormatOptions = FormatOptions
             # Everything went fine - no need for backup anymore
             BackupFormatOptions = None
         except:
             cdml.dlgErrorMsg(Parent = self)
         if BackupFormatOptions != None:
             try:
                 # in case of a bad file or an error, restore blank values
                 self.PopulateOptionsOnScreen(BackupFormatOptions)
             except:
                 answer = cdml.dlgErrorMsg(msg_prefix='ASSERTION ERROR: Unable to recover from Error. Here are additional details: ',yesno=True, Parent = self)
                 if answer == wx.ID_YES :
                     return
                 else:
                     cdml.CloseForm(self, False)
     return
开发者ID:Jacob-Barhak,项目名称:MIST,代码行数:34,代码来源:ReportViewer.py

示例7: DeleteObjective

    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)
开发者ID:arturochian,项目名称:MIST,代码行数:31,代码来源:PopulationData.py

示例8: ShowSimResult

 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
开发者ID:arturochian,项目名称:MIST,代码行数:8,代码来源:Project.py

示例9: OnListDblClick

    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)
开发者ID:Jacob-Barhak,项目名称:MIST,代码行数:12,代码来源:Wizard.py

示例10: DelSimResult

    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()
开发者ID:Jacob-Barhak,项目名称:MIST,代码行数:53,代码来源:ResultViewer.py

示例11: OnMenuSelected

    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) )
开发者ID:arturochian,项目名称:MIST,代码行数:50,代码来源:MISTGUI.py

示例12: OnLeftDblClick

 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)
开发者ID:arturochian,项目名称:MIST,代码行数:14,代码来源:StudyModels.py

示例13: __init__

    def __init__(self, mode=None, data=None, type=None, id_prj=0, *args, **kwds):
        """ Constructor of the MainFrame class """
        self.idPrj = id_prj

        self.ParsedStruct = data

        kwdsnew = copy.copy(kwds)
        kwdsnew["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwdsnew)

        self.pn_main = wx.Panel(self, -1)
        self.label_1 = wx.StaticText(self.pn_main, -1, "Function Type : ")
        self.cb_type = wx.ComboBox(self.pn_main, -1, choices=["Cost Wizard = Init * 10**Sum(Coefficient*Value)", "Quality of Life Wizard = Init + Sum(Coefficient*Value)"], style=wx.CB_DROPDOWN)
        self.label_2 = wx.StaticText(self.pn_main, -1, "Initial Value : ")
        self.ed_ival = wx.TextCtrl(self.pn_main, -1, "")
        self.lc_vector = cdml.List(self.pn_main, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)

        # Up/Down arrow button
        arrow_up = cdml.getSmallUpArrowBitmap() # arrow bitmap for buttons
        arrow_dn = cdml.getSmallDnArrowBitmap()
        self.btn_up = wx.BitmapButton(self.pn_main, wx.ID_ADD, arrow_up)
        self.btn_dn = wx.BitmapButton(self.pn_main, wx.ID_DELETE, arrow_dn)

        self.cc_coef = cdml.Combo(self.pn_main, -1)
        self.tc_valu = cdml.Text(self.pn_main, -1)

        self.btn_undo = wx.Button(self.pn_main, wx.ID_UNDO, "Undo")
        self.btn_ok = wx.Button(self.pn_main, wx.ID_OK, "Ok")
        self.btn_cancel = wx.Button(self.pn_main, wx.ID_CANCEL, "Cancel")

        cdml.GenerateStandardMenu(self, SkipItems = [cdml.ID_MENU_REPORT_THIS, cdml.ID_MENU_REPORT_ALL])

        self.__set_properties()
        self.__do_layout()

        

        self.btn_ok.Bind(wx.EVT_BUTTON, self.OnClose)
        self.btn_cancel.Bind(wx.EVT_BUTTON, self.OnClose)
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.cc_coef.GetTextCtrl().Bind(wx.EVT_LEFT_DCLICK, self.OnListDblClick)
        self.Bind(wx.EVT_END_PROCESS, self.OnRefresh)

        self.btn_up.Bind(wx.EVT_BUTTON, self.OnEdit)
        self.btn_dn.Bind(wx.EVT_BUTTON, self.OnEdit)
        self.btn_undo.Bind(wx.EVT_BUTTON, self.OnEdit)

        self.InitData()
开发者ID:Jacob-Barhak,项目名称:MIST,代码行数:49,代码来源:Wizard.py

示例14: ChangeSimulaionRules

    def ChangeSimulaionRules(self, event):
        """ Add/Remove simulation rules when user click up/down button"""
        id_btn = event.GetId()

        lc = getattr( self, 'tab' + str(self.curPage) + '_list' )
        index = lc.GetFirstSelected()

        try :
            list_rules = getattr(self, 'SimRule')[self.curPage]
            if id_btn == wx.ID_ADD: # UP ARROW - Add/Insert a rule
                if index == -1 : index = lc.GetItemCount()

                rule = []
                no_blank = 0
                for i in range(3):
                    cc = getattr(self, 'combo_box_'+str(i+1))
                    rule.append( str(cc.GetValueString()) )
                    if rule[i] == '' : no_blank += 1

                if no_blank == 3 : return  # no rules are set in the combo boxes

                notes = str(self.tc_notes_rule.GetValue())
                new_rule = DB.SimulationRule(rule[0], self.curPage, rule[1], rule[2], notes)


                list_rules.insert(index, new_rule)
                lc.AddItem((rule[0], rule[1], rule[2], notes, -1), index)
                # Do not clear panel so that it can be used as a clipboard
                # for copy operations. 
                #self.ClearPanel(self.panel_combo)

            else: # DOWN ARROW - Remove a rule
                if index == -1 : return

                # the new implementation is:
                # get the information from the list_rules buffer rather than
                # from the listbox in the screen. 
                cur_rule = [str(list_rules[index].AffectedParam), str(list_rules[index].OccurrenceProbability), str(list_rules[index].AppliedFormula), str(list_rules[index].Notes) ]
                for i in range(3):
                    cc = getattr(self, 'combo_box_' + str(i+1))
                    cc.GetTextCtrl().SetValue(cur_rule[i])
                self.tc_notes_rule.SetValue(cur_rule[-1])

                list_rules.pop(index)
                lc.DeleteItem(index)
                if len(list_rules) > index:
                    lc.Select(index, True)
        except:
            cdml.dlgErrorMsg(Parent = self)
开发者ID:arturochian,项目名称:MIST,代码行数:49,代码来源:Project.py

示例15: CopyProject

    def CopyProject(self):
        """ Copies project and refreshes the form accordingly with the copied Data """
        # It is assumed that the data is saved
        # Eclose the copying in a try statement just in case of an error
        copy_ok = False
        try:
            new_record = DB.Projects.Copy(self.idPrj)
            copy_ok = True
        except:
            cdml.dlgErrorMsg(Parent = self)
       
        if copy_ok:
            self.idPrj = new_record.ID
            self.Initialize()

        return copy_ok
开发者ID:arturochian,项目名称:MIST,代码行数:16,代码来源:Project.py


注:本文中的CDMLib类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。