Ejemplo n.º 1
0
 def create_fontgroup(self,
                      option=None,
                      text=None,
                      tip=None,
                      fontfilters=None):
     """Option=None -> setting plugin font"""
     fontlabel = QLabel(_("Font: "))
     fontbox = QFontComboBox()
     if fontfilters is not None:
         fontbox.setFontFilters(fontfilters)
     sizelabel = QLabel("  " + _("Size: "))
     sizebox = QSpinBox()
     sizebox.setRange(7, 100)
     self.fontboxes[(fontbox, sizebox)] = option
     layout = QHBoxLayout()
     for subwidget in (fontlabel, fontbox, sizelabel, sizebox):
         layout.addWidget(subwidget)
     layout.addStretch(1)
     if text is None:
         text = _("Font style")
     group = QGroupBox(text)
     group.setLayout(layout)
     if tip is not None:
         group.setToolTip(tip)
     return group
Ejemplo n.º 2
0
    def __init__(self, parent, prefix = None, suffix = None, option = None, min_ = None, max_ = None,
                 step = None, tip = None, value = None, changed =None):
        super(MyDoubleSpinBox, self).__init__(parent)
    
        if prefix:
            plabel = QLabel(prefix)
        else:
            plabel = None
        if suffix:
            slabel = QLabel(suffix)
        else:
            slabel = None
        spinbox = QDoubleSpinBox(parent)
        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)
        layout = QHBoxLayout()
        for subwidget in (plabel, spinbox, slabel):
            if subwidget is not None:
                layout.addWidget(subwidget)
        if value is not None:
            spinbox.setValue(value)
        
        if changed is not None:
            self.connect(spinbox, SIGNAL('valueChanged(double)'), changed)

        layout.addStretch(1)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)
        self.spin = spinbox
Ejemplo n.º 3
0
 def __init__(self, parent, statusbar):
     StatusBarWidget.__init__(self, parent, statusbar)
     layout = self.layout()
     layout.addWidget(QLabel(_("End-of-lines:")))
     self.eol = QLabel()
     self.eol.setFont(self.label_font)
     layout.addWidget(self.eol)
     layout.addSpacing(20)
Ejemplo n.º 4
0
 def __init__(self, parent, statusbar):
     StatusBarWidget.__init__(self, parent, statusbar)
     layout = self.layout()
     layout.addWidget(QLabel(_("Encoding:")))
     self.encoding = QLabel()
     self.encoding.setFont(self.label_font)
     layout.addWidget(self.encoding)
     layout.addSpacing(20)
Ejemplo n.º 5
0
 def __init__(self, parent, statusbar):
     StatusBarWidget.__init__(self, parent, statusbar)
     layout = self.layout()
     layout.addWidget(QLabel(_("Permissions:")))
     self.readwrite = QLabel()
     self.readwrite.setFont(self.label_font)
     layout.addWidget(self.readwrite)
     layout.addSpacing(20)
Ejemplo n.º 6
0
class EncodingStatus(StatusBarWidget):
    def __init__(self, parent, statusbar):
        StatusBarWidget.__init__(self, parent, statusbar)
        layout = self.layout()
        layout.addWidget(QLabel(_("Encoding:")))
        self.encoding = QLabel()
        self.encoding.setFont(self.label_font)
        layout.addWidget(self.encoding)
        layout.addSpacing(20)

    def encoding_changed(self, encoding):
        self.encoding.setText(str(encoding).upper().ljust(15))
Ejemplo n.º 7
0
Archivo: status.py Proyecto: Pyke75/ga
 def __init__(self, parent, statusbar):
     StatusBarWidget.__init__(self, parent, statusbar)
     layout = self.layout()
     layout.addWidget(QLabel(_("Line:")))
     self.line = QLabel()
     self.line.setFont(self.label_font)
     layout.addWidget(self.line)
     layout.addWidget(QLabel(_("Column:")))
     self.column = QLabel()
     self.column.setFont(self.label_font)
     layout.addWidget(self.column)
     self.setLayout(layout)
