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()
def __init__(self, scenario, parent = None): super(InfoComp, self).__init__(parent) self.resize(300, 223) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.setWindowTitle(u"Informations complémentaires") icon = get_icon(":/images/people.png") self.setWindowIcon(icon) self.verticalLayout = QVBoxLayout(self) self.gridLayout = QGridLayout() self.gridLayout.setHorizontalSpacing(10) self.setStyleSheet(OfSs.bold_center) self.label_0 = QLabel(u'n°', self) self.gridLayout.addWidget(self.label_0, 0, 0, 1, 1) self.label_1 = QLabel(u'Activité', self) self.gridLayout.addWidget(self.label_1, 0, 1, 1, 1) self.label_2 = QLabel(u"Invalide", self) self.gridLayout.addWidget(self.label_2, 0, 2, 1, 1) self.label_3 = QLabel(u'Garde\nalternée', self) self.gridLayout.addWidget(self.label_3, 0, 3, 1, 1) self.gridLayout.setColumnStretch(1, 1) self.gridLayout.setColumnStretch(2, 1) self.gridLayout.setColumnStretch(3, 1) self.verticalLayout.addLayout(self.gridLayout) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Cancel| QDialogButtonBox.Ok, parent = self) self.verticalLayout.addWidget(self.buttonBox) self.connect(self.buttonBox, SIGNAL('accepted()'), self.accept); self.connect(self.buttonBox, SIGNAL('rejected()'), self.reject); self.parent = parent self.scenario = scenario self.inv_list = [] self.alt_list = [] self.act_list = [] for noi, vals in self.scenario.indiv.iteritems(): self.gridLayout.addWidget(QLabel('%d' % (noi + 1), self), noi + 1, 0) # Acitivité cb_act = QComboBox(self) cb_act.addItems([u'Actif occupé', u'Chômeur', u'Étudiant, élève', u'Retraité', u'Autre inactif']) cb_act.setCurrentIndex(vals['activite']) self.act_list.append(cb_act) self.gridLayout.addWidget(cb_act, noi + 1, 1) # Invalide cb_inv = QCheckBox(self) cb_inv.setChecked(vals['inv']) layout1 = QHBoxLayout() layout1.addItem(QSpacerItem(0,0, QSizePolicy.Expanding, QSizePolicy.Minimum)) layout1.addWidget(cb_inv) layout1.addItem(QSpacerItem(0,0, QSizePolicy.Expanding, QSizePolicy.Minimum)) self.inv_list.append(cb_inv) self.gridLayout.addLayout(layout1, noi + 1, 2) # Garde alternée cb_alt = QCheckBox(self) if vals['quifoy'][:3] != 'pac': vals['alt'] = 0 cb_alt.setEnabled(False) cb_alt.setChecked(vals['alt']) layout2 = QHBoxLayout() layout2.addItem(QSpacerItem(0,0, QSizePolicy.Expanding, QSizePolicy.Minimum)) layout2.addWidget(cb_alt) layout2.addItem(QSpacerItem(0,0, QSizePolicy.Expanding, QSizePolicy.Minimum)) self.alt_list.append(cb_alt) self.gridLayout.addLayout(layout2, noi + 1, 3)
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()
def __init__(self, scenario, parent=None): super(InfoComp, self).__init__(parent) self.resize(300, 223) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.setWindowTitle(u"Informations complémentaires") icon = get_icon(":/images/people.png") self.setWindowIcon(icon) self.verticalLayout = QVBoxLayout(self) self.gridLayout = QGridLayout() self.gridLayout.setHorizontalSpacing(10) self.setStyleSheet(OfSs.bold_center) self.label_0 = QLabel(u'n°', self) self.gridLayout.addWidget(self.label_0, 0, 0, 1, 1) self.label_1 = QLabel(u'Activité', self) self.gridLayout.addWidget(self.label_1, 0, 1, 1, 1) self.label_2 = QLabel(u"Invalide", self) self.gridLayout.addWidget(self.label_2, 0, 2, 1, 1) self.label_3 = QLabel(u'Garde\nalternée', self) self.gridLayout.addWidget(self.label_3, 0, 3, 1, 1) self.gridLayout.setColumnStretch(1, 1) self.gridLayout.setColumnStretch(2, 1) self.gridLayout.setColumnStretch(3, 1) self.verticalLayout.addLayout(self.gridLayout) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Cancel | QDialogButtonBox.Ok, parent=self) self.verticalLayout.addWidget(self.buttonBox) self.connect(self.buttonBox, SIGNAL('accepted()'), self.accept) self.connect(self.buttonBox, SIGNAL('rejected()'), self.reject) self.parent = parent self.scenario = scenario self.inv_list = [] self.alt_list = [] self.act_list = [] for noi, vals in self.scenario.indiv.iteritems(): self.gridLayout.addWidget(QLabel('%d' % (noi + 1), self), noi + 1, 0) # Acitivité cb_act = QComboBox(self) cb_act.addItems([ u'Actif occupé', u'Chômeur', u'Étudiant, élève', u'Retraité', u'Autre inactif' ]) cb_act.setCurrentIndex(vals['activite']) self.act_list.append(cb_act) self.gridLayout.addWidget(cb_act, noi + 1, 1) # Invalide cb_inv = QCheckBox(self) cb_inv.setChecked(vals['inv']) layout1 = QHBoxLayout() layout1.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)) layout1.addWidget(cb_inv) layout1.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)) self.inv_list.append(cb_inv) self.gridLayout.addLayout(layout1, noi + 1, 2) # Garde alternée cb_alt = QCheckBox(self) if vals['quifoy'][:3] != 'pac': vals['alt'] = 0 cb_alt.setEnabled(False) cb_alt.setChecked(vals['alt']) layout2 = QHBoxLayout() layout2.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)) layout2.addWidget(cb_alt) layout2.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)) self.alt_list.append(cb_alt) self.gridLayout.addLayout(layout2, noi + 1, 3)