示例#1
0
 def select_file(self):
     """Open a file selection dialog box"""
     fname = self.item.from_string(to_text_string(self.edit.text()))
     if isinstance(fname, list):
         fname = osp.dirname(fname[0])
     parent = self.parent_layout.parent
     _temp = sys.stdout
     sys.stdout = None
     if len(fname) == 0:
         fname = self.basedir
     _formats = self.item.get_prop_value("data", "formats")
     formats = [to_text_string(format).lower() for format in _formats]
     filter_lines = [(_("%s files")+" (*.%s)") % (format.upper(), format)
                     for format in formats]
     all_filter = _("All supported files")+" (*.%s)" % " *.".join(formats)
     if len(formats) > 1:
         if self.all_files_first:
             filter_lines.insert(0, all_filter)
         else:
             filter_lines.append(all_filter)
     if fname is None:
         fname = ""
     child_title = _get_child_title_func(parent)
     fname, _filter = self.filedialog(parent, child_title(self.item), fname,
                                      "\n".join(filter_lines))
     sys.stdout = _temp
     if fname:
         if isinstance(fname, list):
             fname = to_text_string(fname)
         self.edit.setText(fname)
示例#2
0
 def __init__(self, item, parent_layout):
     super(FloatArrayWidget, self).__init__(item, parent_layout)
     _label = item.get_prop_value("display", "label")
     self.groupbox = self.group = QGroupBox(_label)
     self.layout = QGridLayout()
     self.layout.setAlignment(Qt.AlignLeft)
     self.groupbox.setLayout(self.layout)
     
     self.first_line, self.dim_label = get_image_layout("shape.png",
                                _("Number of rows x Number of columns"))
     edit_button = QPushButton(get_icon("arredit.png"), "")
     edit_button.setToolTip(_("Edit array contents"))
     edit_button.setMaximumWidth(32)
     self.first_line.addWidget(edit_button)
     self.layout.addLayout(self.first_line, 0, 0)
     
     self.min_line, self.min_label = get_image_layout("min.png",
                                              _("Smallest element in array"))
     self.layout.addLayout(self.min_line, 1, 0)
     self.max_line, self.max_label = get_image_layout("max.png",
                                              _("Largest element in array"))
     self.layout.addLayout(self.max_line, 2, 0)
     
     edit_button.clicked.connect(self.edit_array)
     self.arr = None # le tableau si il a été modifié
     self.instance = None
示例#3
0
文件: styles.py 项目: HaMF/guiqwt
 def test_changeconfig(self):
     obj = QPen( Qt.red, 2, Qt.SolidLine )
     ls = LineStyleParam(_("Line style"))
     ls.update_param( obj )
     ls.write_config(CONF, "ls", "" )
     ls = LineStyleParam(_("Line style"))
     ls.read_config(CONF, "ls", "" )
     self.assertEqual(ls.width, 2)
     self.assertEqual(ls.style, "SolidLine")
     self.assertEqual(ls.color, "#ff0000")
示例#4
0
 def get_auto_help(self, instance):
     """Override DataItem method"""
     auto_help = super(IntItem, self).get_auto_help(instance)
     even = self.get_prop_value("data", instance, "even")
     if even is not None:
         if even:
             auto_help += ", "+_("even")
         else:
             auto_help += ", "+_("odd")
     return auto_help
示例#5
0
 def check(self):
     is_ok = True
     for edl in self.edit_layout:
         if not edl.check_all_values():
             is_ok = False
     if not is_ok:
         QMessageBox.warning(self, self.instance.get_title(),
                             _("Some required entries are incorrect")+".\n",
                             _("Please check highlighted fields."))
         return False
     return True
示例#6
0
文件: styles.py 项目: HaMF/guiqwt
 def test_changeconfig(self):
     obj = QwtSymbol( QwtSymbol.Rect, QBrush(Qt.black), QPen(Qt.yellow),
                      QSize(3, 3) )
     sym = SymbolParam(_("Symbol"))
     sym.update_param( obj )
     sym.write_config(CONF, "sym", "" )
     sym = SymbolParam(_("Symbol"))
     sym.read_config(CONF, "sym", "" )
     self.assertEqual(sym.marker, "Rect")
     self.assertEqual(sym.size, 3)
     self.assertEqual(sym.edgecolor, "#ffff00")
     self.assertEqual(sym.facecolor, "#000000")
     sym.build_symbol()