Ejemplo n.º 8
0
Archivo: status.py Proyecto: Pyke75/ga
class EncodingStatus(StatusBarWidget):
    def __init__(self, parent, statusbar):
        StatusBarWidget.__init__(self, parent, statusbar)
        layout = self.layout()
        layout.addWidget(QLabel(_("Encoding:")))
        self.encoding = QLabel()
        self.encoding.setFont(self.label_font)
        layout.addWidget(self.encoding)
        layout.addSpacing(20)
        
    def encoding_changed(self, encoding):
        self.encoding.setText(str(encoding).upper().ljust(15))
Ejemplo n.º 9
0
class EOLStatus(StatusBarWidget):
    def __init__(self, parent, statusbar):
        StatusBarWidget.__init__(self, parent, statusbar)
        layout = self.layout()
        layout.addWidget(QLabel(_("End-of-lines:")))
        self.eol = QLabel()
        self.eol.setFont(self.label_font)
        layout.addWidget(self.eol)
        layout.addSpacing(20)

    def eol_changed(self, os_name):
        os_name = unicode(os_name)
        self.eol.setText({"nt": "CRLF", "posix": "LF"}.get(os_name, "CR"))
Ejemplo n.º 10
0
Archivo: status.py Proyecto: Pyke75/ga
class EOLStatus(StatusBarWidget):
    def __init__(self, parent, statusbar):
        StatusBarWidget.__init__(self, parent, statusbar)
        layout = self.layout()
        layout.addWidget(QLabel(_("End-of-lines:")))
        self.eol = QLabel()
        self.eol.setFont(self.label_font)
        layout.addWidget(self.eol)
        layout.addSpacing(20)
        
    def eol_changed(self, os_name):
        os_name = unicode(os_name)
        self.eol.setText({"nt": "CRLF", "posix": "LF"}.get(os_name, "CR"))
Ejemplo n.º 11
0
class ReadWriteStatus(StatusBarWidget):
    def __init__(self, parent, statusbar):
        StatusBarWidget.__init__(self, parent, statusbar)
        layout = self.layout()
        layout.addWidget(QLabel(_("Permissions:")))
        self.readwrite = QLabel()
        self.readwrite.setFont(self.label_font)
        layout.addWidget(self.readwrite)
        layout.addSpacing(20)

    def readonly_changed(self, readonly):
        readwrite = "R" if readonly else "RW"
        self.readwrite.setText(readwrite.ljust(3))
Ejemplo n.º 12
0
Archivo: status.py Proyecto: Pyke75/ga
class ReadWriteStatus(StatusBarWidget):
    def __init__(self, parent, statusbar):
        StatusBarWidget.__init__(self, parent, statusbar)
        layout = self.layout()
        layout.addWidget(QLabel(_("Permissions:")))
        self.readwrite = QLabel()
        self.readwrite.setFont(self.label_font)
        layout.addWidget(self.readwrite)
        layout.addSpacing(20)
        
    def readonly_changed(self, readonly):
        readwrite = "R" if readonly else "RW"
        self.readwrite.setText(readwrite.ljust(3))
Ejemplo n.º 13
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
Ejemplo n.º 14
0
 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
Ejemplo n.º 15
0
 def __init__(self, parent, statusbar):
     StatusBarWidget.__init__(self, parent, statusbar)
     self.setToolTip(self.TIP)
     layout = self.layout()
     layout.addWidget(QLabel(self.TITLE))
     self.label = QLabel()
     self.label.setFont(self.label_font)
     layout.addWidget(self.label)
     layout.addSpacing(20)
     if self.is_supported():
         self.timer = QTimer()
         self.connect(self.timer, SIGNAL('timeout()'), self.update_label)
         self.timer.start(2000)
     else:
         self.timer = None
         self.hide()
