Пример #1
0
    def __init__(self, *args, **kwds):

        # Create instance of the CDMPanel class.
        kwdsnew = copy.copy(kwds)
        kwdsnew[
            'style'] = wx.SIMPLE_BORDER | wx.TAB_TRAVERSAL  # Set the style of this RowPanel class
        cdml.CDMPanel.__init__(
            self, is_row=True, *args,
            **kwdsnew)  # Second argument should be 'True' always

        # Create variables using State class and initialize those variables
        # using initial values defined in State Class
        self.record = cdml.GetInstanceAttr(DB.State)

        # create controls
        self.btn_del = cdml.Button(
            self, wx.ID_DELETE, "x")  # Second argument should be wx.ID_DELETE
        self.st_status = wx.StaticText(self, -1, "")

        # Create controls to enter/display the variables in State object
        # For controls include text area set wx.TE_NOHIDESEL always.
        # This style need for the Find function
        self.tc_name = cdml.Text(self, -1, "", style=wx.TE_NOHIDESEL)
        self.cb_isSplit = cdml.Checkbox(self, -1, "")
        self.cb_isEvent = cdml.Checkbox(self, -1, "")
        self.cb_isTerminal = cdml.Checkbox(self, -1, "")
        self.cc_joiner_split = cdml.Combo(self,
                                          -1,
                                          validator=cdml.KeyValidator(
                                              cdml.NO_EDIT))
        self.tc_notes = cdml.Text(self,
                                  -1,
                                  "",
                                  style=wx.TE_MULTILINE | wx.TE_NOHIDESEL)
        self.lc_states = cdml.List(self,
                                   -1,
                                   style=wx.LC_REPORT | wx.SUNKEN_BORDER)
        self.cc_states = cdml.Combo(self,
                                    -1,
                                    validator=cdml.KeyValidator(cdml.NO_EDIT))

        arrow_up = cdml.getSmallUpArrowBitmap()  # arrow bitmap for buttons
        arrow_dn = cdml.getSmallDnArrowBitmap()

        # add buttons for child States
        self.btn_add_state = cdml.BitmapButton(self, -1, arrow_up)
        self.btn_del_state = cdml.BitmapButton(self, -1, arrow_dn)

        self.__set_properties()
        self.__do_layout()

        # Opening another instance of the form is currently disabled since
        # recursive opening of this form and updating a parent form according
        # to a modification performed with a child is not supported. However,
        # doing this from the list box is ok since the record is saved and
        # changing the data is not possible in the child form
        # self.cc_states.GetTextCtrl().Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDblClick)
        self.lc_states.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnLeftDblClick)
Пример #2
0
    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()
Пример #3
0
    def __init__(self, *args, **kwds):

        # Create instance of the CDMPanel class.
        kwdsnew = copy.copy(kwds)
        kwdsnew['style'] = wx.SIMPLE_BORDER | wx.TAB_TRAVERSAL              # Set the style of this RowPanel class
        cdml.CDMPanel.__init__(self, is_row = True, *args, **kwdsnew) # Second argument should be 'True' always

        # Create variables using State class and initialize those variables
        # using initial values defined in State Class
        self.record = cdml.GetInstanceAttr(DB.State)

        # create controls
        self.btn_del = cdml.Button(self, wx.ID_DELETE, "x") # Second argument should be wx.ID_DELETE
        self.st_status = wx.StaticText(self, -1, "")

        # Create controls to enter/display the variables in State object
        # For controls include text area set wx.TE_NOHIDESEL always.
        # This style need for the Find function
        self.tc_name = cdml.Text(self, -1, "", style=wx.TE_NOHIDESEL)
        self.cb_isSplit = cdml.Checkbox(self, -1, "")
        self.cb_isEvent = cdml.Checkbox(self, -1, "")
        self.cb_isTerminal = cdml.Checkbox(self, -1, "")
        self.cc_joiner_split = cdml.Combo(self, -1, validator=cdml.KeyValidator(cdml.NO_EDIT))
        self.tc_notes = cdml.Text(self, -1, "", style=wx.TE_MULTILINE|wx.TE_NOHIDESEL)
        self.lc_states = cdml.List(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
        self.cc_states = cdml.Combo(self, -1, validator=cdml.KeyValidator(cdml.NO_EDIT))

        arrow_up = cdml.getSmallUpArrowBitmap() # arrow bitmap for buttons
        arrow_dn = cdml.getSmallDnArrowBitmap()

        # add buttons for child States
        self.btn_add_state = cdml.BitmapButton(self, -1, arrow_up)
        self.btn_del_state = cdml.BitmapButton(self, -1, arrow_dn)

        self.__set_properties()
        self.__do_layout()

        # Opening another instance of the form is currently disabled since
        # recursive opening of this form and updating a parent form according
        # to a modification performed with a child is not supported. However,
        # doing this from the list box is ok since the record is saved and
        # changing the data is not possible in the child form
        # self.cc_states.GetTextCtrl().Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDblClick)
        self.lc_states.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnLeftDblClick)