示例#7
0
文件: styles.py 项目: HaMF/guiqwt
 def test_update(self):
     obj = QPen( Qt.red, 2, Qt.SolidLine )
     ls = LineStyleParam(_("Line style"))
     ls.update_param( obj )
     self.assertEqual(ls.width, 2)
     self.assertEqual(ls.style, "SolidLine")
     self.assertEqual(ls.color, "#ff0000")
示例#8
0
 def __init__(self, package, parent=None):
     QSplitter.__init__(self, parent)
     self.setWindowTitle(_("Tests - %s module") % package.__name__)
     self.setWindowIcon(get_icon("%s.svg" % package.__name__, "guidata.svg"))
     
     test_package_name = '%s.tests' % package.__name__
     _temp = __import__(test_package_name)
     test_package = sys.modules[test_package_name]
     
     tests = get_tests(test_package)
     listwidget = QListWidget(self)
     listwidget.addItems([osp.basename(test.filename) for test in tests])
     
     self.properties = TestPropertiesWidget(self)
     
     self.addWidget(listwidget)
     self.addWidget(self.properties)
     
     self.properties.run_button.clicked.connect(
                             lambda: tests[listwidget.currentRow()].run())
     self.properties.quit_button.clicked.connect(self.close)
     listwidget.currentRowChanged.connect(
                         lambda row: self.properties.set_item(tests[row]))
     listwidget.itemActivated.connect(
                         lambda: tests[listwidget.currentRow()].run())
     listwidget.setCurrentRow(0)
     
     QShortcut(QKeySequence("Escape"), self, self.close)
         
     self.setSizes([150, 1])
     self.setStretchFactor(1, 1)
     self.resize(QSize(950, 600))
     self.properties.set_item(tests[0])
示例#9
0
 def __init__(self, item, parent_layout):
     super(TextEditWidget, self).__init__(item, parent_layout)
     self.edit = self.group = QTextEdit()
     self.edit.setToolTip(item.get_help())
     if hasattr(item, "min_equals_max") and item.min_equals_max():
         if item.check_item():
             self.edit.setEnabled(False)
         self.edit.setToolTip(_("Value is forced to %d") % item.get_max())
     self.edit.textChanged.connect(self.text_changed)
示例#10
0
文件: styles.py 项目: HaMF/guiqwt
 def test_update(self):
     obj = QwtSymbol( QwtSymbol.Rect, QBrush(Qt.black), QPen(Qt.yellow),
                      QSize(3, 3) )
     sym = SymbolParam(_("Symbol"))
     sym.update_param( obj )
     self.assertEqual(sym.marker, "Rect")
     self.assertEqual(sym.size, 3)
     self.assertEqual(sym.edgecolor, "#ffff00")
     self.assertEqual(sym.facecolor, "#000000")
示例#11
0
 def get_description(self):
     doc = self.module.__doc__
     if doc is None or not doc.strip():
         return _("No description available")
     else:
         lines = doc.strip().splitlines()
         format = '<span style=\'color: #2222FF\'><b>%s</b></span>'
         lines[0] = format % lines[0]
         return '<br>'.join(lines)
示例#12
0
文件: guitest.py 项目: mindw/guidata
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        font = QFont(get_family(MONOSPACE), 10, QFont.Normal)

        info_icon = QLabel()
        icon = get_std_icon('MessageBoxInformation').pixmap(24, 24)
        info_icon.setPixmap(icon)
        info_icon.setFixedWidth(32)
        info_icon.setAlignment(Qt.AlignTop)
        self.desc_label = QLabel()
        self.desc_label.setWordWrap(True)
        self.desc_label.setAlignment(Qt.AlignTop)
        self.desc_label.setFont(font)
        group_desc = QGroupBox(_("Description"), self)
        layout = QHBoxLayout()
        layout.addWidget(info_icon)
        layout.addWidget(self.desc_label)
        group_desc.setLayout(layout)

        self.editor = CodeEditor(self)
        self.editor.setup_editor(linenumbers=True, font=font)
        self.editor.setReadOnly(True)
        group_code = QGroupBox(_("Source code"), self)
        layout = QVBoxLayout()
        layout.addWidget(self.editor)
        group_code.setLayout(layout)

        self.run_button = QPushButton(get_icon("apply.png"),
                                      _("Run this script"), self)
        self.quit_button = QPushButton(get_icon("exit.png"), _("Quit"), self)
        hlayout = QHBoxLayout()
        hlayout.addWidget(self.run_button)
        hlayout.addStretch()
        hlayout.addWidget(self.quit_button)

        vlayout = QVBoxLayout()
        vlayout.addWidget(group_desc)
        vlayout.addWidget(group_code)
        vlayout.addLayout(hlayout)
        self.setLayout(vlayout)
