Example #1
0
 def populate_treeview_model(self, index):
     """populate the tree view and the scroll_area when the tab is 
     activated"""
     if not self.tab_model_already_populated and index == 3 :
         
         self.models =  Models()
         # Populating the treeview with the dictionary
         for model_name in self.models.get_model_names():
             model = self.models.get_model(model_name)
             model_item = QtGui.QTreeWidgetItem(self.ui.tree_models, 'Models')
             model_item.setText(self.YEAR, model.get_year())
             model_item.setText(self.AUTHORS, model.get_authors())
             model_item.setText(self.TITLE, model.get_title())
             model_item.setData(self.ID, 0, model.get_id())
             
             # tooltip
             cols = self.ui.tree_models.columnCount()
             for i in range (cols):
                 tooltip = model.get_tooltip()
                 model_item.setToolTip(i, tooltip)
         
             
         #Resizing the column.
         #self.ui.tree_models.resizeColumnToContents(0)
         self.ui.tree_models.resizeColumnToContents(self.YEAR)
         self.ui.tree_models.resizeColumnToContents(self.TITLE)
         self.ui.tree_models.resizeColumnToContents(self.ID)
         self.ui.textBrowser_readme.clear()
         self.ui.textBrowser_readme.insertPlainText("No model selected.")
         self.tab_model_already_populated = True #we populated only once.
Example #2
0
    def __init__(self):
        dynamic_neuron_home()
        app = QtGui.QApplication.instance()
        self.ui_dir = 'ui'
        # Loading the UI
        self.ui = uic.loadUi(
            os.path.join(os.path.dirname(__file__), self.ui_dir,
                         "neuronvisio.ui"))

        # Connecting
        self.ui.Plot3D.connect(self.ui.Plot3D, QtCore.SIGNAL('clicked()'),
                               self.launch_visio)
        self.ui.plot_vector_btn.connect(self.ui.plot_vector_btn,
                                        QtCore.SIGNAL('clicked()'),
                                        self.plot_vector)
        self.ui.init_btn.connect(self.ui.init_btn, QtCore.SIGNAL('clicked()'),
                                 self.init)
        self.ui.run_btn.connect(self.ui.run_btn, QtCore.SIGNAL('clicked()'),
                                self.run)
        self.ui.dtSpinBox.connect(self.ui.dtSpinBox,
                                  QtCore.SIGNAL('valueChanged(double)'),
                                  self.dt_changed)
        self.ui.tstopSpinBox.connect(self.ui.tstopSpinBox,
                                     QtCore.SIGNAL('valueChanged(double)'),
                                     self.tstop_changed)
        self.ui.vSpinBox.connect(self.ui.vSpinBox,
                                 QtCore.SIGNAL('valueChanged(double)'),
                                 self.v_changed)
        self.ui.create_vector.connect(self.ui.create_vector,
                                      QtCore.SIGNAL('clicked()'),
                                      self.create_vector)
        self.ui.actionAbout.connect(self.ui.actionAbout,
                                    QtCore.SIGNAL('triggered()'), self.about)
        self.ui.timelineSlider.connect(self.ui.timelineSlider,
                                       QtCore.SIGNAL("valueChanged(int)"),
                                       self.on_timeline_value_changed)
        self.ui.animationTime.connect(self.ui.animationTime,
                                      QtCore.SIGNAL('returnPressed()'),
                                      self.on_animation_time_return_pressed)
        self.ui.actionLoad.connect(self.ui.actionLoad,
                                   QtCore.SIGNAL("triggered()"), self.load)
        self.ui.actionSave.connect(self.ui.actionSave,
                                   QtCore.SIGNAL("triggered()"), self.save_hdf)
        self.ui.tabWidget.connect(self.ui.tabWidget,
                                  QtCore.SIGNAL('currentChanged(int)'),
                                  self.populate_treeview_model)
        self.ui.tree_models.connect(self.ui.tree_models,
                                    QtCore.SIGNAL('itemSelectionChanged ()'),
                                    self.select_model_treeview)
        self.ui.load_model_btn.connect(self.ui.load_model_btn,
                                       QtCore.SIGNAL('clicked()'),
                                       self.load_selected_model)
        self.ui.load_model_btn.connect(self.ui.filter_list_btn,
                                       QtCore.SIGNAL('clicked()'),
                                       self.filter_list)
        self.ui.filter_input.connect(self.ui.filter_input,
                                     QtCore.SIGNAL('returnPressed()'),
                                     self.filter_list)

        ### Connection with the console
        widgetDic = {
            'dt': self.ui.dtSpinBox,
            'tstop': self.ui.tstopSpinBox,
            'v_init': self.ui.vSpinBox,
            'time_label': self.ui.time_label
        }
        self.timeLoop = Timeloop(widgetDic)
        app.connect(self.timeLoop, QtCore.SIGNAL("updateDt(double)"),
                    self.update_dt)
        app.connect(self.timeLoop, QtCore.SIGNAL("updateTstop(double)"),
                    self.update_tstop)
        app.connect(self.timeLoop, QtCore.SIGNAL("updateVInit(double)"),
                    self.update_v_init)
        self.timeLoop.start()

        ### Manager class
        self.manager = manager.Manager()
        self.path_to_hdf = None
        self.visio = None
        self.tab_model_already_populated = False
        self.ui.show()
        # Start the main event loop.
        #app.exec_()

        self.AUTHORS = 1
        self.YEAR = 0
        self.TITLE = 2
        self.ID = 3
        # Dictionary to hold the models class for the ModelDb integration
        self.models = Models()