Пример #4
0
    def __init__(self, mode=None, data=None, type=None, id_prj=0, *args, **kwds):
        self.idPrj = id_prj

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

        self.grid_1 = None
        
        self.pset_id = data # save the ID of parent RowPanel instance(i.e the ID of current PopulationSet)

        
        if self.pset_id == None: # If current PopulationSet is new one and wasn't saved
            title = 'Population Set : No Name'

        else: # Else display name of the PopulationSet
            CurrentName = DB.PopulationSets[self.pset_id].Name
            if mode != None and CurrentName != mode:
                CurrentName = mode +' {Edited from:' + CurrentName +'}'
            title = 'Population Set : ' + CurrentName

        # define lists for temporary Columns / Data list
        self.DataColumns = []
        self.Data = []
        self.Objectives = []
        self.HasDistribution = None

        self.idPrj = 0
        # Deine Popup menu items
        # Format : tuple of list --> ([Label, Event handler, Id] , [], [], ... )
        #           Label : label of an item
        #           Evet handler : name of event handler
        #           Id : Id of current menu item
        # Special label : '-'--> seperator, '+' --> submenu items
        #           First item after last '+' marked items is the title of the submenu
        # If an item doesn't have event handler, the second parameter should be 'None'
        # If an item doesn't have Id, the third item should be -1
        # If a form need to manage instances of RowPanel class,
        #   the event handler should be 'self.FrameEventHandler'
        # Otherwise, dedicated event handler should be implemented in that class (ex. see Project or PopulationData form)
        self.pup_menus = (  ["Undo", self.OnMenuSelected, wx.ID_UNDO ],
                            ["-" , None, -1],
                            ["Add Row" , self.OnMenuSelected, cdml.IDF_BUTTON1],
                            ["Delete Row" , self.OnMenuSelected, cdml.IDF_BUTTON2] )

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

        self.panel_1 = wx.Panel(self, -1)
        self.st_name = wx.StaticText(self.panel_1, -1, title)

        # Create Tab control for DataCulumns and Data
        self.nb = wx.Notebook(self.panel_1, -1, style=0)
        self.nb_pane_1 = wx.Panel(self.nb, 0)

        self.nb.AddPage(self.nb_pane_1, "Columns")

        self.lc_parm = cdml.List(self.nb_pane_1, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)
        self.tc_dist_text = cdml.Text(self.nb_pane_1, -1, "", style=wx.TE_NOHIDESEL)
        self.lc_dist = cdml.List(self.nb_pane_1, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)


        arrow_up = cdml.getSmallUpArrowBitmap() # arrow bitmap for buttons
        arrow_dn = cdml.getSmallDnArrowBitmap()

        self.btn_del_col = wx.BitmapButton(self.nb_pane_1, wx.ID_DELETE, arrow_dn)
        self.btn_add_col = wx.BitmapButton(self.nb_pane_1, wx.ID_ADD, arrow_up)
        self.lc_column = cdml.List(self.nb_pane_1, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)


        # Define the objective Tab
        self.nb_pane_2 = wx.Panel(self.nb, 0)
        self.nb.AddPage(self.nb_pane_2, "Objectives")

        self.st_obj_filter_expr = wx.StaticText(self.nb_pane_2, -1, "Filter Expr")
        self.st_obj_stat_expr = wx.StaticText(self.nb_pane_2, -1, "Statistics Expr")
        self.st_obj_stat_func = wx.StaticText(self.nb_pane_2, -1, "Function")
        self.st_obj_target = wx.StaticText(self.nb_pane_2, -1, "Target Value")
        self.st_obj_weight = wx.StaticText(self.nb_pane_2, -1, "Weight")

        self.tc_obj_filter_expr = cdml.Text(self.nb_pane_2, -1, "", style=wx.TE_NOHIDESEL)
        self.tc_obj_stat_expr = cdml.Text(self.nb_pane_2, -1, "", style=wx.TE_NOHIDESEL)
        self.cc_obj_stat_func = cdml.Combo(self.nb_pane_2, -1, style=wx.TE_NOHIDESEL, validator=cdml.KeyValidator(cdml.NO_EDIT))
        self.tc_obj_target = cdml.Text(self.nb_pane_2, -1, "", style=wx.TE_NOHIDESEL)
        self.tc_obj_weight = cdml.Text(self.nb_pane_2, -1, "", style=wx.TE_NOHIDESEL)


        self.btn_del_obj = wx.BitmapButton(self.nb_pane_2, cdml.IDF_BUTTON7, arrow_dn)
        self.btn_add_obj = wx.BitmapButton(self.nb_pane_2, cdml.IDF_BUTTON8, arrow_up)
        self.lc_objectives = cdml.List(self.nb_pane_2, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER)


        self.btn_import = wx.Button(self.panel_1, cdml.IDF_BUTTON2, "Import")
        self.btn_export = wx.Button(self.panel_1, cdml.IDF_BUTTON3, "Export")
        self.btn_undo = wx.Button(self.panel_1, cdml.IDF_BUTTON4, "Undo")
        self.btn_ok = wx.Button(self.panel_1, cdml.IDF_BUTTON5, "Ok")


        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_CONTEXT_MENU, self.OnPopupMenu)    # Bind event handler for right mouse click. Open Popup menu
        self.Bind(wx.EVT_CLOSE, self.OnButtonClick)
        self.Bind(wx.EVT_BUTTON, self.OnButtonClick, id=cdml.IDF_BUTTON2, id2=cdml.IDF_BUTTON6)
        self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.btn_add_col)
        self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.btn_del_col)
        self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.btn_del_obj)
        self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.btn_add_obj)
        # The next line fixes the bug of the parent window scrolling because
        # of a click in this window - focus is captured here and not
        # propagated to the parent window
        self.Bind(wx.EVT_CHILD_FOCUS, lambda Event: None)


        # closing the child parameter form triggers this
        self.Bind(wx.EVT_END_PROCESS, self.OnRefresh)

        self.lc_parm.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnLeftDblClick)
        self.lc_parm.Bind(wx.EVT_LIST_COL_CLICK, self.OnLeftDblClick)

        self.lc_dist.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnSelectDistribution)
        self.lc_dist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelectDistribution)

        self.Initialize()
