当前位置: 首页>>代码示例>>Python>>正文


Python NavigationToolbar2QT.setStyleSheet方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_qt4agg.NavigationToolbar2QT.setStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT.setStyleSheet方法的具体用法?Python NavigationToolbar2QT.setStyleSheet怎么用?Python NavigationToolbar2QT.setStyleSheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_qt4agg.NavigationToolbar2QT的用法示例。


在下文中一共展示了NavigationToolbar2QT.setStyleSheet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: processing

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import setStyleSheet [as 别名]
    def processing(self):

        self.button_processing.hide()

        filename1 = QtGui.QFileDialog.getOpenFileName(self, "Open File", "Users/jessicaabreu")
        acq, data, headers = fp.open_c3d_data(str(filename1[0]))
        split_labels, split_tracks = fp.split_wrong_tracks_by_gradient(data, headers, acq.GetAnalogFrequency())
        new_tracks, new_labels = fp.join_equivalent_tracks(split_tracks, split_labels, acq.GetAnalogFrequency())
        viewer = BiomecViewer(new_tracks, new_labels)
        viewer_widget = viewer.edit_traits(parent=self, kind='subpanel').control
        self.layout().addWidget(viewer_widget, 2, 1)

        # making checkbox and plots
        figurex = plt.figure()
        canvasx = FigureCanvas(figurex)
        toolbarx = NavigationToolbar(canvasx, None)
        toolbarx.setIconSize(QtCore.QSize(12, 12))
        toolbarx.setStyleSheet("background-color: #C0C0C0 ")
        ax_x = figurex.add_subplot(111)
        ax_x.cla()
        plt.xlabel('Time (s)', fontsize=10)
        plt.ylabel('Position (mm)', fontsize=10)
        canvasx.draw()

        figurey = plt.figure()
        canvasy = FigureCanvas(figurey)
        toolbary = NavigationToolbar(canvasy, None)
        toolbary.setIconSize(QtCore.QSize(12, 12))
        toolbary.setStyleSheet("background-color: #C0C0C0 ")
        ax_y = figurey.add_subplot(111)
        ax_y.cla()
        plt.xlabel('Time (s)', fontsize=10)
        plt.ylabel('Position (mm)', fontsize=10)
        canvasy.draw()

        figurez = plt.figure()
        canvasz = FigureCanvas(figurez)
        toolbarz = NavigationToolbar(canvasz, None)
        toolbarz.setIconSize(QtCore.QSize(12, 12))
        toolbarz.setStyleSheet("background-color: #C0C0C0 ")
        ax_z = figurez.add_subplot(111)
        ax_z.cla()
        plt.xlabel('Time (s)', fontsize=10)
        plt.ylabel('Position (mm)', fontsize=10)
        canvasz.draw()

        check_box = QtGui.QGroupBox("Plot Tracks")
        check_box_layout = QtGui.QGridLayout()
        check_box.setLayout(check_box_layout)
        for i in range(len(new_labels)):
            column = i / 5
            line = i % 5
            check_item = QtGui.QCheckBox(new_labels[i])
            check_item.setStyleSheet("font-size: 8px; font-weight: normal")
            check_item.stateChanged.connect(self.wrapper_plot(ax_x, ax_y, ax_z, new_tracks[i, :, :],
                                                              new_labels[i], check_item, figurex,
                                                              figurey, figurez, canvasx, canvasy,
                                                              canvasz, acq
                                                              ))
            check_box_layout.addWidget(check_item, line, column)
        plot_layout = QtGui.QVBoxLayout()
        plot_layout.addWidget(canvasx)
        plot_layout.addWidget(toolbarx)
        plot_layout.addWidget(canvasy)
        plot_layout.addWidget(toolbary)
        plot_layout.addWidget(canvasz)
        plot_layout.addWidget(toolbarz)
        self.layout().addWidget(check_box, 1, 2)
        self.layout().addLayout(plot_layout, 2, 2)

        self.button_processing_labeling.show()
        self.button_processing_labeling.clicked.connect(lambda: self.processing_labeling(new_tracks, new_labels, filename1[0], acq))
        self.button_save.show()
        self.button_save.clicked.connect(lambda: self.save(new_tracks, new_labels, filename1[0], acq, "pre_processed"))
开发者ID:jessicaabreu,项目名称:hbt,代码行数:76,代码来源:hand_biomechanics_toolkit_2.py

