示例#1
0
    def setup_page(self):
        tabs = QTabWidget()
        names = self.get_option("names")
        names.pop(names.index(CUSTOM_COLOR_SCHEME_NAME))
        names.insert(0, CUSTOM_COLOR_SCHEME_NAME)
        fieldnames = {
            "background": _("Background:"),
            "currentline": _("Current line:"),
            "occurence": _("Occurence:"),
            "ctrlclick": _("Link:"),
            "sideareas": _("Side areas:"),
            "matched_p": _("Matched parentheses:"),
            "unmatched_p": _("Unmatched parentheses:"),
            "normal": _("Normal text:"),
            "keyword": _("Keyword:"),
            "builtin": _("Builtin:"),
            "definition": _("Definition:"),
            "comment": _("Comment:"),
            "string": _("String:"),
            "number": _("Number:"),
            "instance": _("Instance:"),
        }
        from src.gui.spyder_widgets.sourcecode import syntaxhighlighters
        assert all([
            key in fieldnames for key in syntaxhighlighters.COLOR_SCHEME_KEYS
        ])
        for tabname in names:
            cs_group = QGroupBox(_("Color scheme"))
            cs_layout = QGridLayout()
            for row, key in enumerate(syntaxhighlighters.COLOR_SCHEME_KEYS):
                option = "%s/%s" % (tabname, key)
                value = self.get_option(option)
                name = fieldnames[key]
                if isinstance(value, basestring):
                    label, clayout = self.create_coloredit(name,
                                                           option,
                                                           without_layout=True)
                    label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
                    cs_layout.addWidget(label, row + 1, 0)
                    cs_layout.addLayout(clayout, row + 1, 1)
                else:
                    label, clayout, cb_bold, cb_italic = self.create_scedit(
                        name, option, without_layout=True)
                    label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
                    cs_layout.addWidget(label, row + 1, 0)
                    cs_layout.addLayout(clayout, row + 1, 1)
                    cs_layout.addWidget(cb_bold, row + 1, 2)
                    cs_layout.addWidget(cb_italic, row + 1, 3)
            cs_group.setLayout(cs_layout)
            if tabname in COLOR_SCHEME_NAMES:
                def_btn = self.create_button(
                    _("Reset to default values"),
                    lambda: self.reset_to_default(tabname))
                tabs.addTab(self.create_tab(cs_group, def_btn), tabname)
            else:
                tabs.addTab(self.create_tab(cs_group), tabname)

        vlayout = QVBoxLayout()
        vlayout.addWidget(tabs)
        self.setLayout(vlayout)
示例#2
0
 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
示例#3
0
文件: qthelpers.py 项目: jsantoul/ga
    def __init__(self,parent=None):
        super(Form,self).__init__(parent)

        df = testDf() # make up some data
        widget = DataFrameWidget(df)
        widget.resizeColumnsToContents()

        layout = QVBoxLayout()
        layout.addWidget(widget)
        self.setLayout(layout)
示例#4
0
    def setup_page(self):
        """
        Setup the page of the survey widget
        """

        population_group = QGroupBox(_("Alternatives population data"))
        population_bg = QButtonGroup(self)
        population_label = QLabel(_("Location of population data"))

        country_default_radio = self.create_radiobutton(
            _("Use country default population data"),
            'use_default',
            False,
            tip=_("Use country default population data"),
            button_group=population_bg)
        population_radio = self.create_radiobutton(
            _("The following file"),  # le fichier suivant",
            'enable',
            True,
            _("population data file for micrsosimulation"
              ),  # "Fichier de données pour la microsimulation",
            button_group=population_bg)
        population_file = self.create_browsefile("",
                                                 'data_file',
                                                 filters='*.h5')

        self.connect(country_default_radio, SIGNAL("toggled(bool)"),
                     population_file.setDisabled)
        self.connect(population_radio, SIGNAL("toggled(bool)"),
                     population_file.setEnabled)
        population_file_layout = QHBoxLayout()
        population_file_layout.addWidget(population_radio)
        population_file_layout.addWidget(population_file)

        population_layout = QVBoxLayout()
        population_layout.addWidget(population_label)
        population_layout.addWidget(country_default_radio)
        population_layout.addLayout(population_file_layout)
        population_group.setLayout(population_layout)
        vlayout = QVBoxLayout()
        vlayout.addWidget(population_group)
        vlayout.addStretch(1)
        self.setLayout(vlayout)
