示例#1
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
示例#2
0
文件: qthelpers.py 项目: jsantoul/ga
    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
示例#3
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
示例#4
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
示例#5
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
示例#6
0
 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
示例#7
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)
示例#8
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)
示例#9
0
文件: qthelpers.py 项目: jsantoul/ga
    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
示例#10
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
示例#11
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
示例#12
0
 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
示例#13
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
示例#14
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
示例#15
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
示例#16
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