示例#1
0
    def __init__(self, *args, **kwds):
        """ Constructor of RowPanel class"""

        kwdsnew = copy.copy(kwds)
        kwdsnew['style'] = wx.SIMPLE_BORDER | wx.TAB_TRAVERSAL
        cdml.CDMPanel.__init__(self, True, *args, **kwdsnew)  # initialize

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

        # Create temporary variable to keep input for DataColumns and Data
        self.DataColumns = []
        self.Data = []
        self.Objectives = []

        # Add Button and StaticText for deletion and status display
        self.btn_del = cdml.Button(self,
                                   wx.ID_DELETE,
                                   "x",
                                   style=wx.BU_EXACTFIT)
        self.st_status = wx.StaticText(self, -1, " ")

        # Create controls to enter/display the variables in Transition 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.tc_definitiontype = cdml.Text(self,
                                           -1,
                                           "",
                                           style=wx.TE_NOHIDESEL,
                                           validator=cdml.KeyValidator(
                                               cdml.NO_EDIT))
        self.tc_source = cdml.Text(self, -1, "", style=wx.TE_NOHIDESEL)
        # keep the derived from status in addition to the text box
        self.DerivedFrom = 0
        self.tc_derived = cdml.Text(self,
                                    -1,
                                    "",
                                    style=wx.TE_NOHIDESEL,
                                    validator=cdml.KeyValidator(cdml.NO_EDIT))
        self.tc_created = cdml.Text(self,
                                    -1,
                                    "",
                                    validator=cdml.KeyValidator(cdml.NO_INPUT))
        self.tc_modified = cdml.Text(self,
                                     -1,
                                     "",
                                     validator=cdml.KeyValidator(
                                         cdml.NO_INPUT))
        self.tc_notes = cdml.Text(self,
                                  -1,
                                  "",
                                  style=wx.TE_MULTILINE | wx.TE_NOHIDESEL)

        #self.btn_copy = cdml.Button(self, cdml.IDP_BUTTON1, "Copy")
        self.btn_data = cdml.Button(self, cdml.IDP_BUTTON3, "Data")

        self.__set_properties()
        self.__do_layout()
示例#2
0
文件: States.py 项目: ilanderma/MIST
    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)
示例#3
0
    def __init__(self, *args, **kwds):
        """ Constructor of RowPanel class """

        kwdsnew = copy.copy(kwds)
        kwdsnew[
            "style"] = wx.SIMPLE_BORDER | wx.TAB_TRAVERSAL  # Set the style of RowPanel class
        cdml.CDMPanel.__init__(
            self, True, *args, **kwdsnew
        )  # Second parameter should be True always for any RowPanel class

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

        # Button and hidden StaticText to display panel status
        self.btn_del = cdml.Button(self,
                                   wx.ID_DELETE,
                                   "x",
                                   style=wx.BU_EXACTFIT)
        self.st_status = wx.StaticText(self, -1, " ")

        # Create controls to enter/display the variables in Transition 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.tc_formula = cdml.Text(self,
                                    -1,
                                    "",
                                    style=wx.TE_MULTILINE | wx.TE_NOHIDESEL)
        self.cc_type = cdml.Combo(self,
                                  -1,
                                  style=wx.TE_NOHIDESEL,
                                  validator=cdml.KeyValidator(cdml.NO_EDIT))
        self.tc_rule_parm = cdml.Text(self, -1, "", style=wx.TE_NOHIDESEL)
        self.tc_notes = cdml.Text(self,
                                  -1,
                                  "",
                                  style=wx.TE_MULTILINE | wx.TE_NOHIDESEL)

        self.__set_properties()
        self.__do_layout()
