예제 #1
0
파일: configdialog.py 프로젝트: benjello/ga
 def create_scedit(self, text, option, default=NoDefault, tip=None,
                   without_layout=False):
     label = QLabel(text)
     clayout = ColorLayout(QColor(Qt.black), self)
     clayout.lineedit.setMaximumWidth(80)
     if tip is not None:
         clayout.setToolTip(tip)
     cb_bold = QCheckBox()
     cb_bold.setIcon(get_icon("bold.png"))
     cb_bold.setToolTip(_("Bold"))
     cb_italic = QCheckBox()
     cb_italic.setIcon(get_icon("italic.png"))
     cb_italic.setToolTip(_("Italic"))
     self.scedits[(clayout, cb_bold, cb_italic)] = (option, default)
     if without_layout:
         return label, clayout, cb_bold, cb_italic
     layout = QHBoxLayout()
     layout.addWidget(label)
     layout.addLayout(clayout)
     layout.addSpacing(10)
     layout.addWidget(cb_bold)
     layout.addWidget(cb_italic)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.setLayout(layout)
     return widget
예제 #2
0
파일: configdialog.py 프로젝트: benjello/ga
    def create_dateedit(self, prefix, option, default=NoDefault,
                       min_=None, max_=None, step=None, tip=None):
        if prefix:
            plabel = QLabel(prefix)
        else:
            plabel = None

        dateedit = QDateEdit()
        dateedit.setDisplayFormat('dd MMM yyyy')

        def extract_qdate_from_str(x):
            return QDate(int(x[:4]), int(x[5:7]), int(x[8:10]))

        if min_ is not None:
            min_qdate = extract_qdate_from_str(min_)
            dateedit.setMinimumDate(min_qdate)
        if max_ is not None:
            max_qdate = extract_qdate_from_str(max_)
            dateedit.setMaximumDate(max_qdate)
        
        default_qdate = extract_qdate_from_str(default)
    
        dateedit.setDate(default_qdate)        
        if tip is not None:
            dateedit.setToolTip(tip)
        self.dateedits[dateedit] = (option, default)
        layout = QHBoxLayout()
        for subwidget in (plabel, dateedit):
            if subwidget is not None:
                layout.addWidget(subwidget)
        layout.addStretch(1)
        layout.setContentsMargins(0, 0, 0, 0)
        widget = QWidget(self)
        widget.setLayout(layout)
        return widget
예제 #3
0
파일: configdialog.py 프로젝트: benjello/ga
 def create_spinbox(self, prefix, suffix, option, default=NoDefault,
                    min_=None, max_=None, step=None, tip=None):
     if prefix:
         plabel = QLabel(prefix)
     else:
         plabel = None
     if suffix:
         slabel = QLabel(suffix)
     else:
         slabel = None
     spinbox = QSpinBox()
     if min_ is not None:
         spinbox.setMinimum(min_)
     if max_ is not None:
         spinbox.setMaximum(max_)
     if step is not None:
         spinbox.setSingleStep(step)
     if tip is not None:
         spinbox.setToolTip(tip)
     self.spinboxes[spinbox] = (option, default)
     layout = QHBoxLayout()
     for subwidget in (plabel, spinbox, slabel):
         if subwidget is not None:
             layout.addWidget(subwidget)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.setLayout(layout)
     return widget
예제 #4
0
파일: configdialog.py 프로젝트: jsantoul/ga
 def create_browsefile(self,
                       text,
                       option,
                       default=NoDefault,
                       tip=None,
                       filters=None):
     widget = self.create_lineedit(text,
                                   option,
                                   default,
                                   alignment=Qt.Horizontal)
     for edit in self.lineedits:
         if widget.isAncestorOf(edit):
             break
     msg = _("Invalid file path")
     self.validate_data[edit] = (osp.isfile, msg)
     browse_btn = QPushButton(get_std_icon('FileIcon'), "", self)
     browse_btn.setToolTip(_("Select file"))
     self.connect(browse_btn, SIGNAL("clicked()"),
                  lambda: self.select_file(edit, filters))
     layout = QHBoxLayout()
     layout.addWidget(widget)
     layout.addWidget(browse_btn)
     layout.setContentsMargins(0, 0, 0, 0)
     browsedir = QWidget(self)
     browsedir.setLayout(layout)
     return browsedir