示例#5
0
 def setup_page(self):
     self.table = ShortcutsTable(self)
     self.connect(self.table.model,
                  SIGNAL("dataChanged(QModelIndex,QModelIndex)"),
                  lambda i1, i2, opt='': self.has_been_modified(opt))
     vlayout = QVBoxLayout()
     vlayout.addWidget(self.table)
     reset_btn = QPushButton(_("Reset to default values"))
     self.connect(reset_btn, SIGNAL('clicked()'), self.reset_to_default)
     vlayout.addWidget(reset_btn)
     self.setLayout(vlayout)
示例#6
0
    def setup_page(self):
        interface_group = QGroupBox(_("Interface"))
        styles = [str(txt) for txt in QStyleFactory.keys()]
        choices = zip(styles, [style.lower() for style in styles])
        style_combo = self.create_combobox(_('Qt windows style'),
                                           choices,
                                           'windows_style',
                                           default=self.main.default_style)
        newcb = self.create_checkbox
        vertdock_box = newcb(_("Vertical dockwidget title bars"),
                             'vertical_dockwidget_titlebars')
        verttabs_box = newcb(_("Vertical dockwidget tabs"), 'vertical_tabs')
        animated_box = newcb(_("Animated toolbars and dockwidgets"),
                             'animated_docks')
        margin_box = newcb(_("Custom dockwidget margin:"), 'use_custom_margin')
        margin_spin = self.create_spinbox("", "pixels", 'custom_margin', 0, 0,
                                          30)
        self.connect(margin_box, SIGNAL("toggled(bool)"),
                     margin_spin.setEnabled)
        margin_spin.setEnabled(self.get_option('use_custom_margin'))
        margins_layout = QHBoxLayout()
        margins_layout.addWidget(margin_box)
        margins_layout.addWidget(margin_spin)

        interface_layout = QVBoxLayout()
        interface_layout.addWidget(style_combo)
        interface_layout.addWidget(vertdock_box)
        interface_layout.addWidget(verttabs_box)
        interface_layout.addWidget(animated_box)
        interface_layout.addLayout(margins_layout)
        interface_group.setLayout(interface_layout)

        vlayout = QVBoxLayout()
        vlayout.addWidget(interface_group)
        vlayout.addStretch(1)
        self.setLayout(vlayout)
示例#7
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
示例#8
0
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)

        # Destroying the C++ object right after closing the dialog box,
        # otherwise it may be garbage-collected in another QThread
        # (e.g. the editor's analysis thread in Spyder), thus leading to
        # a segmentation fault on UNIX or an application crash on Windows
        self.setAttribute(Qt.WA_DeleteOnClose)

        self.contents_widget = QListWidget()
        self.contents_widget.setMovement(QListView.Static)
        self.contents_widget.setSpacing(1)

        bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Apply
                                | QDialogButtonBox.Cancel)
        self.apply_btn = bbox.button(QDialogButtonBox.Apply)
        self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
        self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
        self.connect(bbox, SIGNAL("clicked(QAbstractButton*)"),
                     self.button_clicked)

        self.pages_widget = QStackedWidget()
        self.connect(self.pages_widget, SIGNAL("currentChanged(int)"),
                     self.current_page_changed)

        self.connect(self.contents_widget, SIGNAL("currentRowChanged(int)"),
                     self.pages_widget.setCurrentIndex)
        self.contents_widget.setCurrentRow(0)

        hsplitter = QSplitter()
        hsplitter.addWidget(self.contents_widget)
        hsplitter.addWidget(self.pages_widget)

        btnlayout = QHBoxLayout()
        btnlayout.addStretch(1)
        btnlayout.addWidget(bbox)

        vlayout = QVBoxLayout()
        vlayout.addWidget(hsplitter)
        vlayout.addLayout(btnlayout)

        self.setLayout(vlayout)

        self.setWindowTitle(_("Preferences"))
        self.setWindowIcon(get_icon("configure.png"))
示例#9
0
 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
示例#10
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'))
示例#11
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)