Пример #5
0
    def __init__(self,
                 mode=None,
                 data=None,
                 type=None,
                 id_prj=0,
                 *args,
                 **kwds):
        self.idPrj = id_prj

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

        self.grid_1 = None

        self.pset_id = data  # save the ID of parent RowPanel instance(i.e the ID of current PopulationSet)

        if self.pset_id == None:  # If current PopulationSet is new one and wasn't saved
            title = 'Population Set : No Name'

        else:  # Else display name of the PopulationSet
            CurrentName = DB.PopulationSets[self.pset_id].Name
            if mode != None and CurrentName != mode:
                CurrentName = mode + ' {Edited from:' + CurrentName + '}'
            title = 'Population Set : ' + CurrentName

        # define lists for temporary Columns / Data list
        self.DataColumns = []
        self.Data = []
        self.Objectives = []
        self.HasDistribution = None

        self.idPrj = 0
        # Deine Popup menu items
        # Format : tuple of list --> ([Label, Event handler, Id] , [], [], ... )
        #           Label : label of an item
        #           Evet handler : name of event handler
        #           Id : Id of current menu item
        # Special label : '-'--> seperator, '+' --> submenu items
        #           First item after last '+' marked items is the title of the submenu
        # If an item doesn't have event handler, the second parameter should be 'None'
        # If an item doesn't have Id, the third item should be -1
        # If a form need to manage instances of RowPanel class,
        #   the event handler should be 'self.FrameEventHandler'
        # Otherwise, dedicated event handler should be implemented in that class (ex. see Project or PopulationData form)
        self.pup_menus = (["Undo", self.OnMenuSelected, wx.ID_UNDO], [
            "-", None, -1
        ], ["Add Row", self.OnMenuSelected, cdml.IDF_BUTTON1
            ], ["Delete Row", self.OnMenuSelected, cdml.IDF_BUTTON2])

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

        self.panel_1 = wx.Panel(self, -1)
        self.st_name = wx.StaticText(self.panel_1, -1, title)

        # Create Tab control for DataCulumns and Data
        self.nb = wx.Notebook(self.panel_1, -1, style=0)
        self.nb_pane_1 = wx.Panel(self.nb, 0)

        self.nb.AddPage(self.nb_pane_1, "Columns")

        self.lc_parm = cdml.List(self.nb_pane_1,
                                 -1,
                                 style=wx.LC_REPORT | wx.SUNKEN_BORDER)
        self.tc_dist_text = cdml.Text(self.nb_pane_1,
                                      -1,
                                      "",
                                      style=wx.TE_NOHIDESEL)
        self.lc_dist = cdml.List(self.nb_pane_1,
                                 -1,
                                 style=wx.LC_REPORT | wx.SUNKEN_BORDER)

        arrow_up = cdml.getSmallUpArrowBitmap()  # arrow bitmap for buttons
        arrow_dn = cdml.getSmallDnArrowBitmap()

        self.btn_del_col = wx.BitmapButton(self.nb_pane_1, wx.ID_DELETE,
                                           arrow_dn)
        self.btn_add_col = wx.BitmapButton(self.nb_pane_1, wx.ID_ADD, arrow_up)
        self.lc_column = cdml.List(self.nb_pane_1,
                                   -1,
                                   style=wx.LC_REPORT | wx.SUNKEN_BORDER)

        # Define the objective Tab
        self.nb_pane_2 = wx.Panel(self.nb, 0)
        self.nb.AddPage(self.nb_pane_2, "Objectives")

        self.st_obj_filter_expr = wx.StaticText(self.nb_pane_2, -1,
                                                "Filter Expr")
        self.st_obj_stat_expr = wx.StaticText(self.nb_pane_2, -1,
                                              "Statistics Expr")
        self.st_obj_stat_func = wx.StaticText(self.nb_pane_2, -1, "Function")
        self.st_obj_target = wx.StaticText(self.nb_pane_2, -1, "Target Value")
        self.st_obj_weight = wx.StaticText(self.nb_pane_2, -1, "Weight")

        self.tc_obj_filter_expr = cdml.Text(self.nb_pane_2,
                                            -1,
                                            "",
                                            style=wx.TE_NOHIDESEL)
        self.tc_obj_stat_expr = cdml.Text(self.nb_pane_2,
                                          -1,
                                          "",
                                          style=wx.TE_NOHIDESEL)
        self.cc_obj_stat_func = cdml.Combo(self.nb_pane_2,
                                           -1,
                                           style=wx.TE_NOHIDESEL,
                                           validator=cdml.KeyValidator(
                                               cdml.NO_EDIT))
        self.tc_obj_target = cdml.Text(self.nb_pane_2,
                                       -1,
                                       "",
                                       style=wx.TE_NOHIDESEL)
        self.tc_obj_weight = cdml.Text(self.nb_pane_2,
                                       -1,
                                       "",
                                       style=wx.TE_NOHIDESEL)

        self.btn_del_obj = wx.BitmapButton(self.nb_pane_2, cdml.IDF_BUTTON7,
                                           arrow_dn)
        self.btn_add_obj = wx.BitmapButton(self.nb_pane_2, cdml.IDF_BUTTON8,
                                           arrow_up)
        self.lc_objectives = cdml.List(self.nb_pane_2,
                                       -1,
                                       style=wx.LC_REPORT | wx.SUNKEN_BORDER)

        self.btn_import = wx.Button(self.panel_1, cdml.IDF_BUTTON2, "Import")
        self.btn_export = wx.Button(self.panel_1, cdml.IDF_BUTTON3, "Export")
        self.btn_undo = wx.Button(self.panel_1, cdml.IDF_BUTTON4, "Undo")
        self.btn_ok = wx.Button(self.panel_1, cdml.IDF_BUTTON5, "Ok")

        self.__set_properties()
        self.__do_layout()

        self.Bind(
            wx.EVT_CONTEXT_MENU, self.OnPopupMenu
        )  # Bind event handler for right mouse click. Open Popup menu
        self.Bind(wx.EVT_CLOSE, self.OnButtonClick)
        self.Bind(wx.EVT_BUTTON,
                  self.OnButtonClick,
                  id=cdml.IDF_BUTTON2,
                  id2=cdml.IDF_BUTTON6)
        self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.btn_add_col)
        self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.btn_del_col)
        self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.btn_del_obj)
        self.Bind(wx.EVT_BUTTON, self.OnButtonClick, self.btn_add_obj)
        # The next line fixes the bug of the parent window scrolling because
        # of a click in this window - focus is captured here and not
        # propagated to the parent window
        self.Bind(wx.EVT_CHILD_FOCUS, lambda Event: None)

        # closing the child parameter form triggers this
        self.Bind(wx.EVT_END_PROCESS, self.OnRefresh)

        self.lc_parm.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnLeftDblClick)
        self.lc_parm.Bind(wx.EVT_LIST_COL_CLICK, self.OnLeftDblClick)

        self.lc_dist.Bind(wx.EVT_LIST_ITEM_ACTIVATED,
                          self.OnSelectDistribution)
        self.lc_dist.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelectDistribution)

        self.Initialize()