예제 #5
0
파일: configdialog.py 프로젝트: jsantoul/ga
 def create_scedit(self,
                   text,
                   option,
                   default=NoDefault,
                   tip=None,
                   without_layout=False):
     label = QLabel(text)
     clayout = ColorLayout(QColor(Qt.black), self)
     clayout.lineedit.setMaximumWidth(80)
     if tip is not None:
         clayout.setToolTip(tip)
     cb_bold = QCheckBox()
     cb_bold.setIcon(get_icon("bold.png"))
     cb_bold.setToolTip(_("Bold"))
     cb_italic = QCheckBox()
     cb_italic.setIcon(get_icon("italic.png"))
     cb_italic.setToolTip(_("Italic"))
     self.scedits[(clayout, cb_bold, cb_italic)] = (option, default)
     if without_layout:
         return label, clayout, cb_bold, cb_italic
     layout = QHBoxLayout()
     layout.addWidget(label)
     layout.addLayout(clayout)
     layout.addSpacing(10)
     layout.addWidget(cb_bold)
     layout.addWidget(cb_italic)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.setLayout(layout)
     return widget
예제 #6
0
파일: configdialog.py 프로젝트: benjello/ga
 def create_tab(self, *widgets):
     """Create simple tab widget page: widgets added in a vertical layout"""
     widget = QWidget()
     layout = QVBoxLayout()
     for widg in widgets:
         layout.addWidget(widg)
     layout.addStretch(1)
     widget.setLayout(layout)
     return widget
예제 #7
0
파일: configdialog.py 프로젝트: jsantoul/ga
 def create_tab(self, *widgets):
     """Create simple tab widget page: widgets added in a vertical layout"""
     widget = QWidget()
     layout = QVBoxLayout()
     for widg in widgets:
         layout.addWidget(widg)
     layout.addStretch(1)
     widget.setLayout(layout)
     return widget
예제 #8
0
def get_std_icon(name, size=None):
    """Get standard platform icon
    Call 'show_std_icons()' for details"""
    if not name.startswith('SP_'):
        name = 'SP_'+name
    icon = QWidget().style().standardIcon( getattr(QStyle, name) )
    if size is None:
        return icon
    else:
        return QIcon( icon.pixmap(size, size) )
예제 #9
0
파일: status.py 프로젝트: Pyke75/ga
    def __init__(self, parent, statusbar):
        QWidget.__init__(self, parent)

        self.label_font = font = get_font('editor')
        font.setPointSize(self.font().pointSize())
        font.setBold(True)
        
        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        statusbar.addPermanentWidget(self)
예제 #10
0
    def __init__(self, parent, statusbar):
        QWidget.__init__(self, parent)

        self.label_font = font = get_font('editor')
        font.setPointSize(self.font().pointSize())
        font.setBold(True)

        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)

        statusbar.addPermanentWidget(self)
예제 #11
0
파일: configdialog.py 프로젝트: benjello/ga
 def create_lineedit(self, text, option, default=NoDefault,
                     tip=None, alignment=Qt.Vertical):
     label = QLabel(text)
     label.setWordWrap(True)
     edit = QLineEdit()
     layout = QVBoxLayout() if alignment == Qt.Vertical else QHBoxLayout()
     layout.addWidget(label)
     layout.addWidget(edit)
     layout.setContentsMargins(0, 0, 0, 0)
     if tip:
         edit.setToolTip(tip)
     self.lineedits[edit] = (option, default)
     widget = QWidget(self)
     widget.setLayout(layout)
     return widget
