Example #1
0
    def start(self, restart=False):
        '''
        Starts main process
        '''
        # Preferences
        self.general_prefs = [PathConfigPage]
        self.apply_settings()

        # Dockwidgets creation
        self.splash.showMessage(
            "Creating widgets...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))

        self.create_dockwidgets()
        self.populate_mainwidow()

        #################################################################
        ## Menu initialization
        #################################################################
        self.splash.showMessage(
            "Creating menubar...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))
        # Menu Fichier
        self.file_menu = self.menuBar().addMenu("Fichier")
        action_export_png = create_action(
            self, 'Exporter le graphique',
            icon='document-save png.png')  #, triggered = None)
        action_export_csv = create_action(
            self, 'Exporter la table',
            icon='document-save csv.png')  #, triggered = None)
        action_pref = create_action(self,
                                    u'Préférences',
                                    QKeySequence.Preferences,
                                    icon='preferences-desktop.png',
                                    triggered=self.edit_preferences)
        action_quit = create_action(self,
                                    'Quitter',
                                    QKeySequence.Quit,
                                    icon='process-stop.png',
                                    triggered=SLOT('close()'))

        file_actions = [
            action_export_png, action_export_csv, None, action_pref, None,
            action_quit
        ]
        add_actions(self.file_menu, file_actions)

        # Menu Edit
        self.edit_menu = self.menuBar().addMenu(u"Édition")
        action_copy = create_action(self,
                                    'Copier',
                                    QKeySequence.Copy,
                                    triggered=self.global_callback,
                                    data='copy')

        edit_actions = [None, action_copy]
        add_actions(self.edit_menu, edit_actions)

        # Menu Projection
        self.projection_menu = self.menuBar().addMenu(u"Projection")
        #
        self.action_refresh_project_population = create_action(
            self,
            u'Calculer les projections de population',
            shortcut='F9',
            icon='calculator_green.png',
            triggered=self.project_population)

        projection_actions = [self.action_refresh_project_population, None]
        add_actions(self.projection_menu, projection_actions)

        # Menu Help
        help_menu = self.menuBar().addMenu("&Aide")
        action_about = create_action(self,
                                     u"&About GA",
                                     triggered=self.helpAbout)
        action_help = create_action(self,
                                    "&Aide",
                                    QKeySequence.HelpContents,
                                    triggered=self.helpHelp)
        help_actions = [action_about, action_help]
        add_actions(help_menu, help_actions)

        # Display Menu
        view_menu = self.createPopupMenu()
        view_menu.setTitle("&Affichage")
        self.menuBar().insertMenu(help_menu.menuAction(), view_menu)

        # Toolbar
        self.main_toolbar = self.create_toolbar(u"Barre d'outil",
                                                'main_toolbar')
        toolbar_actions = [
            action_export_png,
            action_export_csv,
            None,
            self.action_refresh_project_population,
        ]
        add_actions(self.main_toolbar, toolbar_actions)

        # Window settings
        self.splash.showMessage(
            "Restoring settings...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))
        settings = QSettings()
        size = settings.value('MainWindow/Size',
                              QVariant(QSize(800, 600))).toSize()
        self.resize(size)
        position = settings.value('MainWindow/Position',
                                  QVariant(QPoint(0, 0))).toPoint()
        self.move(position)
        self.restoreState(settings.value("MainWindow/State").toByteArray())

        # Connectors

        self.connect(self._param_widget, SIGNAL('population_changed()'),
                     self.refresh_population)
        #        self.connect(self._param_widget, SIGNAL('rates_changed()'), self.refresh_cohorts)
        self.connect(self._param_widget, SIGNAL('state_proj_changed()'),
                     self.refresh_cohorts)

        self.refresh_population()
        self.load_data()

        self.splash.showMessage(
            "Loading survey data...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))
        self.splash.hide()
        return
Example #2
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.dirty = False
        self.isLoaded = False
        self.calibration_enabled = False
        self.aggregate_enabled = False

        self.setObjectName("MainWindow")
        self.resize(800, 600)
        self.setWindowTitle("OpenFisca")
        app_icon = get_icon('OpenFisca22.png')
        self.setWindowIcon(app_icon)
        self.setLocale(QLocale(QLocale.French, QLocale.France))
        self.setDockOptions(QMainWindow.AllowNestedDocks
                            | QMainWindow.AllowTabbedDocks
                            | QMainWindow.AnimatedDocks)

        self.centralwidget = QWidget(self)
        self.gridLayout = QGridLayout(self.centralwidget)
        self.setCentralWidget(self.centralwidget)
        self.centralwidget.hide()

        self.statusbar = QStatusBar(self)
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)

        # Showing splash screen
        pixmap = QPixmap(':/images/splash.png', 'png')
        self.splash = QSplashScreen(pixmap)
        font = self.splash.font()
        font.setPixelSize(10)
        self.splash.setFont(font)
        self.splash.show()
        self.splash.showMessage(
            "Initialisation...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))
        #        if CONF.get('main', 'current_version', '') != __version__:
        #            CONF.set('main', 'current_version', __version__)
        # Execute here the actions to be performed only once after
        # each update (there is nothing there for now, but it could
        # be useful some day...

        self.scenario = Scenario()
        # Preferences
        self.general_prefs = [SimConfigPage, PathConfigPage, CalConfigPage]
        self.oldXAXIS = 'sal'
        self.reforme = False
        self.apply_settings()

        # Dockwidgets creation
        self.splash.showMessage(
            "Creating widgets...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))

        self.create_dockwidgets()
        self.populate_mainwidow()

        #################################################################
        ## Menu initialization
        #################################################################
        self.splash.showMessage(
            "Creating menubar...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))
        # Menu Fichier
        self.file_menu = self.menuBar().addMenu("Fichier")
        action_export_png = create_action(self,
                                          'Exporter le graphique',
                                          icon='document-save png.png',
                                          triggered=self._graph.save_figure)
        action_export_csv = create_action(self,
                                          'Exporter la table',
                                          icon='document-save csv.png',
                                          triggered=self._table.saveCsv)
        action_pref = create_action(self,
                                    u'Préférences',
                                    QKeySequence.Preferences,
                                    icon='preferences-desktop.png',
                                    triggered=self.edit_preferences)
        action_quit = create_action(self,
                                    'Quitter',
                                    QKeySequence.Quit,
                                    icon='process-stop.png',
                                    triggered=SLOT('close()'))

        file_actions = [
            action_export_png, action_export_csv, None, action_pref, None,
            action_quit
        ]
        add_actions(self.file_menu, file_actions)

        # Menu Edit
        self.edit_menu = self.menuBar().addMenu(u"Édition")
        action_copy = create_action(self,
                                    'Copier',
                                    QKeySequence.Copy,
                                    triggered=self.global_callback,
                                    data='copy')

        edit_actions = [None, action_copy]
        add_actions(self.edit_menu, edit_actions)

        # Menu Simulation
        self.simulation_menu = self.menuBar().addMenu(u"Simulation")

        self.action_refresh_bareme = create_action(
            self,
            u'Calculer barèmes',
            shortcut='F9',
            icon='calculator_green.png',
            triggered=self.refresh_bareme)
        self.action_refresh_aggregate = create_action(
            self,
            u'Calculer aggrégats',
            shortcut='F10',
            icon='calculator_blue.png',
            triggered=self.refresh_aggregate)

        self.action_calibrate = create_action(self,
                                              u'Caler les poids',
                                              shortcut='CTRL+K',
                                              icon='scale22.png',
                                              triggered=self.calibrate)

        action_bareme = create_action(self,
                                      u'Barème',
                                      icon='bareme22.png',
                                      toggled=self.modeBareme)
        action_cas_type = create_action(self,
                                        u'Cas type',
                                        icon='castype22.png',
                                        toggled=self.modeCasType)
        action_mode_reforme = create_action(
            self,
            u'Réforme',
            icon='comparison22.png',
            toggled=self.modeReforme,
            tip=
            u"Différence entre la situation simulée et la situation actuelle")
        mode_group = QActionGroup(self)
        mode_group.addAction(action_bareme)
        mode_group.addAction(action_cas_type)
        self.mode = 'bareme'
        action_bareme.trigger()

        simulation_actions = [
            self.action_refresh_bareme, self.action_refresh_aggregate, None,
            self.action_calibrate, None, action_bareme, action_cas_type, None,
            action_mode_reforme
        ]
        add_actions(self.simulation_menu, simulation_actions)

        # Menu Help
        help_menu = self.menuBar().addMenu("&Aide")
        action_about = create_action(self,
                                     u"&About OpenFisca",
                                     triggered=self.helpAbout)
        action_help = create_action(self,
                                    "&Aide",
                                    QKeySequence.HelpContents,
                                    triggered=self.helpHelp)
        help_actions = [action_about, action_help]
        add_actions(help_menu, help_actions)

        # Display Menu
        view_menu = self.createPopupMenu()
        view_menu.setTitle("&Affichage")
        self.menuBar().insertMenu(help_menu.menuAction(), view_menu)

        # Toolbar
        self.main_toolbar = self.create_toolbar(u"Barre d'outil",
                                                'main_toolbar')
        toolbar_actions = [
            action_export_png, action_export_csv, None,
            self.action_refresh_bareme, self.action_refresh_aggregate, None,
            self.action_calibrate, None, action_bareme, action_cas_type, None,
            action_mode_reforme
        ]
        add_actions(self.main_toolbar, toolbar_actions)

        self.connect(self._menage, SIGNAL('changed()'), self.changed_bareme)
        self.connect(self._parametres, SIGNAL('changed()'), self.changed_param)
        self.connect(self._aggregate_output, SIGNAL('calculated()'),
                     self.calculated)
        self.connect(self, SIGNAL('weights_changed()'), self.refresh_aggregate)
        self.connect(self, SIGNAL('bareme_only()'), self.switch_bareme_only)

        # Window settings
        self.splash.showMessage(
            "Restoring settings...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))
        settings = QSettings()
        size = settings.value('MainWindow/Size',
                              QVariant(QSize(800, 600))).toSize()
        self.resize(size)
        position = settings.value('MainWindow/Position',
                                  QVariant(QPoint(0, 0))).toPoint()
        self.move(position)
        self.restoreState(settings.value("MainWindow/State").toByteArray())

        self.splash.showMessage(
            "Loading survey data...",
            Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute,
            QColor(Qt.black))

        self.enable_aggregate(True)

        self.refresh_bareme()

        self.isLoaded = True
        self.splash.hide()
Example #3
0
    def __init__(self, parent = None):
        super(MainWindow, self).__init__(parent)
        self.dirty = False
        self.isLoaded = False
        self.calibration_enabled = False
        self.aggregate_enabled = False

        self.setObjectName("MainWindow")
        self.resize(800, 600)
        self.setWindowTitle("OpenFisca")
        app_icon = get_icon('OpenFisca22.png')
        self.setWindowIcon(app_icon)
        self.setLocale(QLocale(QLocale.French, QLocale.France))
        self.setDockOptions(QMainWindow.AllowNestedDocks|QMainWindow.AllowTabbedDocks|QMainWindow.AnimatedDocks)

        self.centralwidget = QWidget(self)
        self.gridLayout = QGridLayout(self.centralwidget)
        self.setCentralWidget(self.centralwidget)
        self.centralwidget.hide()

        self.statusbar = QStatusBar(self)
        self.statusbar.setObjectName("statusbar")
        self.setStatusBar(self.statusbar)

        # Showing splash screen
        pixmap = QPixmap(':/images/splash.png', 'png')
        self.splash = QSplashScreen(pixmap)
        font = self.splash.font()
        font.setPixelSize(10)
        self.splash.setFont(font)
        self.splash.show()
        self.splash.showMessage("Initialisation...", Qt.AlignBottom | Qt.AlignCenter | 
                                Qt.AlignAbsolute, QColor(Qt.black))
#        if CONF.get('main', 'current_version', '') != __version__:
#            CONF.set('main', 'current_version', __version__)
            # Execute here the actions to be performed only once after
            # each update (there is nothing there for now, but it could 
            # be useful some day...
        
        self.scenario = Scenario()
        # Preferences
        self.general_prefs = [SimConfigPage, PathConfigPage, CalConfigPage]
        self.oldXAXIS = 'sal'
        self.reforme = False
        self.apply_settings()
        
        # Dockwidgets creation
        self.splash.showMessage("Creating widgets...", Qt.AlignBottom | Qt.AlignCenter | 
                                Qt.AlignAbsolute, QColor(Qt.black))

        self.create_dockwidgets()
        self.populate_mainwidow()

        #################################################################
        ## Menu initialization
        #################################################################
        self.splash.showMessage("Creating menubar...", Qt.AlignBottom | Qt.AlignCenter | 
                                Qt.AlignAbsolute, QColor(Qt.black))
        # Menu Fichier
        self.file_menu = self.menuBar().addMenu("Fichier")
        action_export_png = create_action(self, 'Exporter le graphique', icon = 'document-save png.png', triggered = self._graph.save_figure)
        action_export_csv = create_action(self, 'Exporter la table', icon = 'document-save csv.png', triggered = self._table.saveCsv)
        action_pref = create_action(self, u'Préférences', QKeySequence.Preferences, icon = 'preferences-desktop.png', triggered = self.edit_preferences)
        action_quit = create_action(self, 'Quitter', QKeySequence.Quit, icon = 'process-stop.png',  triggered = SLOT('close()'))
        
        file_actions = [action_export_png, action_export_csv,None, action_pref, None, action_quit]
        add_actions(self.file_menu, file_actions)

        # Menu Edit
        self.edit_menu = self.menuBar().addMenu(u"Édition")
        action_copy = create_action(self, 'Copier', QKeySequence.Copy, triggered = self.global_callback, data = 'copy')
        
        edit_actions = [None, action_copy]
        add_actions(self.edit_menu, edit_actions)

        # Menu Simulation
        self.simulation_menu = self.menuBar().addMenu(u"Simulation")
        self.action_refresh_bareme      = create_action(self, u'Calculer barèmes', shortcut = 'F8', icon = 'view-refresh.png', triggered = self.refresh_bareme)
        self.action_refresh_calibration = create_action(self, u'Calibrer', shortcut = 'F9', icon = 'view-refresh.png', triggered = self.refresh_calibration)
        self.action_refresh_aggregate   = create_action(self, u'Calculer aggrégats', shortcut = 'F10', icon = 'view-refresh.png', triggered = self.refresh_aggregate)
        action_bareme = create_action(self, u'Barème', icon = 'bareme22.png', toggled = self.modeBareme)
        action_cas_type = create_action(self, u'Cas type', icon = 'castype22.png', toggled = self.modeCasType)
        action_mode_reforme = create_action(self, u'Réforme', icon = 'comparison22.png', toggled = self.modeReforme, tip = u"Différence entre la situation simulée et la situation actuelle")
        mode_group = QActionGroup(self)
        mode_group.addAction(action_bareme)
        mode_group.addAction(action_cas_type)
        self.mode = 'bareme'
        action_bareme.trigger()

        simulation_actions = [self.action_refresh_bareme, self.action_refresh_calibration, self.action_refresh_aggregate , None, action_bareme, action_cas_type, None, action_mode_reforme]
        add_actions(self.simulation_menu, simulation_actions)
        
        # Menu Help
        help_menu = self.menuBar().addMenu("&Aide")
        action_about = create_action(self, u"&About OpenFisca", triggered = self.helpAbout)
        action_help = create_action(self, "&Aide", QKeySequence.HelpContents, triggered = self.helpHelp)
        help_actions = [action_about, action_help]
        add_actions(help_menu, help_actions)
                
        # Display Menu
        view_menu = self.createPopupMenu()
        view_menu.setTitle("&Affichage")
        self.menuBar().insertMenu(help_menu.menuAction(),
                                  view_menu)
        
        # Toolbar
        self.main_toolbar = self.create_toolbar(u"Barre d'outil", 'main_toolbar')
        toolbar_actions = [action_export_png, action_export_csv, None, self.action_refresh_bareme,
                           self.action_refresh_calibration, self.action_refresh_aggregate, None,
                            action_bareme, action_cas_type, None, action_mode_reforme]
        add_actions(self.main_toolbar, toolbar_actions)


        self.connect(self._menage,     SIGNAL('changed()'), self.changed_bareme)
        self.connect(self._parametres, SIGNAL('changed()'), self.changed_param)
        self.connect(self._aggregate_output, SIGNAL('calculated()'), self.calculated)
        self.connect(self._calibration, SIGNAL('param_or_margins_changed()'), self.param_or_margins_changed)
        self.connect(self._calibration, SIGNAL('calibrated()'), self.calibrated)
        
        # Window settings
        self.splash.showMessage("Restoring settings...", Qt.AlignBottom | Qt.AlignCenter | 
                                Qt.AlignAbsolute, QColor(Qt.black))
        settings = QSettings()
        size = settings.value('MainWindow/Size', QVariant(QSize(800,600))).toSize()
        self.resize(size)
        position = settings.value('MainWindow/Position', QVariant(QPoint(0,0))).toPoint()
        self.move(position)
        self.restoreState(settings.value("MainWindow/State").toByteArray())



        self.splash.showMessage("Loading survey data...", Qt.AlignBottom | Qt.AlignCenter | 
                                Qt.AlignAbsolute, QColor(Qt.black))
        
        self.enable_aggregate(True)
        self.enable_calibration(True)
        
        self.refresh_bareme()
        
        self.isLoaded = True
        self.splash.hide()
Example #4
0
    def start(self, restart = False):
        '''
        Starts main process
        '''
        # Preferences
        self.general_prefs = [PathConfigPage]
        self.apply_settings()
        
        # Dockwidgets creation
        self.splash.showMessage("Creating widgets...", Qt.AlignBottom | Qt.AlignCenter | 
                                Qt.AlignAbsolute, QColor(Qt.black))

        self.create_dockwidgets()
        self.populate_mainwidow()
        
        #################################################################
        ## Menu initialization
        #################################################################
        self.splash.showMessage("Creating menubar...", Qt.AlignBottom | Qt.AlignCenter | 
                                Qt.AlignAbsolute, QColor(Qt.black))
        # Menu Fichier
        self.file_menu = self.menuBar().addMenu("Fichier")
        action_export_png = create_action(self, 'Exporter le graphique', icon = 'document-save png.png') #, triggered = None)
        action_export_csv = create_action(self, 'Exporter la table', icon = 'document-save csv.png') #, triggered = None)
        action_pref = create_action(self, u'Préférences', QKeySequence.Preferences, icon = 'preferences-desktop.png', triggered = self.edit_preferences)
        action_quit = create_action(self, 'Quitter', QKeySequence.Quit, icon = 'process-stop.png',  triggered = SLOT('close()'))
        
        file_actions = [action_export_png, action_export_csv,None, action_pref, None, action_quit]
        add_actions(self.file_menu, file_actions)


        # Menu Edit
        self.edit_menu = self.menuBar().addMenu(u"Édition")
        action_copy = create_action(self, 'Copier', QKeySequence.Copy, triggered = self.global_callback, data = 'copy')
        
        edit_actions = [None, action_copy]
        add_actions(self.edit_menu, edit_actions)


        # Menu Projection
        self.projection_menu = self.menuBar().addMenu(u"Projection")
#
        self.action_refresh_project_population  = create_action(self, u'Calculer les projections de population', shortcut = 'F9', icon = 'calculator_green.png', triggered = self.project_population)


        projection_actions = [self.action_refresh_project_population,  None ]
        add_actions(self.projection_menu, projection_actions)
        
        # Menu Help
        help_menu = self.menuBar().addMenu("&Aide")
        action_about = create_action(self, u"&About GA", triggered = self.helpAbout)
        action_help = create_action(self, "&Aide", QKeySequence.HelpContents, triggered = self.helpHelp)
        help_actions = [action_about, action_help]
        add_actions(help_menu, help_actions)
                
        # Display Menu
        view_menu = self.createPopupMenu()
        view_menu.setTitle("&Affichage")
        self.menuBar().insertMenu(help_menu.menuAction(),
                                  view_menu)
        
        
        # Toolbar
        self.main_toolbar = self.create_toolbar(u"Barre d'outil", 'main_toolbar')
        toolbar_actions = [action_export_png, action_export_csv, None, self.action_refresh_project_population,]
        add_actions(self.main_toolbar, toolbar_actions)
        
        # Window settings
        self.splash.showMessage("Restoring settings...", Qt.AlignBottom | Qt.AlignCenter | 
                                Qt.AlignAbsolute, QColor(Qt.black))
        settings = QSettings()
        size = settings.value('MainWindow/Size', QVariant(QSize(800,600))).toSize()
        self.resize(size)
        position = settings.value('MainWindow/Position', QVariant(QPoint(0,0))).toPoint()
        self.move(position)
        self.restoreState(settings.value("MainWindow/State").toByteArray())

        # Connectors

        self.connect(self._param_widget, SIGNAL('population_changed()'), self.refresh_population)
#        self.connect(self._param_widget, SIGNAL('rates_changed()'), self.refresh_cohorts)
        self.connect(self._param_widget, SIGNAL('state_proj_changed()'), self.refresh_cohorts)

        self.refresh_population()
        self.load_data()
        
        
        self.splash.showMessage("Loading survey data...", Qt.AlignBottom | Qt.AlignCenter | 
                                Qt.AlignAbsolute, QColor(Qt.black))
        self.splash.hide()
        return