Ejemplo n.º 16
0
Archivo: status.py Proyecto: Pyke75/ga
 def __init__(self, parent, statusbar):
     StatusBarWidget.__init__(self, parent, statusbar)
     layout = self.layout()
     layout.addWidget(QLabel(_("Permissions:")))
     self.readwrite = QLabel()
     self.readwrite.setFont(self.label_font)
     layout.addWidget(self.readwrite)
     layout.addSpacing(20)
Ejemplo n.º 17
0
Archivo: status.py Proyecto: Pyke75/ga
 def __init__(self, parent, statusbar):
     StatusBarWidget.__init__(self, parent, statusbar)
     layout = self.layout()
     layout.addWidget(QLabel(_("End-of-lines:")))
     self.eol = QLabel()
     self.eol.setFont(self.label_font)
     layout.addWidget(self.eol)
     layout.addSpacing(20)
Ejemplo n.º 18
0
Archivo: status.py Proyecto: Pyke75/ga
 def __init__(self, parent, statusbar):
     StatusBarWidget.__init__(self, parent, statusbar)
     layout = self.layout()
     layout.addWidget(QLabel(_("Encoding:")))
     self.encoding = QLabel()
     self.encoding.setFont(self.label_font)
     layout.addWidget(self.encoding)
     layout.addSpacing(20)
Ejemplo n.º 19
0
class BaseTimerStatus(StatusBarWidget):
    TITLE = None
    TIP = None

    def __init__(self, parent, statusbar):
        StatusBarWidget.__init__(self, parent, statusbar)
        self.setToolTip(self.TIP)
        layout = self.layout()
        layout.addWidget(QLabel(self.TITLE))
        self.label = QLabel()
        self.label.setFont(self.label_font)
        layout.addWidget(self.label)
        layout.addSpacing(20)
        if self.is_supported():
            self.timer = QTimer()
            self.connect(self.timer, SIGNAL('timeout()'), self.update_label)
            self.timer.start(2000)
        else:
            self.timer = None
            self.hide()

    def set_interval(self, interval):
        """Set timer interval (ms)"""
        if self.timer is not None:
            self.timer.setInterval(interval)

    def import_test(self):
        """Raise ImportError if feature is not supported"""
        raise NotImplementedError

    def is_supported(self):
        """Return True if feature is supported"""
        try:
            self.import_test()
            return True
        except ImportError:
            return False

    def get_value(self):
        """Return value (e.g. CPU or memory usage)"""
        raise NotImplementedError

    def update_label(self):
        """Update status label widget, if widget is visible"""
        if self.isVisible():
            self.label.setText('%d %%' % self.get_value())
Ejemplo n.º 20
0
Archivo: status.py Proyecto: Pyke75/ga
class BaseTimerStatus(StatusBarWidget):
    TITLE = None
    TIP = None
    def __init__(self, parent, statusbar):
        StatusBarWidget.__init__(self, parent, statusbar)
        self.setToolTip(self.TIP)
        layout = self.layout()
        layout.addWidget(QLabel(self.TITLE))
        self.label = QLabel()
        self.label.setFont(self.label_font)
        layout.addWidget(self.label)
        layout.addSpacing(20)
        if self.is_supported():
            self.timer = QTimer()
            self.connect(self.timer, SIGNAL('timeout()'), self.update_label)
            self.timer.start(2000)
        else:
            self.timer = None
            self.hide()
    
    def set_interval(self, interval):
        """Set timer interval (ms)"""
        if self.timer is not None:
            self.timer.setInterval(interval)
    
    def import_test(self):
        """Raise ImportError if feature is not supported"""
        raise NotImplementedError

    def is_supported(self):
        """Return True if feature is supported"""
        try:
            self.import_test()
            return True
        except ImportError:
            return False
    
    def get_value(self):
        """Return value (e.g. CPU or memory usage)"""
        raise NotImplementedError
        
    def update_label(self):
        """Update status label widget, if widget is visible"""
        if self.isVisible():
            self.label.setText('%d %%' % self.get_value())