예제 #12
0
파일: configdialog.py 프로젝트: benjello/ga
 def create_coloredit(self, text, option, default=NoDefault, tip=None,
                      without_layout=False):
     label = QLabel(text)
     clayout = ColorLayout(QColor(Qt.black), self)
     clayout.lineedit.setMaximumWidth(80)
     if tip is not None:
         clayout.setToolTip(tip)
     self.coloredits[clayout] = (option, default)
     if without_layout:
         return label, clayout
     layout = QHBoxLayout()
     layout.addWidget(label)
     layout.addLayout(clayout)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.setLayout(layout)
     return widget
예제 #13
0
파일: configdialog.py 프로젝트: benjello/ga
 def create_combobox(self, text, choices, option, default=NoDefault,
                     tip=None):
     """choices: couples (name, key)"""
     label = QLabel(text)
     combobox = QComboBox()
     if tip is not None:
         combobox.setToolTip(tip)
     for name, key in choices:
         combobox.addItem(name, to_qvariant(key))
     self.comboboxes[combobox] = (option, default)
     layout = QHBoxLayout()
     for subwidget in (label, combobox):
         layout.addWidget(subwidget)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.setLayout(layout)
     return widget
예제 #14
0
파일: configdialog.py 프로젝트: benjello/ga
 def create_browsedir(self, text, option, default=NoDefault, tip=None):
     widget = self.create_lineedit(text, option, default,
                                   alignment=Qt.Horizontal)
     for edit in self.lineedits:
         if widget.isAncestorOf(edit):
             break
     msg = _("Invalid directory path")
     self.validate_data[edit] = (osp.isdir, msg)
     browse_btn = QPushButton(get_std_icon('DirOpenIcon'), "", self)
     browse_btn.setToolTip(_("Select directory"))
     self.connect(browse_btn, SIGNAL("clicked()"),
                  lambda: self.select_directory(edit))
     layout = QHBoxLayout()
     layout.addWidget(widget)
     layout.addWidget(browse_btn)
     layout.setContentsMargins(0, 0, 0, 0)
     browsedir = QWidget(self)
     browsedir.setLayout(layout)
     return browsedir
예제 #15
0
파일: configdialog.py 프로젝트: jsantoul/ga
 def create_lineedit(self,
                     text,
                     option,
                     default=NoDefault,
                     tip=None,
                     alignment=Qt.Vertical):
     label = QLabel(text)
     label.setWordWrap(True)
     edit = QLineEdit()
     layout = QVBoxLayout() if alignment == Qt.Vertical else QHBoxLayout()
     layout.addWidget(label)
     layout.addWidget(edit)
     layout.setContentsMargins(0, 0, 0, 0)
     if tip:
         edit.setToolTip(tip)
     self.lineedits[edit] = (option, default)
     widget = QWidget(self)
     widget.setLayout(layout)
     return widget
예제 #16
0
파일: configdialog.py 프로젝트: jsantoul/ga
    def create_dateedit(self,
                        prefix,
                        option,
                        default=NoDefault,
                        min_=None,
                        max_=None,
                        step=None,
                        tip=None):
        if prefix:
            plabel = QLabel(prefix)
        else:
            plabel = None

        dateedit = QDateEdit()
        dateedit.setDisplayFormat('dd MMM yyyy')

        def extract_qdate_from_str(x):
            return QDate(int(x[:4]), int(x[5:7]), int(x[8:10]))

        if min_ is not None:
            min_qdate = extract_qdate_from_str(min_)
            dateedit.setMinimumDate(min_qdate)
        if max_ is not None:
            max_qdate = extract_qdate_from_str(max_)
            dateedit.setMaximumDate(max_qdate)

        default_qdate = extract_qdate_from_str(default)

        dateedit.setDate(default_qdate)
        if tip is not None:
            dateedit.setToolTip(tip)
        self.dateedits[dateedit] = (option, default)
        layout = QHBoxLayout()
        for subwidget in (plabel, dateedit):
            if subwidget is not None:
                layout.addWidget(subwidget)
        layout.addStretch(1)
        layout.setContentsMargins(0, 0, 0, 0)
        widget = QWidget(self)
        widget.setLayout(layout)
        return widget