示例#4
0
文件: States.py 项目: ilanderma/MIST
    def __init__(self,
                 mode=None,
                 data=None,
                 type=None,
                 id_prj=0,
                 *args,
                 **kwds):
        """ Constructor of the MainFrame class """
        self.idPrj = id_prj
        cdml.CDMFrame.__init__(self, mode, data, type, *args, **kwds)

        # Define Popup menu items
        # Format : tuple of list --> ([Label, Event handler, Id] , [], [], ... )
        #                       Label : label of an item
        #                       Event handler : name of event handler
        #                       Id : Id of current menu item
        # Special label : '-'--> separator, '+' --> 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.FrameEventHandler, wx.ID_UNDO], [
            "-", None, -1
        ], ["Add", self.FrameEventHandler, wx.ID_ADD], [
            "Copy Record", self.FrameEventHandler, cdml.ID_MENU_COPY_RECORD
        ], ["Delete", self.FrameEventHandler, wx.ID_DELETE], ["-", None, -1], [
            "Find", self.FrameEventHandler, wx.ID_FIND
        ], ["-",
            None, -1], ["+Name", self.FrameEventHandler, cdml.IDF_BUTTON1], [
                "+IsSplit", self.FrameEventHandler, cdml.IDF_BUTTON2
            ], ["+IsEvent", self.FrameEventHandler, cdml.IDF_BUTTON3
                ], ["+IsTemplate", self.FrameEventHandler, cdml.IDF_BUTTON4], [
                    "+Joiner Of Splitter", self.FrameEventHandler,
                    cdml.IDF_BUTTON5
                ], ["+Notes", self.FrameEventHandler,
                    cdml.IDF_BUTTON6], ["Sort By", None, -1])

        # Define the window menus
        cdml.GenerateStandardMenu(self)

        # create panels for title section. First argument should be False
        self.pn_title = cdml.CDMPanel(False, self, -1)

        # Create bitmap buttons to display title of each field
        # Syntax : cdml.BitmapButton( parent, id, bitmap, label )
        # Don't need to set bitmap here. It will be assigned in the event handler when pressed
        # For the sort function, the labels need to be same with the variable name in database object
        self.st_title = wx.StaticText(self.pn_title, -1, "State Definition")
        self.st_name = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON1, None,
                                         "Name  ")
        self.st_isSplit = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON2,
                                            None, "Is Split   ")
        self.st_isEvent = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON3,
                                            None, "Is Event   ")
        self.st_isTerminal = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON4,
                                               None, "Is Terminal")
        self.st_joins_split = cdml.BitmapButton(self.pn_title,
                                                cdml.IDF_BUTTON5, None,
                                                "Joiner Of Splitter")
        self.st_notes = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON6,
                                          None, "Notes")
        self.st_child_state = cdml.BitmapButton(self.pn_title, -1, None,
                                                "Child State/ Subprocess")

        # Create Add/Find buttons
        # Syntax : cdml.Button( parent, ID )
        # ID should be wx.ID_ADD for add button and wx.ID_FIND for find button in all forms
        self.btn_add = cdml.Button(self.pn_title, wx.ID_ADD)
        self.btn_find = cdml.Button(self.pn_title, wx.ID_FIND)

        # Scroll window that the RowPanel objects will be placed
        # IMPORTANT NOTE:
        #       In current version, all forms that need to manage the instance(s) of RowPanel class
        #               should have an instance of wx.ScrolledWindow class.
        #       Also the name of the panel should be "pn_view"
        self.pn_view = wx.ScrolledWindow(self,
                                         -1,
                                         style=wx.SUNKEN_BORDER
                                         | wx.TAB_TRAVERSAL)

        self.__set_properties()
        self.__do_layout()

        # Assign event handler for the buttons in title section -- to check the focus change
        self.pn_title.Bind(wx.EVT_BUTTON,
                           self.FrameEventHandler,
                           id=cdml.IDF_BUTTON1,
                           id2=cdml.IDF_BUTTON6)
        self.btn_add.Bind(wx.EVT_BUTTON, self.FrameEventHandler)
        self.btn_find.Bind(wx.EVT_BUTTON, self.FrameEventHandler)

        # Call Initialize method to create row panels and display data
        self.Initialize()