示例#13
0
 def __init__(self, parent):
     QWidget.__init__(self, parent)
     font = QFont(get_family(MONOSPACE), 10, QFont.Normal)
     
     info_icon = QLabel()
     icon = get_std_icon('MessageBoxInformation').pixmap(24, 24)
     info_icon.setPixmap(icon)
     info_icon.setFixedWidth(32)
     info_icon.setAlignment(Qt.AlignTop)
     self.desc_label = QLabel()
     self.desc_label.setWordWrap(True)
     self.desc_label.setAlignment(Qt.AlignTop)
     self.desc_label.setFont(font)
     group_desc = QGroupBox(_("Description"), self)
     layout = QHBoxLayout()
     layout.addWidget(info_icon)
     layout.addWidget(self.desc_label)
     group_desc.setLayout(layout)
     
     self.editor = CodeEditor(self)
     self.editor.setup_editor(linenumbers=True, font=font)
     self.editor.setReadOnly(True)
     group_code = QGroupBox(_("Source code"), self)
     layout = QVBoxLayout()
     layout.addWidget(self.editor)
     group_code.setLayout(layout)
     
     self.run_button = QPushButton(get_icon("apply.png"),
                                   _("Run this script"), self)
     self.quit_button = QPushButton(get_icon("exit.png"), _("Quit"), self)
     hlayout = QHBoxLayout()
     hlayout.addWidget(self.run_button)
     hlayout.addStretch()
     hlayout.addWidget(self.quit_button)
     
     vlayout = QVBoxLayout()
     vlayout.addWidget(group_desc)
     vlayout.addWidget(group_code)
     vlayout.addLayout(hlayout)
     self.setLayout(vlayout)
示例#14
0
 def __init__(self, label, klass, button_text=None, button_icon=None, show_button=True, wordwrap=False, **kwargs):
     DataSetShowGroupBox.__init__(self, label, klass, wordwrap=wordwrap, **kwargs)
     if show_button:
         if button_text is None:
             button_text = _("Apply")
         if button_icon is None:
             button_icon = get_icon("apply.png")
         elif is_text_string(button_icon):
             button_icon = get_icon(button_icon)
         apply_btn = QPushButton(button_icon, button_text, self)
         apply_btn.clicked.connect(self.set)
         layout = self.edit.layout
         layout.addWidget(apply_btn, layout.rowCount(), 0, 1, -1, Qt.AlignRight)
示例#15
0
 def __init__(self, label, klass, button_text=None, button_icon=None,
              show_button=True, wordwrap=False, **kwargs):
     DataSetShowGroupBox.__init__(self, label, klass, wordwrap=wordwrap,
                                  **kwargs)
     if show_button:
         if button_text is None:
             button_text = _("Apply")
         if button_icon is None:
             button_icon = get_icon("apply.png")
         elif is_text_string(button_icon):
             button_icon = get_icon(button_icon)
         apply_btn = QPushButton(button_icon, button_text, self)
         apply_btn.clicked.connect(self.set)
         layout = self.edit.layout
         layout.addWidget(apply_btn, layout.rowCount(),
                          0, 1, -1, Qt.AlignRight)
示例#16
0
 def get_auto_help(self, instance):
     """Override DataItem method"""
     auto_help = {int: _("integer"), float: _("float")}[self.type]
     _min = self.get_prop_value("data", instance, "min")
     _max = self.get_prop_value("data", instance, "max")
     nonzero = self.get_prop_value("data", instance, "nonzero")
     unit = self.get_prop_value("display", instance, "unit")
     if _min is not None and _max is not None:
         auto_help += _(" between ") + str(_min) + _(" and ") + str(_max)
     elif _min is not None:
         auto_help += _(" higher than ") + str(_min)
     elif _max is not None:
         auto_help += _(" lower than ") + str(_max)
     if nonzero:
         auto_help += ", " + _("non zero")
     if unit:
         auto_help += ", %s %s" % (_("unit:"), unit)
     return auto_help
示例#17
0
 def get_auto_help(self, instance):
     """Override DataItem method"""
     auto_help = {int: _('integer'), float: _('float')}[self.type]
     _min = self.get_prop_value("data", instance, "min")
     _max = self.get_prop_value("data", instance, "max")
     nonzero = self.get_prop_value("data", instance, "nonzero")
     unit = self.get_prop_value("display", instance, "unit")
     if _min is not None and _max is not None:
         auto_help += _(" between ")+str(_min)+ _(" and ")+str(_max)
     elif _min is not None:
         auto_help += _(" higher than ")+str(_min)
     elif _max is not None:
         auto_help += _(" lower than ")+str(_max)
     if nonzero:
         auto_help += ", "+_("non zero")
     if unit:
         auto_help += (", %s %s" % (_("unit:"), unit))
     return auto_help