예제 #17
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     layout = QHBoxLayout()
     row_nb = 14
     cindex = 0
     for child in dir(QStyle):
         if child.startswith('SP_'):
             if cindex == 0:
                 col_layout = QVBoxLayout()
             icon_layout = QHBoxLayout()
             icon = get_std_icon(child)
             label = QLabel()
             label.setPixmap(icon.pixmap(32, 32))
             icon_layout.addWidget( label )
             icon_layout.addWidget( QLineEdit(child.replace('SP_', '')) )
             col_layout.addLayout(icon_layout)
             cindex = (cindex+1) % row_nb
             if cindex == 0:
                 layout.addLayout(col_layout)                    
     self.setLayout(layout)
     self.setWindowTitle('Standard Platform Icons')
     self.setWindowIcon(get_std_icon('TitleBarMenuButton'))
예제 #18
0
파일: configdialog.py 프로젝트: jsantoul/ga
 def create_combobox(self,
                     text,
                     choices,
                     option,
                     default=NoDefault,
                     tip=None):
     """choices: couples (name, key)"""
     label = QLabel(text)
     combobox = QComboBox()
     if tip is not None:
         combobox.setToolTip(tip)
     for name, key in choices:
         combobox.addItem(name, to_qvariant(key))
     self.comboboxes[combobox] = (option, default)
     layout = QHBoxLayout()
     for subwidget in (label, combobox):
         layout.addWidget(subwidget)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.setLayout(layout)
     return widget
예제 #19
0
파일: configdialog.py 프로젝트: jsantoul/ga
 def create_coloredit(self,
                      text,
                      option,
                      default=NoDefault,
                      tip=None,
                      without_layout=False):
     label = QLabel(text)
     clayout = ColorLayout(QColor(Qt.black), self)
     clayout.lineedit.setMaximumWidth(80)
     if tip is not None:
         clayout.setToolTip(tip)
     self.coloredits[clayout] = (option, default)
     if without_layout:
         return label, clayout
     layout = QHBoxLayout()
     layout.addWidget(label)
     layout.addLayout(clayout)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.setLayout(layout)
     return widget
예제 #20
0
파일: configdialog.py 프로젝트: jsantoul/ga
 def create_spinbox(self,
                    prefix,
                    suffix,
                    option,
                    default=NoDefault,
                    min_=None,
                    max_=None,
                    step=None,
                    tip=None):
     if prefix:
         plabel = QLabel(prefix)
     else:
         plabel = None
     if suffix:
         slabel = QLabel(suffix)
     else:
         slabel = None
     spinbox = QSpinBox()
     if min_ is not None:
         spinbox.setMinimum(min_)
     if max_ is not None:
         spinbox.setMaximum(max_)
     if step is not None:
         spinbox.setSingleStep(step)
     if tip is not None:
         spinbox.setToolTip(tip)
     self.spinboxes[spinbox] = (option, default)
     layout = QHBoxLayout()
     for subwidget in (plabel, spinbox, slabel):
         if subwidget is not None:
             layout.addWidget(subwidget)
     layout.addStretch(1)
     layout.setContentsMargins(0, 0, 0, 0)
     widget = QWidget(self)
     widget.setLayout(layout)
     return widget
예제 #21
0
    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