示例#5
0
文件: MISTGUI.py 项目: ilanderma/MIST
    def __init__(self, *args, **kwds):

        self._db_opened = False  # state variables to check
        self._path = None  # path that database(zip file) exists
        self.curPrj = None  # variable to maintain opened project form

        kwdsnew = copy.copy(kwds)
        kwdsnew["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args,
                          **kwdsnew)  # In Main form, wx.Frame class is used
        # because this form don't need to check the focus change

        self.HelpContext = 'Main'

        # 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 = ([
            "Delete Record", self.OnMenuSelected, cdml.ID_MENU_DELETE_RECORD
        ], ["-", None, -1
            ], ["Copy Record", self.OnMenuSelected, cdml.ID_MENU_COPY_RECORD])

        # Menu Bar
        self.menubar = wx.MenuBar()
        self.SetMenuBar(self.menubar)

        # File Menu
        self.MenuBarFile = wx.Menu()  # Create 'File' menu

        # Add File menu items
        self.MenuItemNew = wx.MenuItem(self.MenuBarFile, wx.ID_NEW, "&New", "",
                                       wx.ITEM_NORMAL)
        self.MenuBarFile.AppendItem(self.MenuItemNew)
        self.MenuItemOpen = wx.MenuItem(self.MenuBarFile, wx.ID_OPEN, "&Open",
                                        "", wx.ITEM_NORMAL)
        self.MenuBarFile.AppendItem(self.MenuItemOpen)
        self.MenuItemSave = wx.MenuItem(self.MenuBarFile, wx.ID_SAVE, "&Save",
                                        "", wx.ITEM_NORMAL)
        self.MenuBarFile.AppendItem(self.MenuItemSave)
        self.MenuItemSaveAs = wx.MenuItem(self.MenuBarFile, wx.ID_SAVEAS,
                                          "Save &As", "", wx.ITEM_NORMAL)
        self.MenuBarFile.AppendItem(self.MenuItemSaveAs)
        self.MenuBarFile.AppendSeparator()
        self.MenuItemReportThis = wx.MenuItem(self.MenuBarFile,
                                              cdml.ID_MENU_REPORT_THIS,
                                              "Sing&le Report", "",
                                              wx.ITEM_NORMAL)
        self.MenuBarFile.AppendItem(self.MenuItemReportThis)
        self.MenuItemReportAll = wx.MenuItem(self.MenuBarFile,
                                             cdml.ID_MENU_REPORT_ALL,
                                             "&Report All", "", wx.ITEM_NORMAL)
        self.MenuBarFile.AppendItem(self.MenuItemReportAll)
        self.MenuBarFile.AppendSeparator()
        self.MenuItemExit = wx.MenuItem(self.MenuBarFile, wx.ID_EXIT, "E&xit",
                                        "", wx.ITEM_NORMAL)
        self.MenuBarFile.AppendItem(self.MenuItemExit)
        self.menubar.Append(self.MenuBarFile, "&File")

        # Data Menu
        self.MenuBarForms = wx.Menu()

        # Add Data menu items
        self.MenuItemStates = wx.MenuItem(self.MenuBarForms, cdml.IDF_BUTTON1,
                                          "States", "", wx.ITEM_NORMAL)
        self.MenuBarForms.AppendItem(self.MenuItemStates)
        self.MenuItemStudy = wx.MenuItem(self.MenuBarForms, cdml.IDF_BUTTON4,
                                         "Model", "", wx.ITEM_NORMAL)
        self.MenuBarForms.AppendItem(self.MenuItemStudy)
        self.MenuItemTransition = wx.MenuItem(self.MenuBarForms,
                                              cdml.IDF_BUTTON3,
                                              "Transitions / Probabilities",
                                              "", wx.ITEM_NORMAL)
        self.MenuBarForms.AppendItem(self.MenuItemTransition)
        self.MenuItemPopulation = wx.MenuItem(self.MenuBarForms,
                                              cdml.IDF_BUTTON5, "Populations",
                                              "", wx.ITEM_NORMAL)
        self.MenuBarForms.AppendItem(self.MenuItemPopulation)
        self.MenuItemParameters = wx.MenuItem(self.MenuBarForms,
                                              cdml.IDF_BUTTON6, "Parameters",
                                              "", wx.ITEM_NORMAL)
        self.MenuBarForms.AppendItem(self.MenuItemParameters)
        self.menubar.Append(self.MenuBarForms, "F&orms")

        #  Menu
        self.MenuBarHelp = wx.Menu()

        # Add Help menu items
        self.MenuItemHelp = wx.MenuItem(self.MenuBarHelp, cdml.ID_MENU_HELP,
                                        "&Help", "", wx.ITEM_NORMAL)
        self.MenuBarHelp.AppendItem(self.MenuItemHelp)
        self.MenuItemHelpGeneral = wx.MenuItem(self.MenuBarHelp,
                                               cdml.ID_MENU_HELP_GENERAL,
                                               "&General Help", "",
                                               wx.ITEM_NORMAL)
        self.MenuBarHelp.AppendItem(self.MenuItemHelpGeneral)
        self.MenuBarFile.AppendSeparator()
        self.MenuItemAbout = wx.MenuItem(self.MenuBarHelp, cdml.ID_MENU_ABOUT,
                                         "&About", "", wx.ITEM_NORMAL)
        self.MenuBarHelp.AppendItem(self.MenuItemAbout)
        self.menubar.Append(self.MenuBarHelp, "&Help")
        # Menu Bar end

        self.st_title = wx.StaticText(self, -1,
                                      ' ' * 50 + "MIcroSimulation Tool (MIST)")
        self.btn_state = cdml.Button(self, cdml.IDF_BUTTON1, "States")
        self.btn_study_model = cdml.Button(self, cdml.IDF_BUTTON4, "Models")
        self.btn_trans = cdml.Button(self, cdml.IDF_BUTTON3,
                                     "Transitions / Probabilities")
        self.btn_pset = cdml.Button(self, cdml.IDF_BUTTON5, "Populations")
        self.btn_params = cdml.Button(self, cdml.IDF_BUTTON6, "Parameters")

        self.lc_project = cdml.List(self,
                                    -1,
                                    style=wx.LC_REPORT | wx.SUNKEN_BORDER
                                    | wx.LC_SINGLE_SEL)

        # Now that the list exists we can init the other base class,
        # see wx/lib/mixins/listctrl.py
        self.itemDataMap = {}
        self.IndexToPID = {}
        listmix.ColumnSorterMixin.__init__(self, 4)

        # assign event handlers
        #self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
        self.Bind(wx.EVT_CLOSE, self.OnExit)
        self.Bind(wx.EVT_MENU, self.OnMenuSelected, self.MenuItemNew)
        self.Bind(wx.EVT_MENU, self.OnMenuSelected, self.MenuItemOpen)
        self.Bind(wx.EVT_MENU, self.OnMenuSelected, self.MenuItemSave)
        self.Bind(wx.EVT_MENU, self.OnMenuSelected, self.MenuItemSaveAs)
        self.Bind(wx.EVT_MENU, self.OnExit, self.MenuItemExit)
        self.Bind(wx.EVT_MENU, self.OnMenuSelected, self.MenuItemReportThis)
        self.Bind(wx.EVT_MENU, self.OnMenuSelected, self.MenuItemReportAll)
        self.Bind(wx.EVT_MENU, self.OnMenuSelected, self.MenuItemHelp)
        self.Bind(wx.EVT_MENU, self.OnMenuSelected, self.MenuItemHelpGeneral)
        self.Bind(wx.EVT_MENU, self.OnMenuSelected, self.MenuItemAbout)
        self.Bind(wx.EVT_MENU,
                  self.OnMenuSelected,
                  id=cdml.IDF_BUTTON1,
                  id2=cdml.IDF_BUTTON6)
        self.Bind(wx.EVT_BUTTON,
                  self.OnMenuSelected,
                  id=cdml.IDF_BUTTON1,
                  id2=cdml.IDF_BUTTON6)
        self.Bind(wx.EVT_CONTEXT_MENU,
                  self.OnPopupMenu)  # Dedicated event handler for popup menu
        self.lc_project.Bind(wx.EVT_KEY_DOWN, self.OnKeyUp)
        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnListDClick,
                  self.lc_project)

        # Bind special event to refresh project refresh
        # This event handler is called by Project form
        self.Bind(wx.EVT_END_PROCESS, self.RefreshEvent)

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

        cdml.CDMFrame.__init__(self, mode, data, type, *args, **kwds)

        # 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.FrameEventHandler, wx.ID_UNDO], [
            "-", None, -1
        ], ["Add", self.FrameEventHandler, wx.ID_ADD], [
            "Copy Record", self.FrameEventHandler, cdml.ID_MENU_COPY_RECORD
        ], ["Delete", self.FrameEventHandler, wx.ID_DELETE], [
            "Regenerate New Population Data from a Distribution",
            self.FrameEventHandler, cdml.ID_SPECIAL_RECORD_ADD
        ], ["-", None, -1], ["Find", self.FrameEventHandler, wx.ID_FIND], [
            "-", None, -1
        ], ["+ID", self.FrameEventHandler, cdml.IDF_BUTTON1], [
            "+Name", self.FrameEventHandler, cdml.IDF_BUTTON2
        ], ["+Source", self.FrameEventHandler, cdml.IDF_BUTTON3], [
            "+Definition Type", self.FrameEventHandler, cdml.IDF_BUTTON4
        ], ["+Derived From", self.FrameEventHandler, cdml.IDF_BUTTON5], [
            "+Read Only", self.FrameEventHandler, cdml.IDF_BUTTON6
        ], ["+Created On", self.FrameEventHandler, cdml.IDF_BUTTON7
            ], ["+Last Modified", self.FrameEventHandler, cdml.IDF_BUTTON8],
                          ["+Notes", self.FrameEventHandler,
                           cdml.IDF_BUTTON9], ["Sort By", None, -1])

        # Define the window menus
        cdml.GenerateStandardMenu(self)

        # create panel for field titles
        # IMPORTANT NOTE:
        #   In current version, name of a panel for the title section should be "pn_title"
        #   And should be an instance of CDMPanel class with False as a first argument
        self.pn_title = cdml.CDMPanel(False, self, -1, style=wx.TAB_TRAVERSAL)
        self.st_title = wx.StaticText(self.pn_title, -1, "Population Sets")

        # Create bitmap buttons to display title of each field
        # Syntax : cdml.BitmapButton( parent, id, bitmap, label )
        # Don't need to set bitmap here. It will be assigned in the event handler when pressed
        # For the sort function, the labels need to be same with the variable name in database object
        self.button_2 = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON2,
                                          None, "Name")
        self.button_3 = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON3,
                                          None, "Source")
        self.button_4 = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON4,
                                          None, "Definition Type")
        self.button_5 = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON5,
                                          None, "Derived From")
        self.button_6 = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON7,
                                          None, "Created On")
        self.button_7 = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON10,
                                          None, "Last Modified")
        self.button_8 = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON11,
                                          None, "Notes")

        # Create Add/Find buttons
        # Syntax : cdml.Button( parent, ID )
        # ID should be wx.ID_ADD for add button and wx.ID_FIND for find button in all forms
        self.btn_add = cdml.Button(self.pn_title, wx.ID_ADD)
        self.btn_find = cdml.Button(self.pn_title, wx.ID_FIND)

        # Scroll window that the RowPanel objects will be placed
        # IMPORTANT NOTE:
        #   In current version, all forms that need to manage the instance(s) of RowPanel class
        #       should have an instance of wx.ScrolledWindow class.
        #   Also the name of the panel should be "pn_view"
        self.pn_view = wx.ScrolledWindow(self,
                                         -1,
                                         style=wx.SUNKEN_BORDER
                                         | wx.TAB_TRAVERSAL)

        self.__set_properties()
        self.__do_layout()

        # Assign event handler for the buttons in title section -- to check the focus change
        self.pn_title.Bind(wx.EVT_BUTTON,
                           self.FrameEventHandler,
                           id=cdml.IDF_BUTTON2,
                           id2=cdml.IDF_BUTTON9)
        self.btn_add.Bind(wx.EVT_BUTTON, self.FrameEventHandler)
        self.btn_find.Bind(wx.EVT_BUTTON, self.FrameEventHandler)

        self.Initialize()