Пример #6
0
    def __init__(self, mode=None, data=None, type=None, id_prj=0, *args, **kwds):

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

        self.Collection = 'Projects'

        self.idPrj = data     # Current project id.
        self.typePrj = type # Current project type.

        self.HelpContext = self.typePrj

        # List to save simulation rules at each stage
        # stage 2 doesn't have rule, but added here for indexing
        # This list is used to maintain temporary rule data before saving
        self.SimRule = [[], [], [], []]

        # Create empty class to save initial value(s) of project variables
        self.record = cdml.GetInstanceAttr(DB.Project)

        self.curCtrl = None # Current control which is selected for opening of a form
        self.curPage = 0     # Variable to save current page(i.e. tab) number
        self.openMode = mode

        # reset the override population
        self.TempOverridePopulationSet = None

        # Deine Popup menu items
        # Format : tuple of list --> ([Label, Event handler, Id] , [], [], ... )
        #           Label : label of an item
        #           Evet handler : name of event handler
        #           Id : Id of current menu item
        # Special label : '-'--> seperator, '+' --> submenu items
        #           First item after last '+' marked items is the title of the submenu
        # If an item doesn't have event handler, the second parameter should be 'None'
        # If an item doesn't have Id, the third item should be -1
        # In Project form dedicated event handler(OnMenuSelected) is being used
        # to deal with the button press event and focus change.
        self.pup_menus = (  ["Undo", self.OnUndo, wx.ID_UNDO ],
                            ["Copy Record" , self.OnMenuSelected, cdml.ID_MENU_COPY_RECORD],
                            ["Save" , self.OnMenuSelected, wx.ID_SAVE],
                            ["-" , None, -1],
                            ["Run Simulation" , self.OnMenuSelected, wx.ID_APPLY],
                            ["View Result" , self.OnMenuSelected, wx.ID_VIEW_DETAILS])

        # Define the window menus 
        cdml.GenerateStandardMenu(self, SkipItems = [cdml.ID_MENU_REPORT_ALL])

        self.panel_main = wx.Panel(self, -1)
        self.panel_common = wx.Panel(self.panel_main, -1)
        self.notebook = wx.Notebook(self.panel_main, -1, style=0)

        # title
        self.st_title = wx.StaticText(self.panel_main, -1, "Project Definition")

        # Common simulation information
        self.st_name = wx.StaticText(self.panel_common, -1, "Name : ")
        self.tc_name = cdml.Text(self.panel_common, -1, "")
        self.st_from = wx.StaticText(self.panel_common, -1, "Derived From : ")
        self.tc_from = cdml.Text(self.panel_common, -1, "", validator=cdml.KeyValidator(cdml.NO_EDIT))

        self.st_created = wx.StaticText(self.panel_common, -1, "Created On : ")
        self.tc_created = cdml.Text(self.panel_common, -1, "", validator=cdml.KeyValidator(cdml.NO_EDIT))
        self.st_modified = wx.StaticText(self.panel_common, -1, "Last Modified : ")
        self.tc_modified = cdml.Text(self.panel_common, -1, "", validator=cdml.KeyValidator(cdml.NO_EDIT))
        self.st_notes = wx.StaticText(self.panel_common, -1, "Notes : ")
        self.tc_notes = cdml.Text(self.panel_common, -1, "", style = wx.TE_MULTILINE)

        # reserved for future extension

        arrow_up = cdml.getSmallUpArrowBitmap() # arrow bitmap for buttons
        arrow_dn = cdml.getSmallDnArrowBitmap()

        self.btn_save = wx.Button(self.panel_main, wx.ID_SAVE)
        self.btn_copy = wx.Button(self.panel_main, cdml.ID_MENU_COPY_RECORD, "Copy")
        self.btn_undo = wx.Button(self.panel_main, wx.ID_UNDO)

        # simulation conditions
        self.panel_sim = wx.Panel(self.panel_main, -1)
        self.st_pset = wx.StaticText(self.panel_sim, -1, "Population Set : ")
        self.cc_pset = cdml.Combo(self.panel_sim, cdml.IDF_BUTTON1, validator=cdml.KeyValidator(cdml.NO_EDIT))
        self.st_simsteps = wx.StaticText(self.panel_sim, -1, "No. of Simulation Steps : ")
        self.tc_simsteps = cdml.Text(self.panel_sim, -1, "")
        self.st_model = wx.StaticText(self.panel_sim, -1, "Primary Model : ")
        self.cc_model = cdml.Combo(self.panel_sim, cdml.IDF_BUTTON2, validator=cdml.KeyValidator(cdml.NO_EDIT))
        self.st_repet = wx.StaticText(self.panel_sim, -1, "No. of Repetitions : ")
        self.tc_repet = cdml.Text(self.panel_sim, -1, "")

        self.btn_ed_pset = wx.Button(self.panel_sim, cdml.IDF_BUTTON3, "...")
        self.btn_ed_model = wx.Button(self.panel_sim, cdml.IDF_BUTTON4, "...")

        self.btn_run = wx.Button(self.panel_sim, wx.ID_APPLY, "Run Simulation")
        self.btn_result = wx.Button(self.panel_sim, wx.ID_VIEW_DETAILS, "View Result")
        self.btn_delete = wx.Button(self.panel_sim, wx.ID_CLEAR, "Delete Results")


        # create tabs for simulation stage
        self.nb_pane_0 = wx.Panel(self.notebook, 0)
        self.nb_pane_1 = wx.Panel(self.notebook, 1)
        self.nb_pane_2 = wx.Panel(self.notebook, 2)
        self.nb_pane_3 = wx.Panel(self.notebook, 3)

        
        # simulation stage 0 : initialization
        self.tab0_label = wx.StaticText(self.nb_pane_0, -1, "Initialize the simulation")
        self.tab0_list = cdml.List(self.nb_pane_0, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_SINGLE_SEL)

        # simulation stage 1 - Pre state transition
        self.tab1_label = wx.StaticText(self.nb_pane_1, -1, "Pre-State Transition Rules")
        self.tab1_list = cdml.List(self.nb_pane_1, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_SINGLE_SEL)

        # simulation stage 2
        self.tab2_label = wx.StaticText(self.nb_pane_2, -1, "Execute state transitions according to the primary model:", style=wx.ALIGN_CENTRE)
        self.tab2_st_model = wx.StaticText(self.nb_pane_2, -1, "")
        self.tab2_st_TraceBack = wx.StaticText(self.nb_pane_2, -1, "Pickled TraceBack Information for Reproducing simulation")
        self.tab2_tc_TraceBack = cdml.Text(self.nb_pane_2, -1, "", style = wx.TE_MULTILINE)
     
        # show the TraceBack fields only in Admin mode
        TraceBackIsVisible = cdml.GetAdminMode()
        self.tab2_st_TraceBack.Show(TraceBackIsVisible)
        self.tab2_tc_TraceBack.Show(TraceBackIsVisible)


        # simulation stage 3 - Post state transition
        self.tab3_label = wx.StaticText(self.nb_pane_3, -1, "Post-State Transition Rules")
        self.tab3_list = cdml.List(self.nb_pane_3, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_SINGLE_SEL)


        # combo boxes
        self.panel_combo = wx.Panel(self.panel_main, -1)
        self.label_1 = wx.StaticText(self.panel_combo, -1, "Parameter")
        self.label_2 = wx.StaticText(self.panel_combo, -1, "Occurrence Probability")
        self.label_3 = wx.StaticText(self.panel_combo, -1, "Function")
        self.label_4 = wx.StaticText(self.panel_combo, -1, "Notes")

        self.combo_box_1 = cdml.Combo(self.panel_combo, cdml.IDP_BUTTON1)
        self.combo_box_2 = cdml.Combo(self.panel_combo, cdml.IDP_BUTTON2)
        self.combo_box_2.AllowInput = True
        self.combo_box_3 = cdml.Combo(self.panel_combo, cdml.IDP_BUTTON3)
        self.combo_box_3.AllowInput = True
        self.tc_notes_rule = cdml.Text(self.panel_combo, cdml.IDP_BUTTON4)


        # Up/Down arrow button, Cost and QoL Wizard button
        self.btn_up = wx.BitmapButton(self.panel_combo, wx.ID_ADD, arrow_up)
        self.btn_dn = wx.BitmapButton(self.panel_combo, wx.ID_DELETE, arrow_dn)


        # Bind common event handler for Project form
        self.Bind(wx.EVT_CONTEXT_MENU, self.OnPopupMenu) # Dedicated event handler for popup menu
        self.Bind(wx.EVT_CLOSE, self.OnMenuSelected)
        self.Bind(wx.EVT_END_PROCESS, self.OnRefresh)

        self.btn_save.Bind(wx.EVT_BUTTON, self.OnMenuSelected)
        self.btn_copy.Bind(wx.EVT_BUTTON, self.OnMenuSelected)
        self.btn_undo.Bind(wx.EVT_BUTTON, self.OnUndo)

        self.notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)

        self.btn_up.Bind(wx.EVT_BUTTON, self.ChangeSimulaionRules)
        self.btn_dn.Bind(wx.EVT_BUTTON, self.ChangeSimulaionRules)

        self.btn_run.Bind(wx.EVT_BUTTON, self.OnMenuSelected)
        self.btn_result.Bind(wx.EVT_BUTTON, self.OnMenuSelected)
        self.btn_delete.Bind(wx.EVT_BUTTON, self.OnMenuSelected)

        self.btn_ed_pset.Bind(wx.EVT_BUTTON, self.OnLeftDblClick)
        self.btn_ed_model.Bind(wx.EVT_BUTTON, self.OnLeftDblClick)

        self.cc_pset.GetTextCtrl().Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDblClick)
        self.cc_model.GetTextCtrl().Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDblClick)

        self.combo_box_1.GetTextCtrl().Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDblClick)
        self.combo_box_2.GetTextCtrl().Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDblClick)
        self.combo_box_3.GetTextCtrl().Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDblClick)
        self.tc_notes_rule.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDblClick)

        self.__set_properties()
        self.__do_layout()

        # This method is different from the Initialize method of CDMFrame class
        # It is implemented in this module
        self.Initialize()
Пример #7
0
    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()