def __init__(self, parent = None): super(ProfilesExplorerWidget, self).__init__(parent) self.setStyleSheet(OfSs.dock_style) # Create geometry self.setObjectName( _("Profiles data explorer")) self.dockWidgetContents = QWidget() self.view = DataFrameViewWidget(self.dockWidgetContents) verticalLayout = QVBoxLayout(self.dockWidgetContents) verticalLayout.addWidget(self.view) self.setLayout(verticalLayout) # Initialize attributes self.parent = parent self.initialize_plugin() # To run the suitable inherited API methods
class PopulationExplorerWidget(OpenfiscaPluginWidget): """ Population data explorer Widget """ CONF_SECTION = 'population' CONFIGWIDGET_CLASS = PopulationExplorerConfigPage LOCATION = Qt.LeftDockWidgetArea FEATURES = QDockWidget.DockWidgetClosable | \ QDockWidget.DockWidgetFloatable | \ QDockWidget.DockWidgetMovable DISABLE_ACTIONS_WHEN_HIDDEN = False sig_option_changed = Signal(str, object) def __init__(self, parent = None): super(PopulationExplorerWidget, self).__init__(parent) self.setStyleSheet(OfSs.dock_style) # Create geometry self.setObjectName( _("Population data explorer")) self.dockWidgetContents = QWidget() self.view = DataFrameViewWidget(self.dockWidgetContents) verticalLayout = QVBoxLayout(self.dockWidgetContents) verticalLayout.addWidget(self.view) self.setLayout(verticalLayout) # Initialize attributes self.parent = parent self.initialize_plugin() # To run the suitable inherited API methods # Initialize attributes self.parent = parent self.data = None def set_dataframe(self, dataframe = None, name = None): ''' Sets the current dataframe ''' if name is not None: self.data = self.dataframes[name] if dataframe is not None: self.data = dataframe def clear(self): self.view.clear() self.data = None self.datatables_choices = [] self.dataframes = {} #------ OpenfiscaPluginMixin API --------------------------------------------- def apply_plugin_settings(self, options): """ Apply configuration file's plugin settings """ if 'data_file' in options: NotImplementedError if 'use_default' in options: from src.lib.utils import of_import default_profiles_filename = of_import("","DEFAULT_PROFILES_FILENAME", self.simulation.country) self.simulation.load_profiles(default_profiles_filename) self.refresh_plugin() #------ OpenfiscaPluginWidget API --------------------------------------------- def get_plugin_title(self): """ Return plugin title Note: after some thinking, it appears that using a method is more flexible here than using a class attribute """ return _("Population Data Explorer") def get_plugin_icon(self): """ Return plugin icon (QIcon instance) Note: this is required for plugins creating a main window (see OpenfiscaPluginMixin.create_mainwindow) and for configuration dialog widgets creation """ return get_icon('OpenFisca22.png') def get_plugin_actions(self): """ Return a list of actions related to plugin Note: these actions will be enabled when plugin's dockwidget is visible and they will be disabled when it's hidden """ pass def register_plugin(self): """ Register plugin in OpenFisca's main window """ self.simulation = self.main.simulation self.main.add_dockwidget(self) def refresh_plugin(self): ''' Update Survey dataframes ''' self.starting_long_process(_("Refreshing population explorer dataframe ...")) self.clear() # self.view.set_dataframe(self.simulation.profiles.reset_index()) self.ending_long_process(_("Population explorer dataframe updated")) def closing_plugin(self, cancelable=False): """ Perform actions before parent main window is closed Return True or False whether the plugin may be closed immediately or not Note: returned value is ignored if *cancelable* is False """ return True
class ProfilesExplorerWidget(OpenfiscaPluginWidget): """ Profiles data explorer Widget """ CONF_SECTION = 'profiles' CONFIGWIDGET_CLASS = ProfilesExplorerConfigPage LOCATION = Qt.LeftDockWidgetArea FEATURES = QDockWidget.DockWidgetClosable | \ QDockWidget.DockWidgetFloatable | \ QDockWidget.DockWidgetMovable DISABLE_ACTIONS_WHEN_HIDDEN = False sig_option_changed = Signal(str, object) def __init__(self, parent = None): super(ProfilesExplorerWidget, self).__init__(parent) self.setStyleSheet(OfSs.dock_style) # Create geometry self.setObjectName( _("Profiles data explorer")) self.dockWidgetContents = QWidget() self.view = DataFrameViewWidget(self.dockWidgetContents) verticalLayout = QVBoxLayout(self.dockWidgetContents) verticalLayout.addWidget(self.view) self.setLayout(verticalLayout) # Initialize attributes self.parent = parent self.initialize_plugin() # To run the suitable inherited API methods def clear(self): self.view.reset() #------ OpenfiscaPluginMixin API --------------------------------------------- def apply_plugin_settings(self, options): """ Apply configuration file's plugin settings """ if 'data_file' in options: NotImplementedError if 'use_default' in options: from src.lib.utils import of_import default_profiles_filename = of_import("","DEFAULT_PROFILES_FILENAME", self.simulation.country) self.simulation.load_profiles(default_profiles_filename) self.refresh_plugin() #------ OpenfiscaPluginWidget API --------------------------------------------- def get_plugin_title(self): """ Return plugin title Note: after some thinking, it appears that using a method is more flexible here than using a class attribute """ return _("Profiles Data Explorer") def get_plugin_icon(self): """ Return plugin icon (QIcon instance) Note: this is required for plugins creating a main window (see OpenfiscaPluginMixin.create_mainwindow) and for configuration dialog widgets creation """ return get_icon('OpenFisca22.png') def get_plugin_actions(self): """ Return a list of actions related to plugin Note: these actions will be enabled when plugin's dockwidget is visible and they will be disabled when it's hidden """ # self.action_compute = create_action(self, _('Compute aggregates'), # shortcut = 'F10', # icon = 'calculator_blue.png', # triggered = self.compute) # self.register_shortcut(self.action_compute, # context = 'Survey explorer', # name = _('Compute survey simulation'), default = 'F10') # # self.action_set_reform = create_action(self, _('Reform mode'), # icon = 'comparison22.png', # toggled = self.set_reform, # tip = u"Différence entre la situation simulée et la situation actuelle") # # self.run_menu_actions = [self.action_compute, self.action_set_reform] # self.main.run_menu_actions += self.run_menu_actions # self.main.survey_toolbar_actions += self.run_menu_actions # # return self.run_menu_actions pass def register_plugin(self): """ Register plugin in OpenFisca's main window """ self.simulation = self.main.simulation self.main.add_dockwidget(self) def refresh_plugin(self): ''' Update Survey dataframes ''' self.starting_long_process(_("Refreshing profiles explorer dataframe ...")) self.clear() self.view.set_dataframe(self.simulation.profiles.reset_index()) self.ending_long_process(_("Profiles explorer dataframe updated")) def closing_plugin(self, cancelable=False): """ Perform actions before parent main window is closed Return True or False whether the plugin may be closed immediately or not Note: returned value is ignored if *cancelable* is False """ return True
class PopulationExplorerWidget(OpenfiscaPluginWidget): """ Population data explorer Widget """ CONF_SECTION = 'population' CONFIGWIDGET_CLASS = PopulationExplorerConfigPage LOCATION = Qt.LeftDockWidgetArea FEATURES = QDockWidget.DockWidgetClosable | \ QDockWidget.DockWidgetFloatable | \ QDockWidget.DockWidgetMovable DISABLE_ACTIONS_WHEN_HIDDEN = False sig_option_changed = Signal(str, object) def __init__(self, parent=None): super(PopulationExplorerWidget, self).__init__(parent) self.setStyleSheet(OfSs.dock_style) # Create geometry self.setObjectName(_("Population data explorer")) self.dockWidgetContents = QWidget() self.view = DataFrameViewWidget(self.dockWidgetContents) verticalLayout = QVBoxLayout(self.dockWidgetContents) verticalLayout.addWidget(self.view) self.setLayout(verticalLayout) # Initialize attributes self.parent = parent self.initialize_plugin() # To run the suitable inherited API methods # Initialize attributes self.parent = parent self.data = None def set_dataframe(self, dataframe=None, name=None): ''' Sets the current dataframe ''' if name is not None: self.data = self.dataframes[name] if dataframe is not None: self.data = dataframe def clear(self): self.view.clear() self.data = None self.datatables_choices = [] self.dataframes = {} #------ OpenfiscaPluginMixin API --------------------------------------------- def apply_plugin_settings(self, options): """ Apply configuration file's plugin settings """ if 'data_file' in options: NotImplementedError if 'use_default' in options: from src.lib.utils import of_import default_profiles_filename = of_import("", "DEFAULT_PROFILES_FILENAME", self.simulation.country) self.simulation.load_profiles(default_profiles_filename) self.refresh_plugin() #------ OpenfiscaPluginWidget API --------------------------------------------- def get_plugin_title(self): """ Return plugin title Note: after some thinking, it appears that using a method is more flexible here than using a class attribute """ return _("Population Data Explorer") def get_plugin_icon(self): """ Return plugin icon (QIcon instance) Note: this is required for plugins creating a main window (see OpenfiscaPluginMixin.create_mainwindow) and for configuration dialog widgets creation """ return get_icon('OpenFisca22.png') def get_plugin_actions(self): """ Return a list of actions related to plugin Note: these actions will be enabled when plugin's dockwidget is visible and they will be disabled when it's hidden """ pass def register_plugin(self): """ Register plugin in OpenFisca's main window """ self.simulation = self.main.simulation self.main.add_dockwidget(self) def refresh_plugin(self): ''' Update Survey dataframes ''' self.starting_long_process( _("Refreshing population explorer dataframe ...")) self.clear() # self.view.set_dataframe(self.simulation.profiles.reset_index()) self.ending_long_process(_("Population explorer dataframe updated")) def closing_plugin(self, cancelable=False): """ Perform actions before parent main window is closed Return True or False whether the plugin may be closed immediately or not Note: returned value is ignored if *cancelable* is False """ return True