示例#18
0
 def __init__(self,
              label,
              klass,
              button_text=None,
              button_icon=None,
              show_button=True,
              wordwrap=False,
              **kwargs):
     super().__init__(label, klass, wordwrap=wordwrap, **kwargs)
     if show_button:
         if button_text is None:
             button_text = _("Apply")
         if button_icon is None:
             button_icon = get_icon("apply.png")
         elif isinstance(button_icon, str):
             button_icon = get_icon(button_icon)
         apply_btn = QtWidgets.QPushButton(button_icon, button_text, self)
         apply_btn.clicked.connect(self.set)
         layout = self.edit.layout
         layout.addWidget(apply_btn, layout.rowCount(), 0, 1, -1,
                          QtCore.Qt.AlignRight)
示例#19
0
文件: styles.py 项目: HaMF/guiqwt
 def test_saveconfig(self):
     ls = LineStyleParam(_("Line style"))
     ls.write_config(CONF, "ls", "" )
     ls = LineStyleParam(_("Line style"))
     ls.read_config(CONF, "ls", "" )
示例#20
0
# -*- coding: utf-8 -*-
#
# Copyright © 2012 CEA
# Pierre Raybaut
# Licensed under the terms of the CECILL License
# (see guidata/__init__.py for details)

"""Little translation test"""

from __future__ import print_function

SHOW = False # Do not show test in GUI-based test launcher

from guidata.config import _

translations = (_("Some required entries are incorrect"),)

if __name__ == '__main__':
    for text in translations:
        print(text)
示例#21
0
 def get_auto_help(self, instance):
     """Override DataItem method"""
     formats = self.get_prop("data", "formats")
     return _("all file types") if formats == ['*'] \
            else _("supported file types:") + " *.%s" % ", *.".join(formats)
示例#22
0
 def get_auto_help(self, instance):
     """Override DataItem method"""
     formats = self.get_prop("data", "formats")
     return (_("all file types") if formats == ["*"] else
             _("supported file types:") + " *.%s" % ", *.".join(formats))
示例#23
0
文件: styles.py 项目: zgpglee/guiqwt
 def test_saveconfig(self):
     ls = LineStyleParam(_("Line style"))
     ls.write_config(CONF, "ls", "")
     ls = LineStyleParam(_("Line style"))
     ls.read_config(CONF, "ls", "")
示例#24
0
文件: styles.py 项目: zgpglee/guiqwt
 def test_default(self):
     ls = LineStyleParam(_("Line style"))
     _obj = ls.build_pen()
示例#25
0
文件: styles.py 项目: zgpglee/guiqwt
 def test_saveconfig(self):
     sym = SymbolParam(_("Symbol"))
     sym.write_config(CONF, "sym", "")
     sym = SymbolParam(_("Symbol"))
     sym.read_config(CONF, "sym", "")
示例#26
0
文件: styles.py 项目: zgpglee/guiqwt
 def test_default(self):
     sym = SymbolParam(_("Symbol"))
     _obj = sym.build_symbol()
示例#27
0
文件: styles.py 项目: HaMF/guiqwt
 def test_saveconfig(self):
     sym = SymbolParam(_("Symbol"))
     sym.write_config(CONF, "sym", "" )
     sym = SymbolParam(_("Symbol"))
     sym.read_config(CONF, "sym", "" )
示例#28
0
文件: styles.py 项目: HaMF/guiqwt
 def test_default(self):
     sym = SymbolParam(_("Symbol"))
     _obj = sym.build_symbol()
示例#29
0
文件: styles.py 项目: HaMF/guiqwt
 def test_default(self):
     ls = LineStyleParam(_("Line style"))
     _obj = ls.build_pen()
示例#30
0
# -*- coding: utf-8 -*-
#
# Copyright © 2012 CEA
# Pierre Raybaut
# Licensed under the terms of the CECILL License
# (see guidata/__init__.py for details)
"""Little translation test"""

from __future__ import print_function

SHOW = False  # Do not show test in GUI-based test launcher

from guidata.config import _

translations = (_("Some required entries are incorrect"), )

if __name__ == '__main__':
    for text in translations:
        print(text)