コード例 #1
0
ファイル: formlayout.py プロジェクト: pallavtinna/matplotlib
 def set_color(self, color):
     if color != self._color:
         self._color = color
         self.colorChanged.emit(self._color)
         pixmap = QtGui.QPixmap(self.iconSize())
         pixmap.fill(color)
         self.setIcon(QtGui.QIcon(pixmap))
コード例 #2
0
ファイル: formlayout.py プロジェクト: dimkal/matplotlib
    def __init__(self, value, parent=None):
        QtGui.QGridLayout.__init__(self)
        font = tuple_to_qfont(value)
        assert font is not None

        # Font family
        self.family = QtGui.QFontComboBox(parent)
        self.family.setCurrentFont(font)
        self.addWidget(self.family, 0, 0, 1, -1)

        # Font size
        self.size = QtGui.QComboBox(parent)
        self.size.setEditable(True)
        sizelist = list(xrange(6, 12)) + list(xrange(12, 30, 2)) + [36, 48, 72]
        size = font.pointSize()
        if size not in sizelist:
            sizelist.append(size)
            sizelist.sort()
        self.size.addItems([str(s) for s in sizelist])
        self.size.setCurrentIndex(sizelist.index(size))
        self.addWidget(self.size, 1, 0)

        # Italic or not
        self.italic = QtGui.QCheckBox(self.tr("Italic"), parent)
        self.italic.setChecked(font.italic())
        self.addWidget(self.italic, 1, 1)

        # Bold or not
        self.bold = QtGui.QCheckBox(self.tr("Bold"), parent)
        self.bold.setChecked(font.bold())
        self.addWidget(self.bold, 1, 2)
コード例 #3
0
ファイル: formlayout.py プロジェクト: dimkal/matplotlib
 def set_color(self, color):
     if color != self._color:
         self._color = color
         self.emit(QtCore.SIGNAL("colorChanged(QColor)"), self._color)
         pixmap = QtGui.QPixmap(self.iconSize())
         pixmap.fill(color)
         self.setIcon(QtGui.QIcon(pixmap))
コード例 #4
0
ファイル: formlayout.py プロジェクト: dimkal/matplotlib
 def __init__(self, data, comment="", parent=None):
     QtGui.QWidget.__init__(self, parent)
     from copy import deepcopy
     self.data = deepcopy(data)
     self.widgets = []
     self.formlayout = QtGui.QFormLayout(self)
     if comment:
         self.formlayout.addRow(QtGui.QLabel(comment))
         self.formlayout.addRow(QtGui.QLabel(" "))
     if DEBUG:
         print("\n" + ("*" * 80))
         print("DATA:", self.data)
         print("*" * 80)
         print("COMMENT:", comment)
         print("*" * 80)
コード例 #5
0
ファイル: formlayout.py プロジェクト: dimkal/matplotlib
 def __init__(self, datalist, comment="", parent=None):
     QtGui.QWidget.__init__(self, parent)
     layout = QtGui.QVBoxLayout()
     self.tabwidget = QtGui.QTabWidget()
     layout.addWidget(self.tabwidget)
     self.setLayout(layout)
     self.widgetlist = []
     for data, title, comment in datalist:
         if len(data[0]) == 3:
             widget = FormComboWidget(data, comment=comment, parent=self)
         else:
             widget = FormWidget(data, comment=comment, parent=self)
         index = self.tabwidget.addTab(widget, title)
         self.tabwidget.setTabToolTip(index, comment)
         self.widgetlist.append(widget)