Ejemplo n.º 21
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
Ejemplo n.º 22
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'))
Ejemplo n.º 23
0
class CursorPositionStatus(StatusBarWidget):
    def __init__(self, parent, statusbar):
        StatusBarWidget.__init__(self, parent, statusbar)
        layout = self.layout()
        layout.addWidget(QLabel(_("Line:")))
        self.line = QLabel()
        self.line.setFont(self.label_font)
        layout.addWidget(self.line)
        layout.addWidget(QLabel(_("Column:")))
        self.column = QLabel()
        self.column.setFont(self.label_font)
        layout.addWidget(self.column)
        self.setLayout(layout)

    def cursor_position_changed(self, line, index):
        self.line.setText("%-6d" % (line + 1))
        self.column.setText("%-4d" % (index + 1))
Ejemplo n.º 24
0
Archivo: status.py Proyecto: Pyke75/ga
class CursorPositionStatus(StatusBarWidget):
    def __init__(self, parent, statusbar):
        StatusBarWidget.__init__(self, parent, statusbar)
        layout = self.layout()
        layout.addWidget(QLabel(_("Line:")))
        self.line = QLabel()
        self.line.setFont(self.label_font)
        layout.addWidget(self.line)
        layout.addWidget(QLabel(_("Column:")))
        self.column = QLabel()
        self.column.setFont(self.label_font)
        layout.addWidget(self.column)
        self.setLayout(layout)
        
    def cursor_position_changed(self, line, index):
        self.line.setText("%-6d" % (line+1))
        self.column.setText("%-4d" % (index+1))
Ejemplo n.º 25
0
 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
Ejemplo n.º 26
0
Archivo: status.py Proyecto: Pyke75/ga
 def __init__(self, parent, statusbar):
     StatusBarWidget.__init__(self, parent, statusbar)
     self.setToolTip(self.TIP)
     layout = self.layout()
     layout.addWidget(QLabel(self.TITLE))
     self.label = QLabel()
     self.label.setFont(self.label_font)
     layout.addWidget(self.label)
     layout.addSpacing(20)
     if self.is_supported():
         self.timer = QTimer()
         self.connect(self.timer, SIGNAL('timeout()'), self.update_label)
         self.timer.start(2000)
     else:
         self.timer = None
         self.hide()
Ejemplo n.º 27
0
 def __init__(self, parent, statusbar):
     StatusBarWidget.__init__(self, parent, statusbar)
     layout = self.layout()
     layout.addWidget(QLabel(_("Line:")))
     self.line = QLabel()
     self.line.setFont(self.label_font)
     layout.addWidget(self.line)
     layout.addWidget(QLabel(_("Column:")))
     self.column = QLabel()
     self.column.setFont(self.label_font)
     layout.addWidget(self.column)
     self.setLayout(layout)
Ejemplo n.º 28
0
    def __init__(self, parent, text, choices = None, option = None, tip = None):
        super(MyComboBox, self).__init__(parent)
        """choices: couples (name, key)"""
        label = QLabel(text)
        combobox = QComboBox(parent)
        if tip is not None:
            combobox.setToolTip(tip)
        if choices:
            for name, key in choices:
                combobox.addItem(name, to_qvariant(key))

        layout = QHBoxLayout()
        for subwidget in (label, combobox):
            layout.addWidget(subwidget)
        layout.addStretch(1)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(layout)
        self.box = combobox
Ejemplo n.º 29
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)
Ejemplo n.º 30
0
    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
Ejemplo n.º 31
0
 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
Ejemplo n.º 32
0
 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
Ejemplo n.º 33
0
def get_image_label(name, default="not_found.png"):
    """Return image inside a QLabel object"""
    label = QLabel()
    label.setPixmap(QPixmap(get_image_path(name, default)))
    return label
Ejemplo n.º 34
0
Archivo: config.py Proyecto: Pyke75/ga
def get_image_label( name, default="not_found.png" ):
    """Return image inside a QLabel object"""
    label = QLabel()
    label.setPixmap(QPixmap(get_image_path(name, default)))
    return label