示例2: mGraph

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import setStyleSheet [as 别名]
class mGraph(QtGui.QWidget):
    def __init__(self, device, parent=None):
        QtGui.QWidget.__init__(self, parent)
        # Create a matplotlib figure
        self.figure = plt.figure()
        self.figure.set_facecolor("r")
        # Create a QFrame to house the plot. This is not necessary, just makes it look nice
        self.matframe = QtGui.QFrame()
        self.matLayout = QtGui.QVBoxLayout()
        self.matLayout.setSpacing(0)
        self.matframe.setLayout(self.matLayout)
        self.matframe.setFrameShape(QtGui.QFrame.Panel)
        self.matframe.setFrameShadow(QtGui.QFrame.Plain)
        self.matframe.setStyleSheet("background-color: rgb(70,80,88); margin:0px; border:2px solid rgb(0, 0, 0); ")
        self.canvas = FigureCanvas(self.figure)
        self.canvas.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
        # This is the device we want to use
        self.device = device
        # This sets up axis on which to plot
        self.ax = self.figure.add_subplot(111, axisbg=(189.0 / 255, 195.0 / 255, 199.0 / 255))
        # Add the matplotlib canvas to the QFrame
        self.matLayout.addWidget(self.canvas)
        # The following lines set up all the colors, makes it look nice. The code to do it is
        # far from pretty and I am planning on cleaning this up a bit.
        self.figure.patch.set_color((70.0 / 255, 80.0 / 255, 88.0 / 255))
        self.figure.patch.set_edgecolor((70.0 / 255, 80.0 / 255, 88.0 / 255))
        self.ax.spines["bottom"].set_color((189.0 / 255, 195.0 / 255, 199.0 / 255))
        self.ax.spines["top"].set_color((189.0 / 255, 195.0 / 255, 199.0 / 255))
        self.ax.spines["right"].set_color((189.0 / 255, 195.0 / 255, 199.0 / 255))
        self.ax.spines["left"].set_color((189.0 / 255, 195.0 / 255, 199.0 / 255))
        self.ax.tick_params(axis="x", colors=(189.0 / 255, 195.0 / 255, 199.0 / 255))
        self.ax.tick_params(axis="y", colors=(189.0 / 255, 195.0 / 255, 199.0 / 255))
        self.ax.title.set_color((189.0 / 255, 195.0 / 255, 199.0 / 255))
        self.ax.yaxis.label.set_color((189.0 / 255, 195.0 / 255, 199.0 / 255))
        self.ax.xaxis.label.set_color((189.0 / 255, 195.0 / 255, 199.0 / 255))
        self.ax.xaxis.get_offset_text().set_color((189.0 / 255, 195.0 / 255, 199.0 / 255))
        self.ax.yaxis.get_offset_text().set_color((189.0 / 255, 195.0 / 255, 199.0 / 255))
        # This is an array of all the lines on the plot. A line for every parameter
        self.line = []
        # Each element of line holds a plot, to be combined onto the same graph
        self.line.append(self.ax.plot(1, 1, label="Getting Data...")[0])
        # This is the ONLY time canvas.draw is called. It should NOT be called anywhere else if
        # the graphing speed is to be fast.
        self.canvas.draw()
        # In order to handle interactivity, I had to do some odd stuff with the
        # toolbar buttons. Self.home holds the original function called when the home button on the toolbar
        # is clicked.
        self.home = NavigationToolbar.home
        # We now change the function that is called when the toolbar is clicked.
        NavigationToolbar.home = self.enableAutoScaling
        self.toolbar = NavigationToolbar(self.canvas, self)
        # print [item for item in dir(self.toolbar) if type(item) == QtGui.QDialog]
        self.cid = self.canvas.mpl_connect("button_press_event", self.disableAutoScaling)
        self.setStyleSheet(
            "QPushButton{\
                    color:rgb(189,195, 199); \
                    background:rgb(70, 80, 88)}"
        )
        self.toolbarFrame = QtGui.QFrame()
        toolbarFrameLayout = QtGui.QVBoxLayout()
        toolbarFrameLayout.addWidget(self.toolbar)
        self.toolbar.setParent(None)
        self.toolbarFrame.setLayout(toolbarFrameLayout)
        self.toolbarFrame.setStyleSheet(
            "\
                    border:2px solid rgb(0,0,0);\
                    color:rgb(189,195,199); \
                    background:rgb(70, 80, 88);\
                    "
        )
        self.toolbar.setStyleSheet(
            "\
                    border:0px solid rgb(0,0,0);\
                    QDialog{background:rgb(250, 80, 88)}\
                    "
        )
        # print dir(self.toolbar)
        # print self.toolbar.children()
        # print self.toolbar.setPalette
        self.matPlotInfo = QtGui.QLabel()
        self.alertFont = QtGui.QFont()
        self.alertFont.setPointSize(12)
        self.matPlotInfo.setStyleSheet("color:rgb(200, 69, 50);")
        self.matPlotInfo.setText("Auto refresh disabled, click HOME button to enable.")
        self.matPlotInfo.setFont(self.alertFont)

        self.refreshRateSec = device.getFrame().getPlotRefreshRate()
        self.timer = QtCore.QTimer(self)

        self.hidden = True
        self.home = True
        self.currTimeRange = 120
        self.plot(self.currTimeRange)

        self.timer.timeout.connect(partial(self.plot, self.currTimeRange))
        self.timer.start(self.refreshRateSec * 1000)
        # did it store data?
        self.dataOk = True
        self.hideButton = QtGui.QPushButton("Show Plot")
        self.hideButton.clicked.connect(self.togglePlot)
#.........这里部分代码省略.........
开发者ID:McDermott-Group,项目名称:servers,代码行数:103,代码来源:MGrapher.py


注:本文中的matplotlib.backends.backend_qt4agg.NavigationToolbar2QT.setStyleSheet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。