コード例 #6
0
ファイル: formlayout.py プロジェクト: dimkal/matplotlib
    def __init__(self,
                 data,
                 title="",
                 comment="",
                 icon=None,
                 parent=None,
                 apply=None):
        QtGui.QDialog.__init__(self, parent)

        self.apply_callback = apply

        # Form
        if isinstance(data[0][0], (list, tuple)):
            self.formwidget = FormTabWidget(data, comment=comment, parent=self)
        elif len(data[0]) == 3:
            self.formwidget = FormComboWidget(data,
                                              comment=comment,
                                              parent=self)
        else:
            self.formwidget = FormWidget(data, comment=comment, parent=self)
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.formwidget)

        self.float_fields = []
        self.formwidget.setup()

        # Button box
        self.bbox = bbox = QtGui.QDialogButtonBox(
            QtGui.QDialogButtonBox.Ok
            | QtGui.QDialogButtonBox.Cancel)
        self.connect(self.formwidget, QtCore.SIGNAL('update_buttons()'),
                     self.update_buttons)
        if self.apply_callback is not None:
            apply_btn = bbox.addButton(QtGui.QDialogButtonBox.Apply)
            self.connect(apply_btn, QtCore.SIGNAL("clicked()"), self.apply)
        self.connect(bbox, QtCore.SIGNAL("accepted()"),
                     QtCore.SLOT("accept()"))
        self.connect(bbox, QtCore.SIGNAL("rejected()"),
                     QtCore.SLOT("reject()"))
        layout.addWidget(bbox)

        self.setLayout(layout)

        self.setWindowTitle(title)
        if not isinstance(icon, QtGui.QIcon):
            icon = QtGui.QWidget().style().standardIcon(
                QtGui.QStyle.SP_MessageBoxQuestion)
        self.setWindowIcon(icon)