示例#7
0
    def __init__(self, id_model, *args, **kwds):
        """ Constructor of RowPanel class """

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

        # Use userData to save ID of Study/Model
        self.userData = id_model

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

        # Button and hidden StaticText to display panel status
        self.btn_del = cdml.Button(self,
                                   wx.ID_DELETE,
                                   "x",
                                   style=wx.BU_EXACTFIT)
        self.st_status = wx.StaticText(self, -1, " ")

        # Create controls to enter/display the variables in Transition object
        # For controls include text area set wx.TE_NOHIDESEL always.
        # This style need for the Find function
        self.cc_state_from = cdml.Combo(self,
                                        cdml.IDP_BUTTON1,
                                        style=wx.TE_NOHIDESEL,
                                        validator=cdml.KeyValidator(
                                            cdml.NO_EDIT))
        self.cc_state_to = cdml.Combo(self,
                                      cdml.IDP_BUTTON2,
                                      style=wx.TE_NOHIDESEL,
                                      validator=cdml.KeyValidator(
                                          cdml.NO_EDIT))

        self.tc_probability = cdml.Text(self,
                                        cdml.IDP_BUTTON3,
                                        '',
                                        style=wx.TE_NOHIDESEL
                                        | wx.TE_MULTILINE)

        self.tc_notes = cdml.Text(self,
                                  -1,
                                  "",
                                  style=wx.TE_NOHIDESEL | wx.TE_MULTILINE)

        self.__set_properties()
        self.__do_layout()

        # Bind an event handler to check/display formulae for the parameters
        # self.Bind(wx.EVT_IDLE, self.CheckFormula)

        # To modify the state and parameters, assign event handles for some controls
        # Because focus management isn't need for the modification,
        # event handlers are assigned directly to the controls instead of the FrameEventHandler method in CDMFrame class
        #self.cc_state_from.GetTextCtrl().Bind(wx.EVT_LEFT_DCLICK, self.OnButtonDblClick )
        #self.cc_state_to.GetTextCtrl().Bind(wx.EVT_LEFT_DCLICK, self.OnButtonDblClick )
        self.tc_probability.Bind(wx.EVT_LEFT_DCLICK, self.OnButtonDblClick)