예제 #22
0
    def __init__(self, parent=None):
        super(ParametersWidget, self).__init__(parent)
        self.setStyleSheet(OfSs.dock_style)
        # Create geometry
        self.setObjectName("Parameters")
        self.setWindowTitle(u"Configurer les paramètres")
        self.dockWidgetContents = QWidget()

        # Population
        #  scenario selection
        self.population_choices = []
        self.population_combo = MyComboBox(self.dockWidgetContents,
                                           u'Choix du scénario de population',
                                           self.population_choices)

        #  scenario prolongation
        self.population_prolong_choices = [(u'stable', 'stable'),
                                           (u'taux de croissance constant',
                                            'constant')]
        self.population_prolong_combo = MyComboBox(
            self.dockWidgetContents,
            u'Choix du prolongement du scénario de population',
            self.population_prolong_choices)

        # Population steady growth rate
        self.pop_grth = None
        self.pop_grth_spin = MyDoubleSpinBox(
            self.dockWidgetContents,
            u"Taux de croissance de la population",
            min_=-10,
            max_=10,
            step=.1,
            value=2)

        # Projection of net taxes (taxes - transfers)
        self.taxes_proj_choices = [(u"Global/Taux de croissance", 'global_g'),
                                   (u"Par tête/taux de croissance", 'head_g')]
        self.taxes_proj_combo = MyComboBox(
            self.dockWidgetContents,
            u"Projection des prélèvements nets des tranferts",
            self.taxes_proj_choices)

        # Growth rate
        self.grth_spin = MyDoubleSpinBox(self.dockWidgetContents,
                                         u"Taux de croissance",
                                         min_=-100,
                                         max_=100,
                                         step=.1,
                                         value=2)

        # Discount rate
        self.dsct_spin = MyDoubleSpinBox(self.dockWidgetContents,
                                         u"Taux d'actualisation",
                                         min_=-100,
                                         max_=100,
                                         step=.1,
                                         value=2)

        # Projection of the net expenses of the state
        self.state_proj_choices = [(u"Global/Taux d'intérêt", 'global_r'),
                                   (u"Global/Taux de croissance", 'global_g'),
                                   (u"Par tête/taux d'intérêt", 'head_r'),
                                   (u"Par tête/taux de croissance", 'head_g')]
        self.state_proj_combo = MyComboBox(
            self.dockWidgetContents,
            u"Projection des contributions nettes de l'Etat",
            self.state_proj_choices)

        verticalLayout = QVBoxLayout(self.dockWidgetContents)
        verticalLayout.addWidget(self.population_combo)
        verticalLayout.addWidget(self.population_prolong_combo)
        verticalLayout.addWidget(self.pop_grth_spin)
        verticalLayout.addWidget(self.taxes_proj_combo)
        verticalLayout.addWidget(self.grth_spin)
        verticalLayout.addWidget(self.dsct_spin)
        verticalLayout.addWidget(self.state_proj_combo)
        self.setWidget(self.dockWidgetContents)

        self.parent = parent

        # Connectors
        self.connect(self.population_combo.box,
                     SIGNAL('currentIndexChanged(int)'), self.set_population)
        self.connect(self.population_prolong_combo.box,
                     SIGNAL('currentIndexChanged(int)'),
                     self.set_population_prolong)
        self.connect(self.taxes_proj_combo.box,
                     SIGNAL('currentIndexChanged(int)'), self.set_taxes_proj)
        self.connect(self.state_proj_combo.box,
                     SIGNAL('currentIndexChanged(int)'),
                     self.set_state_proj_params)
예제 #23
0
파일: configdialog.py 프로젝트: jsantoul/ga
 def __init__(self, parent, apply_callback=None):
     QWidget.__init__(self, parent)
     self.apply_callback = apply_callback
     self.is_modified = False
예제 #24
0
파일: __init__.py 프로젝트: jsantoul/ga
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     OpenfiscaPluginMixin.__init__(self, parent)
예제 #25
0
파일: configdialog.py 프로젝트: benjello/ga
 def __init__(self, parent, apply_callback=None):
     QWidget.__init__(self, parent)
     self.apply_callback = apply_callback
     self.is_modified = False