コード例 #7
0
ファイル: formlayout.py プロジェクト: pallavtinna/matplotlib
    def __init__(self, datalist, comment="", parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QVBoxLayout()
        self.setLayout(layout)
        self.combobox = QtGui.QComboBox()
        layout.addWidget(self.combobox)

        self.stackwidget = QtGui.QStackedWidget(self)
        layout.addWidget(self.stackwidget)
        self.combobox.currentIndexChanged.connect(self.stackwidget.setCurrentIndex)

        self.widgetlist = []
        for data, title, comment in datalist:
            self.combobox.addItem(title)
            widget = FormWidget(data, comment=comment, parent=self)
            self.stackwidget.addWidget(widget)
            self.widgetlist.append(widget)
コード例 #8
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.setWindowTitle("XPD Motor Controls")
        #Get all the motor names here, essentially load up the motorD

        toplayout=QtGui.QGridLayout()
        number_of_motors_ = len(motorD)
        titles = ['Name', 'Status', 'Position Read Back', 'Position', 'Step', 'Stop']
        fields_per_motor = len(titles)

        i=1
        for n, title in enumerate(titles):
            toplayout.addWidget(QtGui.QLabel(title), 0, n)
        for motor in motorD:

            #set the motor name
            toplayout.addWidget(QtGui.QLabel(motor), i, 0)

            #How do I get this to update automaticly? Also needs if statement with real words
            motor_stat = 'MOTOR STATUS HERE'
            toplayout.addWidget(QtGui.QLabel(motor_stat), i, 1)
            position_read_back='POSITION VALUE HERE'
            toplayout.addWidget(QtGui.QLabel(position_read_back), i, 2)

            #Spin box for setting the position
            user_position=QtGui.QDoubleSpinBox()
            user_position.setMaximum(motorD[motor]['high'])
            user_position.setMinimum(motorD[motor]['low'])
            #this needs to update
            user_position.setValue(caget(motorD[motor]['pv']+'.VAL'))
            user_position.setSuffix(motorD[motor]['EGU'])
            user_position.valueChanged.connect(lambda y=user_position.value, x=motor : self.new_position)

            toplayout.addWidget(user_position)

            #step box
            step = QtGui.QDoubleSpinBox()
            step.setMinimum(motorD[motor]['res'])
            step.setValue(.5)
            step.valueChanged.connect(user_position.setSingleStep)
            toplayout.addWidget(step)

            #stop button
            stop_btn=QtGui.QPushButton("STOP")
            stop_btn.clicked.connect(lambda x=motor: self.gui_stop(x))
            toplayout.addWidget(stop_btn)






            i+=1
        self.setLayout(toplayout)
        self.show()
コード例 #9
0
ファイル: formlayout.py プロジェクト: pallavtinna/matplotlib
 def __init__(self, color, parent=None):
     QtGui.QHBoxLayout.__init__(self)
     assert isinstance(color, QtGui.QColor)
     self.lineedit = QtGui.QLineEdit(color.name(), parent)
     self.lineedit.editingFinished.connect(self.update_color)
     self.addWidget(self.lineedit)
     self.colorbtn = ColorButton(parent)
     self.colorbtn.color = color
     self.colorbtn.colorChanged.connect(self.update_text)
     self.addWidget(self.colorbtn)
コード例 #10
0
ファイル: formlayout.py プロジェクト: dimkal/matplotlib
def to_qcolor(color):
    """Create a QColor from a matplotlib color"""
    qcolor = QtGui.QColor()
    color = str(color)
    try:
        color = col2hex(color)
    except ValueError:
        #print('WARNING: ignoring invalid color %r' % color)
        return qcolor  # return invalid QColor
    qcolor.setNamedColor(color)  # set using hex color
    return qcolor  # return valid QColor
コード例 #11
0
 def activateAction(self):
     """
     Returns a QAction that will activate the window with setActiveSubWindow
     as long as it has an mdiArea set. If not, it will use activateWindow to
     try to make it the active window.
     """
     if self._activate_action is not None:
         return self._activate_action
     self._activate_action = QtGui.QAction(self.windowTitle(), self)
     self._activate_action.setCheckable(True)
     self._activate_action.triggered.connect(self._activate_triggered)
     self.activeFigureActionGroup.addAction(self._activate_action)
     return self._activate_action
コード例 #12
0
    def __init__(self, canvas, num):
        FigureManagerBase.__init__(self, canvas, num)
        self.canvas = canvas
        self.window = FigureWindow()
        self.window.closing.connect(canvas.close_event)
        self.window.closing.connect(self._widgetclosed)

        self.window.setWindowTitle("Figure %d" % num)
        image = os.path.join(matplotlib.rcParams['datapath'], 'images',
                             'matplotlib.png')
        self.window.setWindowIcon(QtGui.QIcon(image))

        # Give the keyboard focus to the figure instead of the
        # manager; StrongFocus accepts both tab and click to focus and
        # will enable the canvas to process event w/o clicking.
        # ClickFocus only takes the focus is the window has been
        # clicked
        # on. http://qt-project.org/doc/qt-4.8/qt.html#FocusPolicy-enum or
        # http://doc.qt.digia.com/qt/qt.html#FocusPolicy-enum
        self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.canvas.setFocus()

        self.window._destroying = False

        # No toolbar in figure currently
        self.toolbar = None
        tbs_height = 0

        # resize the main window so it will display the canvas with the
        # requested size:
        cs = canvas.sizeHint()
        self._status_and_tool_height = tbs_height
        height = cs.height() + self._status_and_tool_height
        self.window.resize(cs.width(), height)

        self.window.setWidget(self.canvas)

        _on_new_figure(self.window)

        if matplotlib.is_interactive():
            self.window.show()

        def notify_axes_change(fig):
            # This will be called whenever the current axes is changed
            if self.toolbar is not None:
                self.toolbar.update()

        self.canvas.figure.add_axobserver(notify_axes_change)
コード例 #13
0
ファイル: formlayout.py プロジェクト: dimkal/matplotlib
def tuple_to_qfont(tup):
    """
    Create a QFont from tuple:
        (family [string], size [int], italic [bool], bold [bool])
    """
    if not isinstance(tup, tuple) or len(tup) != 4 \
       or not font_is_installed(tup[0]) \
       or not isinstance(tup[1], int) \
       or not isinstance(tup[2], bool) \
       or not isinstance(tup[3], bool):
        return None
    font = QtGui.QFont()
    family, size, italic, bold = tup
    font.setFamily(family)
    font.setPointSize(size)
    font.setItalic(italic)
    font.setBold(bold)
    return font
コード例 #14
0
ファイル: formlayout.py プロジェクト: dimkal/matplotlib
def fedit(data, title="", comment="", icon=None, parent=None, apply=None):
    """
    Create form dialog and return result
    (if Cancel button is pressed, return None)

    data: datalist, datagroup
    title: string
    comment: string
    icon: QIcon instance
    parent: parent QWidget
    apply: apply callback (function)

    datalist: list/tuple of (field_name, field_value)
    datagroup: list/tuple of (datalist *or* datagroup, title, comment)

    -> one field for each member of a datalist
    -> one tab for each member of a top-level datagroup
    -> one page (of a multipage widget, each page can be selected with a combo
       box) for each member of a datagroup inside a datagroup

    Supported types for field_value:
      - int, float, str, unicode, bool
      - colors: in Qt-compatible text form, i.e. in hex format or name (red,...)
                (automatically detected from a string)
      - list/tuple:
          * the first element will be the selected index (or value)
          * the other elements can be couples (key, value) or only values
    """

    # Create a QApplication instance if no instance currently exists
    # (e.g., if the module is used directly from the interpreter)
    if QtGui.QApplication.startingUp():
        _app = QtGui.QApplication([])
    dialog = FormDialog(data, title, comment, icon, parent, apply)
    if dialog.exec_():
        return dialog.get()
コード例 #15
0
class FigureWindow(QtGui.QMdiSubWindow):
    """
    A basic MDI sub-window, but with a closing signal, and an activate QAction,
    which allows for switching between all FigureWindows (e.g. by a
    Windows-menu). An exclusive, static action group makes sure only one
    window can be active at the time. If you want to split the windows into
    different groups that can be treated separately, you will need to create
    your own QActionGroups.
    """
    closing = QtCore.Signal()

    activeFigureActionGroup = QtGui.QActionGroup(None)
    activeFigureActionGroup.setExclusive(True)

    def __init__(self, *args, **kwargs):
        super(FigureWindow, self).__init__(*args, **kwargs)
        self._activate_action = None
        if os.environ['QT_API'] != 'pyside':
            self.windowStateChanged.connect(self._windowStateChanged)

    def closeEvent(self, event):
        self.closing.emit()
        super(FigureWindow, self).closeEvent(event)

    def activateAction(self):
        """
        Returns a QAction that will activate the window with setActiveSubWindow
        as long as it has an mdiArea set. If not, it will use activateWindow to
        try to make it the active window.
        """
        if self._activate_action is not None:
            return self._activate_action
        self._activate_action = QtGui.QAction(self.windowTitle(), self)
        self._activate_action.setCheckable(True)
        self._activate_action.triggered.connect(self._activate_triggered)
        self.activeFigureActionGroup.addAction(self._activate_action)
        return self._activate_action

    def setWindowTitle(self, title):
        # Overridden to keep action text updated
        super(FigureWindow, self).setWindowTitle(title)
        if self._activate_action is not None:
            self._activate_action.setText(title)

    def _windowStateChanged(self, oldState, newState):
        # Event for tracking if we're active or not
        isactive = newState & QtCore.Qt.WindowActive
        if isactive == oldState & QtCore.Qt.WindowActive:
            return  # Another window state changed, e.g. activation
        self._activate_action.setChecked(isactive)

    def _activate_triggered(self, checked=True):
        # Activate action triggered, make window active
        if self.mdiArea():
            self.mdiArea().setActiveSubWindow(self)
        else:
            self.activateWindow()  # If not subwindow

        if self.isMinimized():
            self.showNormal()  # Restore minimized window
        if not checked:
            # User unchecked, which makes no sense, recheck
            self._activate_action.setChecked(True)
コード例 #16
0
ファイル: formlayout.py プロジェクト: dimkal/matplotlib
 def __init__(self, parent=None):
     QtGui.QPushButton.__init__(self, parent)
     self.setFixedSize(20, 20)
     self.setIconSize(QtCore.QSize(12, 12))
     self.connect(self, QtCore.SIGNAL("clicked()"), self.choose_color)
     self._color = QtGui.QColor()
コード例 #17
0





            i+=1
        self.setLayout(toplayout)
        self.show()

    @QtCore.Slot(float)
    def sl_update_position(self, position):
        pass

    @QtCore.Slot()
    def gui_stop(self, motorID):
        print motorID
        stop(motorID)

    @QtCore.Slot(float)
    def new_position(self, pos, motor):
        AAA
        print 'start motor move'
        move(motor, pos)


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    window = Motor()
    window.show()
    sys.exit(app.exec_())
コード例 #18
0
ファイル: formlayout.py プロジェクト: dimkal/matplotlib
 def setup(self):
     for label, value in self.data:
         if DEBUG:
             print("value:", value)
         if label is None and value is None:
             # Separator: (None, None)
             self.formlayout.addRow(QtGui.QLabel(" "), QtGui.QLabel(" "))
             self.widgets.append(None)
             continue
         elif label is None:
             # Comment
             self.formlayout.addRow(QtGui.QLabel(value))
             self.widgets.append(None)
             continue
         elif tuple_to_qfont(value) is not None:
             field = FontLayout(value, self)
         elif is_color_like(value):
             field = ColorLayout(to_qcolor(value), self)
         elif isinstance(value, six.string_types):
             field = QtGui.QLineEdit(value, self)
         elif isinstance(value, (list, tuple)):
             if isinstance(value, tuple):
                 value = list(value)
             selindex = value.pop(0)
             field = QtGui.QComboBox(self)
             if isinstance(value[0], (list, tuple)):
                 keys = [key for key, _val in value]
                 value = [val for _key, val in value]
             else:
                 keys = value
             field.addItems(value)
             if selindex in value:
                 selindex = value.index(selindex)
             elif selindex in keys:
                 selindex = keys.index(selindex)
             elif not isinstance(selindex, int):
                 print("Warning: '%s' index is invalid (label: " \
                                 "%s, value: %s)" % (selindex, label, value), file=STDERR)
                 selindex = 0
             field.setCurrentIndex(selindex)
         elif isinstance(value, bool):
             field = QtGui.QCheckBox(self)
             if value:
                 field.setCheckState(QtCore.Qt.Checked)
             else:
                 field.setCheckState(QtCore.Qt.Unchecked)
         elif isinstance(value, float):
             field = QtGui.QLineEdit(repr(value), self)
             field.setValidator(QtGui.QDoubleValidator(field))
             dialog = self.get_dialog()
             dialog.register_float_field(field)
             self.connect(field, QtCore.SIGNAL('textChanged(QString)'),
                          lambda text: dialog.update_buttons())
         elif isinstance(value, int):
             field = QtGui.QSpinBox(self)
             field.setRange(-1e9, 1e9)
             field.setValue(value)
         elif isinstance(value, datetime.datetime):
             field = QtGui.QDateTimeEdit(self)
             field.setDateTime(value)
         elif isinstance(value, datetime.date):
             field = QtGui.QDateEdit(self)
             field.setDate(value)
         else:
             field = QtGui.QLineEdit(repr(value), self)
         self.formlayout.addRow(label, field)
         self.widgets.append(field)
コード例 #19
0
ファイル: formsubplottool.py プロジェクト: wmak/matplotlib
    def __init__(self, *args, **kwargs):
        super(UiSubplotTool, self).__init__(*args, **kwargs)
        self.setObjectName('SubplotTool')
        self.resize(450, 265)

        gbox = QtGui.QGridLayout(self)
        self.setLayout(gbox)

        # groupbox borders
        groupbox = QtGui.QGroupBox('Borders', self)
        gbox.addWidget(groupbox, 6, 0, 1, 1)
        self.verticalLayout = QtGui.QVBoxLayout(groupbox)
        self.verticalLayout.setSpacing(0)

        # slider top
        self.hboxtop = QtGui.QHBoxLayout()
        self.labeltop = QtGui.QLabel('top', self)
        self.labeltop.setMinimumSize(QtCore.QSize(50, 0))
        self.labeltop.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.slidertop = QtGui.QSlider(self)
        self.slidertop.setMouseTracking(False)
        self.slidertop.setProperty("value", 0)
        self.slidertop.setOrientation(QtCore.Qt.Horizontal)
        self.slidertop.setInvertedAppearance(False)
        self.slidertop.setInvertedControls(False)
        self.slidertop.setTickPosition(QtGui.QSlider.TicksAbove)
        self.slidertop.setTickInterval(100)

        self.topvalue = QtGui.QLabel('0', self)
        self.topvalue.setMinimumSize(QtCore.QSize(30, 0))
        self.topvalue.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.verticalLayout.addLayout(self.hboxtop)
        self.hboxtop.addWidget(self.labeltop)
        self.hboxtop.addWidget(self.slidertop)
        self.hboxtop.addWidget(self.topvalue)

        # slider bottom
        hboxbottom = QtGui.QHBoxLayout()
        labelbottom = QtGui.QLabel('bottom', self)
        labelbottom.setMinimumSize(QtCore.QSize(50, 0))
        labelbottom.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.sliderbottom = QtGui.QSlider(self)
        self.sliderbottom.setMouseTracking(False)
        self.sliderbottom.setProperty("value", 0)
        self.sliderbottom.setOrientation(QtCore.Qt.Horizontal)
        self.sliderbottom.setInvertedAppearance(False)
        self.sliderbottom.setInvertedControls(False)
        self.sliderbottom.setTickPosition(QtGui.QSlider.TicksAbove)
        self.sliderbottom.setTickInterval(100)

        self.bottomvalue = QtGui.QLabel('0', self)
        self.bottomvalue.setMinimumSize(QtCore.QSize(30, 0))
        self.bottomvalue.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.verticalLayout.addLayout(hboxbottom)
        hboxbottom.addWidget(labelbottom)
        hboxbottom.addWidget(self.sliderbottom)
        hboxbottom.addWidget(self.bottomvalue)

        # slider left
        hboxleft = QtGui.QHBoxLayout()
        labelleft = QtGui.QLabel('left', self)
        labelleft.setMinimumSize(QtCore.QSize(50, 0))
        labelleft.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.sliderleft = QtGui.QSlider(self)
        self.sliderleft.setMouseTracking(False)
        self.sliderleft.setProperty("value", 0)
        self.sliderleft.setOrientation(QtCore.Qt.Horizontal)
        self.sliderleft.setInvertedAppearance(False)
        self.sliderleft.setInvertedControls(False)
        self.sliderleft.setTickPosition(QtGui.QSlider.TicksAbove)
        self.sliderleft.setTickInterval(100)

        self.leftvalue = QtGui.QLabel('0', self)
        self.leftvalue.setMinimumSize(QtCore.QSize(30, 0))
        self.leftvalue.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.verticalLayout.addLayout(hboxleft)
        hboxleft.addWidget(labelleft)
        hboxleft.addWidget(self.sliderleft)
        hboxleft.addWidget(self.leftvalue)

        # slider right
        hboxright = QtGui.QHBoxLayout()
        self.labelright = QtGui.QLabel('right', self)
        self.labelright.setMinimumSize(QtCore.QSize(50, 0))
        self.labelright.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.sliderright = QtGui.QSlider(self)
        self.sliderright.setMouseTracking(False)
        self.sliderright.setProperty("value", 0)
        self.sliderright.setOrientation(QtCore.Qt.Horizontal)
        self.sliderright.setInvertedAppearance(False)
        self.sliderright.setInvertedControls(False)
        self.sliderright.setTickPosition(QtGui.QSlider.TicksAbove)
        self.sliderright.setTickInterval(100)

        self.rightvalue = QtGui.QLabel('0', self)
        self.rightvalue.setMinimumSize(QtCore.QSize(30, 0))
        self.rightvalue.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.verticalLayout.addLayout(hboxright)
        hboxright.addWidget(self.labelright)
        hboxright.addWidget(self.sliderright)
        hboxright.addWidget(self.rightvalue)

        # groupbox spacings
        groupbox = QtGui.QGroupBox('Spacings', self)
        gbox.addWidget(groupbox, 7, 0, 1, 1)
        self.verticalLayout = QtGui.QVBoxLayout(groupbox)
        self.verticalLayout.setSpacing(0)

        # slider hspace
        hboxhspace = QtGui.QHBoxLayout()
        self.labelhspace = QtGui.QLabel('hspace', self)
        self.labelhspace.setMinimumSize(QtCore.QSize(50, 0))
        self.labelhspace.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.sliderhspace = QtGui.QSlider(self)
        self.sliderhspace.setMouseTracking(False)
        self.sliderhspace.setProperty("value", 0)
        self.sliderhspace.setOrientation(QtCore.Qt.Horizontal)
        self.sliderhspace.setInvertedAppearance(False)
        self.sliderhspace.setInvertedControls(False)
        self.sliderhspace.setTickPosition(QtGui.QSlider.TicksAbove)
        self.sliderhspace.setTickInterval(100)

        self.hspacevalue = QtGui.QLabel('0', self)
        self.hspacevalue.setMinimumSize(QtCore.QSize(30, 0))
        self.hspacevalue.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.verticalLayout.addLayout(hboxhspace)
        hboxhspace.addWidget(self.labelhspace)
        hboxhspace.addWidget(self.sliderhspace)
        hboxhspace.addWidget(self.hspacevalue)  # slider hspace

        # slider wspace
        hboxwspace = QtGui.QHBoxLayout()
        self.labelwspace = QtGui.QLabel('wspace', self)
        self.labelwspace.setMinimumSize(QtCore.QSize(50, 0))
        self.labelwspace.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.sliderwspace = QtGui.QSlider(self)
        self.sliderwspace.setMouseTracking(False)
        self.sliderwspace.setProperty("value", 0)
        self.sliderwspace.setOrientation(QtCore.Qt.Horizontal)
        self.sliderwspace.setInvertedAppearance(False)
        self.sliderwspace.setInvertedControls(False)
        self.sliderwspace.setTickPosition(QtGui.QSlider.TicksAbove)
        self.sliderwspace.setTickInterval(100)

        self.wspacevalue = QtGui.QLabel('0', self)
        self.wspacevalue.setMinimumSize(QtCore.QSize(30, 0))
        self.wspacevalue.setAlignment(
            QtCore.Qt.AlignRight |
            QtCore.Qt.AlignTrailing |
            QtCore.Qt.AlignVCenter)

        self.verticalLayout.addLayout(hboxwspace)
        hboxwspace.addWidget(self.labelwspace)
        hboxwspace.addWidget(self.sliderwspace)
        hboxwspace.addWidget(self.wspacevalue)

        # button bar
        hbox2 = QtGui.QHBoxLayout()
        gbox.addLayout(hbox2, 8, 0, 1, 1)
        self.tightlayout = QtGui.QPushButton('Tight Layout', self)
        spacer = QtGui.QSpacerItem(
            5, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.resetbutton = QtGui.QPushButton('Reset', self)
        self.donebutton = QtGui.QPushButton('Close', self)
        self.donebutton.setFocus(True)
        hbox2.addWidget(self.tightlayout)
        hbox2.addItem(spacer)
        hbox2.addWidget(self.resetbutton)
        hbox2.addWidget(self.donebutton)

        self.donebutton.clicked.connect(self.accept)
コード例 #20
0
def get_icon(name):
    import matplotlib
    basedir = osp.join(matplotlib.rcParams['datapath'], 'images')
    return QtGui.QIcon(osp.join(basedir, name))
コード例 #21
0
ファイル: formlayout.py プロジェクト: dimkal/matplotlib
def font_is_installed(font):
    """Check if font is installed"""
    return [
        fam for fam in QtGui.QFontDatabase().families()
        if six.text_type(fam) == font
    ]
コード例 #22
0
ファイル: ToolBar.py プロジェクト: uheee/FCY
 def _icon(self, name):
     return QtGui.QIcon(os.path.join(self.basedir, name))