示例#8
0
    def __init__(self,
                 mode=None,
                 data=None,
                 type=None,
                 id_prj=0,
                 *args,
                 **kwds):
        """ Constructor of the MainFrame class """
        self.idPrj = id_prj

        cdml.CDMFrame.__init__(self, mode, data, type, *args, **kwds)

        # Deine Popup menu items
        # Format : tuple of list --> ([Label, Event handler, Id] , [], [], ... )
        #           Label : label of an item
        #           Event handler : name of event handler
        #           Id : Id of current menu item
        # Special label : '-'--> separator, '+' --> 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.FrameEventHandler, wx.ID_UNDO], [
            "-", None, -1
        ], ["Add", self.FrameEventHandler,
            wx.ID_ADD], ["Delete", self.FrameEventHandler, wx.ID_DELETE], [
                "-", None, -1
            ], ["Find", self.FrameEventHandler, wx.ID_FIND], ["-", None, -1], [
                "+From State",
                self.FrameEventHandler, cdml.IDF_BUTTON4
            ], ["+To State", self.FrameEventHandler, cdml.IDF_BUTTON5
                ], ["+Probability", self.FrameEventHandler,
                    cdml.IDF_BUTTON6], ["Sort By", None, -1])

        # Define the window menus
        cdml.GenerateStandardMenu(self)

        # create panel for field titles
        # IMPORTANT NOTE:
        #   In current version, name of a panel for the title section should be "pn_title"
        #   And should be an instance of CDMPanel class with False as a first argument
        self.pn_title = cdml.CDMPanel(False, self, -1)
        self.st_title = wx.StaticText(self.pn_title, -1,
                                      "Transitions Between States in a Model")

        # Create text and combo control to display the list of studies and models
        # Due to this controls, two step initialization need to be implemented for Transition form
        # --> transition list could be set up after selecting a study or model using this combo control
        self.st_study_model = wx.StaticText(self.pn_title, -1, "Model")
        self.cc_study_model = cdml.Combo(self.pn_title,
                                         validator=cdml.KeyValidator(
                                             cdml.NO_EDIT))

        # Create bitmap buttons to display title of each field
        # Syntax : cdml.BitmapButton( parent, id, bitmap, label )
        # Don't need to set bitmap here. It will be assigned in the event handler when pressed
        # For the sort function, the labels need to be same with the variable name in database object
        self.button_1 = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON1,
                                          None, "From State")
        self.button_2 = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON2,
                                          None, "To State")
        self.button_3 = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON3,
                                          None, "Probability")
        self.button_4 = cdml.BitmapButton(self.pn_title, cdml.IDF_BUTTON8,
                                          None, "Notes")

        # Create Add/Find buttons
        # Syntax : cdml.Button( parent, ID )
        # ID should be wx.ID_ADD for add button and wx.ID_FIND for find button in all forms
        self.btn_add = cdml.Button(self.pn_title, wx.ID_ADD)
        self.btn_find = cdml.Button(self.pn_title, wx.ID_FIND)
        self.btn_copy_from_model = cdml.Button(self.pn_title,
                                               cdml.IDF_BUTTON11,
                                               'Copy From Model')

        # Scroll window that the RowPanel objects will be placed
        # IMPORTANT NOTE:
        #   In current version, all forms that need to manage the instance(s) of RowPanel class
        #       should have an instance of wx.ScrolledWindow class.
        #   Also the name of the panel should be "pn_view"
        self.pn_view = wx.ScrolledWindow(self,
                                         -1,
                                         style=wx.SUNKEN_BORDER
                                         | wx.TAB_TRAVERSAL)

        self.__set_properties()
        self.__do_layout()

        # Assign event handler for the buttons in title section -- to check the focus change
        self.pn_title.Bind(wx.EVT_BUTTON,
                           self.FrameEventHandler,
                           id=cdml.IDF_BUTTON1,
                           id2=cdml.IDF_BUTTON8)
        self.btn_add.Bind(wx.EVT_BUTTON, self.FrameEventHandler)
        self.btn_find.Bind(wx.EVT_BUTTON, self.FrameEventHandler)
        self.btn_copy_from_model.Bind(
            wx.EVT_BUTTON, self.CopyTransitionsFromAnotherStudyModel)

        self.cc_study_model.Bind(wx.EVT_LEFT_UP, self.FrameEventHandler)
        self.cc_study_model.GetTextCtrl().Bind(wx.EVT_LEFT_UP,
                                               self.FrameEventHandler)
        # The next line was commented since it worked fine on windows yet did
        # not work on a Linux system. Therefore instead of handling the mouse
        # click we are looking at the selection of the item form the list. For
        # some reason this forces repainting of the screen. Yet since it works
        # on both Linux and Windows, this solution was a compromise
        # self.cc_study_model.Bind(wx.EVT_COMMAND_LEFT_CLICK, self.FrameEventHandler)
        self.cc_study_model.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                 self.InitTransitions)

        self.InitTransitions()  # display existing data
示例#9
0
    def __init__(self, *args, **kwds):
        """ Constructor of RowPanel class """

        # 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 StudyModel class and initialize those variables
        # using initial values defined in StudyModel Class
        self.record = cdml.GetInstanceAttr(DB.StudyModel)

        # Create controls for each field in database
        # All controls are derived from controls in wxPython for CDM Project
        # Naming convention :
        # self.btn_ : Button or BitmapButton
        # self.cc_  : Combo control
        # self.lc_  : List control
        # self.tc_  : Text control
        # self.st_  : Static Text
        # self.cb_  : Checkbox

        # Button and hidden StaticText to display panel status
        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 StudyModel object
        # For controls include text area set wx.TE_NOHIDESEL always.
        # This style need for the Find function
        # wx.TE_MULTILINE means multi line text control
        self.tc_name = cdml.Text(self,
                                 -1,
                                 "",
                                 style=wx.TE_MULTILINE | wx.TE_NOHIDESEL)

        # Add validator to prevent certain type of keyboard input
        # Following line shows how to prevent string input (i.e. only allow numbers in this control)

        self.cc_main_proc = cdml.Combo(self,
                                       style=wx.TE_NOHIDESEL,
                                       validator=cdml.KeyValidator(
                                           cdml.NO_EDIT))

        # Following two lines show how to prevent keyboard input
        self.tc_created = cdml.Text(self,
                                    -1,
                                    "",
                                    validator=cdml.KeyValidator(cdml.NO_INPUT))
        self.tc_modified = cdml.Text(self,
                                     -1,
                                     "",
                                     validator=cdml.KeyValidator(
                                         cdml.NO_INPUT))

        self.DerivedFrom = 0
        self.tc_from = cdml.Text(self,
                                 -1,
                                 style=wx.TE_NOHIDESEL,
                                 validator=cdml.KeyValidator(cdml.NO_EDIT))
        self.tc_notes = cdml.Text(self,
                                  -1,
                                  "",
                                  style=wx.TE_MULTILINE | wx.TE_NOHIDESEL)

        self.btn_trans = cdml.Button(self, cdml.IDP_BUTTON1, "Transitions")
        #self.btn_copy = cdml.Button(self, cdml.IDP_BUTTON2, "Copy")

        # To modify the MainProcess, assign event handles for the combo control
        # Because modification will be done in the 'States' form (i.e. don't need to check the focus change ),
        # event handlers are assigned directly to the controls instead of the FrameEventHandler method in CDMFrame class
        self.cc_main_proc.GetTextCtrl().Bind(wx.EVT_LEFT_DCLICK,
                                             self.OnLeftDblClick)

        self.__set_properties()
        self.__do_layout()