コード例 #1
0
class Window(QtWidgets.QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)

        self.setWindowTitle("グラフ")
        self.setGeometry(300, 300, 500, 500)

        self.figure = plt.figure()
        self.axes = self.figure.add_subplot(111)
        # We want the axes cleared every time plot() is called
        self.axes.hold(False)
        self.canvas = FigureCanvas(self.figure)
        self.canvas.setParent(self)

        self.canvas.move(100, 20)

        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()

        # Just some button
        self.button1 = QtWidgets.QPushButton('Plot', self)
        self.button1.clicked.connect(self.plot)
        self.button1.move(0, 400)

    def plot(self):
        ''' plot some random stuff '''
        data = [random.random() for i in range(25)]
        self.axes.plot(data, '*-')
        self.canvas.draw()
コード例 #2
0
    def __init__(self , canvas , parent , direction = 'h' ) :
        self.canvas = canvas
        QtWidgets.QWidget.__init__( self, parent )

        if direction=='h' :    self.layout = PyQt5.QtWidgets.QHBoxLayout
        else : self.layout = PyQt5.QtWidgets.QVBoxLayout
        NavigationToolbar.__init__( self, canvas, parent )
コード例 #3
0
ファイル: toolbar.py プロジェクト: omad/glue
    def __init__(self, canvas, frame, name=None):
        """ Create a new toolbar object

        Parameters
        ----------
        canvas : Maptloblib canvas instance
         The drawing canvas to interact with
        frame : QWidget
         The QT frame that the canvas is embedded within.
        """
        self.buttons = {}
        self.__active = None
        self.basedir = None
        NavigationToolbar2QT.__init__(self, canvas, frame)
        if name is not None:
            self.setWindowTitle(name)
        self.setIconSize(QtCore.QSize(25, 25))
        self.layout().setSpacing(1)
        self.setFocusPolicy(Qt.StrongFocus)
        self._idKey = None

        # pyside is prone to segfaults if slots hold the only
        # reference to a signal, so we hold an extra reference
        # see https://bugreports.qt-project.org/browse/PYSIDE-88
        self.__signals = []
コード例 #4
0
 def __init__(*args, **kwargs):
     warnings.warn(
         'This class has been deprecated in 1.4 ' +
         'as it has no additional functionality over ' +
         '`NavigationToolbar2QT`.  Please change your code to '
         'use `NavigationToolbar2QT` instead', mplDeprecation)
     NavigationToolbar2QT.__init__(*args, **kwargs)
コード例 #5
0
ファイル: glue_toolbar.py プロジェクト: antonl/glue
    def __init__(self, canvas, frame, name=None):
        """ Create a new toolbar object

        Parameters
        ----------
        canvas : Maptloblib canvas instance
         The drawing canvas to interact with
        frame : QWidget
         The QT frame that the canvas is embedded within.
        """
        self.buttons = {}
        self.__active = None
        self.basedir = None
        NavigationToolbar2QT.__init__(self, canvas, frame)
        if name is not None:
            self.setWindowTitle(name)
        self.setIconSize(QtCore.QSize(25, 25))
        self.layout().setSpacing(1)
        self.setFocusPolicy(Qt.StrongFocus)
        self._idKey = None

        # pyside is prone to segfaults if slots hold the only
        # reference to a signal, so we hold an extra reference
        # see https://bugreports.qt-project.org/browse/PYSIDE-88
        self.__signals = []
コード例 #6
0
class MyMplCanvas(FigureCanvas):
    """Ultimately, this is a QWidget (as well as a FigureCanvasAgg, etc.)."""

    def __init__(self, parent=None, width=5, height=4, dpi=100):
        fig = Figure(figsize=(width, height), dpi=dpi)
        self._axes = fig.add_subplot(111)

        self.compute_initial_figure()

        FigureCanvas.__init__(self, fig)
        self.setParent(parent)

        FigureCanvas.setSizePolicy(self,
                                   QtWidgets.QSizePolicy.Expanding,
                                   QtWidgets.QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)

        self.toolbar = NavigationToolbar(self, parent, False)

        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.figure.add_axobserver(notify_axes_change)

    def compute_initial_figure(self):
        pass
コード例 #7
0
    def mianThread_callbacklog(self, df):
        mpl = StockMplCanvas(self, width=5, height=4, dpi=100)
        mpl.start_staict_plot(df)
        mpl_ntb = NavigationToolbar(mpl, self)
        mpl_ntb.setStyleSheet("background-color:white;color:black")

        self.grid.addWidget(mpl, 2, 0, 12, 12)
        self.grid.addWidget(mpl_ntb, 2, 0, 1, 5)
コード例 #8
0
    def kLineThread_callbacklog(self, df):
        self.df = df
        self.mplK = KMplCanvas(self, width=5, height=4, dpi=100)
        self.mplK.start_staict_plot(df)
        mpl_ntb = NavigationToolbar(self.mplK, self)
        mpl_ntb.setStyleSheet("background-color:white;color:black")

        self.grid_k.addWidget(self.mplK, 2, 0, 13, 12)
        self.grid_k.addWidget(mpl_ntb, 2, 0, 1, 5)
コード例 #9
0
class Window(QtWidgets.QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)

        self.figure = plt.figure()
        self.axes = self.figure.add_subplot(111)
        # We want the axes cleared every time plot() is called
        self.axes.hold(False)
        self.canvas = FigureCanvas(self.figure)

        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()

        # Just some button
        self.button1 = QtWidgets.QPushButton('Plot')
        self.button1.clicked.connect(self.plot)

        self.button2 = QtWidgets.QPushButton('Zoom')
        self.button2.clicked.connect(self.zoom)

        self.button3 = QtWidgets.QPushButton('Pan')
        self.button3.clicked.connect(self.pan)

        self.button4 = QtWidgets.QPushButton('Home')
        self.button4.clicked.connect(self.home)

        # set the layout
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(self.toolbar)
        layout.addWidget(self.canvas)

        btnlayout = QtWidgets.QHBoxLayout()
        btnlayout.addWidget(self.button1)
        btnlayout.addWidget(self.button2)
        btnlayout.addWidget(self.button3)
        btnlayout.addWidget(self.button4)
        qw = QtWidgets.QWidget(self)
        qw.setLayout(btnlayout)
        layout.addWidget(qw)

        self.setLayout(layout)

    def home(self):
        self.toolbar.home()
        self.toolbar.forward()

    def zoom(self):
        self.toolbar.zoom()

    def pan(self):
        self.toolbar.pan()

    def plot(self):
        ''' plot some random stuff '''
        data = [random.random() for i in range(25)]
        self.axes.plot(data, '*-')
        self.canvas.draw()
コード例 #10
0
class BaseCanvas(QWidget):
    def __init__(self,
                 figure_title='',
                 x_axis_title='',
                 y_axis_title='',
                 add_toolbar=True,
                 add_grid=True):
        super().__init__()

        self.add_toolbar = add_toolbar
        self.add_grid = add_grid
        self.figure_title = figure_title
        self.x_axis_title = x_axis_title
        self.y_axis_title = y_axis_title
        self.figure, self.axes = pyplot.subplots()
        self.canvas = FigureCanvas(self.figure)
        if self.add_toolbar:
            self.toolbar = NavigationToolbar(self.canvas, self)
        else:
            self.toolbar = None
        self._set_layout()
        self._initialize_figure()

    def _update_figure(self):
        if self.toolbar is not None:
            self.toolbar.update()
        self.canvas.draw()

    def _set_layout(self):
        layout = QVBoxLayout()
        layout.addWidget(self.canvas)
        if self.toolbar is not None:
            layout.addWidget(self.toolbar)
        self.setLayout(layout)

    def _initialize_figure(self):
        self.figure.clf()
        self.axes = self.figure.add_subplot(111)
        self.axes.set_title(self.figure_title)
        self.axes.set_xlabel(self.x_axis_title)
        self.axes.set_ylabel(self.y_axis_title)
        if self.add_grid:
            self.axes.grid()
        self.figure.subplots_adjust(bottom=0.3)
        self.canvas.draw()

    def clear(self):
        self._initialize_figure()

    @abstractmethod
    def plot(self, *args):
        raise NotImplementedError
コード例 #11
0
   def __createFigure(self):
   ##      self.__fig=mpl.figure.Figure(figsize=(8, 5),constrained_layout=True, tight_layout=None)  #单位英寸
   ##      self.__fig=mpl.figure.Figure(figsize=(8, 5))  #单位英寸
      self.__fig=mpl.figure.Figure() 
      figCanvas = FigureCanvas(self.__fig)  #创建FigureCanvas对象,必须传递一个Figure对象
      self.__fig.suptitle("suptitle:matplotlib in Qt GUI",fontsize=16, fontweight='bold')  # 总的图标题

      naviToolbar=NavigationToolbar(figCanvas, self)  #创建NavigationToolbar工具栏
      actList=naviToolbar.actions()  #关联的Action列表
      count=len(actList)       #Action的个数
      lastAction=actList[count-1]   #最后一个Action

      labCurAxes=QLabel("当前子图")
      naviToolbar.insertWidget(lastAction,labCurAxes)
      self.__comboAxes=QComboBox(self)    #子图列表,用于选择子图
      self.__comboAxes.setToolTip("选择当前子图")
      self.__comboAxes.currentIndexChanged.connect(self.do_currentAxesChaned)
      naviToolbar.insertWidget(lastAction,self.__comboAxes)

      naviToolbar.insertAction(lastAction,self.ui.actQuit)  #在最后一个Action之前插入一个Action
   ##      naviToolbar.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)  #ToolButtonTextUnderIcon
      self.addToolBar(naviToolbar)  #添加作为主窗口工具栏

      splitter = QSplitter(self)
      splitter.setOrientation(Qt.Horizontal)
      splitter.addWidget(self.ui.toolBox)    #左侧控制面板
      splitter.addWidget(figCanvas)          #右侧FigureCanvas对象
      self.setCentralWidget(splitter)
コード例 #12
0
 def __init__(self, canvas, parent, coordinates=True):
     self.curveX = {}
     self.curveY = {}
     self.error = 0.01
     self.curve_point = {}
     self.last_plot = {}
     self.siblings = []
     self.text_coordinates = u''
     self.last_message = u''
     self.canvas = canvas
     self._drag_mode = False
     NavigationToolbar2QT.__init__(self, canvas, parent, coordinates)
     self._id_scroll_event = self.canvas.mpl_connect('scroll_event', self._on_mouse_scroll)
     self._id_mouse_button_release = self.canvas.mpl_connect('button_release_event', self._on_mouse_button_release)
コード例 #13
0
    def __init__(self, parent, canvas, direction = 'h' ) :

        self.canvas = canvas
        QWidget.__init__( self, parent )

        if direction=='h' :
            self.layout = QHBoxLayout( self )
        else :
            self.layout = QVBoxLayout( self )

        self.layout.setMargin( 2 )
        self.layout.setSpacing( 0 )

        NavigationToolbar.__init__( self, canvas )
コード例 #14
0
ファイル: exsample.py プロジェクト: umyuu/Sample
class Window(QtWidgets.QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)

        self.figure = plt.figure()
        self.axes = self.figure.add_subplot(111)
        # We want the axes cleared every time plot() is called
        self.axes.hold(False)
        self.canvas = FigureCanvas(self.figure)

        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()

        # Just some button
        self.button1 = QtWidgets.QPushButton('Plot')
        self.button1.clicked.connect(self.plot)

        self.button2 = QtWidgets.QPushButton('Save')
        self.button2.clicked.connect(self.save)

        # set the layout
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(self.toolbar)
        layout.addWidget(self.canvas)

        btnlayout = QtWidgets.QHBoxLayout()
        btnlayout.addWidget(self.button1)
        btnlayout.addWidget(self.button2)
        qw = QtWidgets.QWidget(self)
        qw.setLayout(btnlayout)
        layout.addWidget(qw)

        self.setLayout(layout)

    def save(self):
        from pathlib import Path
        file_name, _ = QFileDialog.getSaveFileName(self)
        if len(file_name) == 0:
            return
        print(file_name)
        file_name = str(Path(file_name).with_suffix(".png"))
        print(file_name)
        self.figure.savefig(file_name)

    def plot(self):
        ''' plot some random stuff '''
        data = [random.random() for i in range(25)]
        self.axes.plot(data, '*-')
        self.canvas.draw()
コード例 #15
0
    def __init__(self, **kwargs: Any):
        BaseWidget.__init__(self, **kwargs)
        self.setupUi(self)

        # variables
        self.new_data = False
        self.data_filename: Optional[str] = None
        self.data: Optional[fits.HDUList] = None

        # before first update, disable mys
        self.setEnabled(False)

        # add image panel
        self.imageLayout = QtWidgets.QVBoxLayout(self.tabImage)
        if isinstance(self.module, IImageGrabber):
            self.imageView = QFitsWidget()
            self.imageLayout.addWidget(self.imageView)
        elif isinstance(self.module, ISpectrograph):
            self.figure, self.ax = plt.subplots()
            self.canvas = FigureCanvas(self.figure)
            self.plotTools = NavigationToolbar2QT(self.canvas, self.tabImage)
            self.imageLayout.addWidget(self.plotTools)
            self.imageLayout.addWidget(self.canvas)
        else:
            raise ValueError("Unknown type")

        # set headers for fits header tab
        self.tableFitsHeader.setColumnCount(3)
        self.tableFitsHeader.setHorizontalHeaderLabels(
            ["Key", "Value", "Comment"])

        # connect signals
        self.signal_update_gui.connect(self.update_gui)
        self.checkAutoSave.stateChanged.connect(
            lambda x: self.textAutoSavePath.setEnabled(x))
コード例 #16
0
    def __init__(self, parent=None, toolbarVisible=True, showHint=False):
        super().__init__(parent)

        self.figure = mpl.figure.Figure()  #公共的figure属性
        figCanvas = FigureCanvas(self.figure)  #创建FigureCanvas对象,必须传递一个Figure对象

        self.naviBar = NavigationToolbar(figCanvas, self)  #公共属性naviBar
        self.__changeActionLanguage()  #改为汉语

        actList = self.naviBar.actions()  #关联的Action列表
        count = len(actList)  #Action的个数
        self.__lastActtionHint = actList[count - 1]  #最后一个Action,坐标提示标签
        self.__showHint = showHint  #是否在工具栏上显示坐标提示
        self.__lastActtionHint.setVisible(self.__showHint)  #隐藏其原有的坐标提示

        self.__showToolbar = toolbarVisible  #是否显示工具栏
        self.naviBar.setVisible(self.__showToolbar)

        layout = QVBoxLayout(self)
        layout.addWidget(self.naviBar)  #添加工具栏
        layout.addWidget(figCanvas)  #添加FigureCanvas对象
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        #鼠标滚轮缩放
        self.__cid = figCanvas.mpl_connect("scroll_event", self.do_scrollZoom)
コード例 #17
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.ui = Ui_main_window()
        self.ui.setupUi(self)

        # Application variables

        self.model = ListModel()
        self.well_dataframes_dict = {}

        self.decline_curves_dict = {}
        self.model_oil_curves = ListModel()
        self.model_gas_curves = ListModel()

        # Cashflow models

        self.model_cashflow_monthly = TableModel()
        self.model_cashflow_annual = TableModel()
        self.model_cashflow_summary = TableModel()

        # Production Plot setup

        self.widget_production_plot = DynamicMplCanvas(
            self.ui.widgetProductionPlot)
        toolbar = NavigationToolbar2QT(self.widget_production_plot,
                                       self.ui.widgetProductionPlot)

        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(toolbar)
        layout.addWidget(self.widget_production_plot)

        self.ui.widgetProductionPlot.setLayout(layout)

        self.ui.comboBoxPhase.addItems(["Oil", "Gas"])
        self.ui.comboBoxUnits.addItems(["BOPM/MCFPM", "BOPD/MCFPD"])
コード例 #18
0
    def __iniFigure(self):  ##创建绘图系统,初始化窗口
        self.__fig = mpl.figure.Figure(figsize=(8, 5))  #单位英寸
        self.__fig.suptitle("plot in GUI application")  #总的图标题
        figCanvas = FigureCanvas(self.__fig)  #创建FigureCanvas对象,必须传递一个Figure对象

        ## 下面这两行语句是行不通的
        ##      figCanvas = FigureCanvas()  #创建FigureCanvas对象,必须传递一个Figure对象
        ##      self.__fig.set_canvas(figCanvas)

        naviToolbar = NavigationToolbar(figCanvas, self)  #创建工具栏
        naviToolbar.setToolButtonStyle(
            Qt.ToolButtonTextUnderIcon
        )  #ToolButtonTextUnderIcon,ToolButtonTextBesideIcon

        self.addToolBar(naviToolbar)  #添加工具栏到主窗口
        self.setCentralWidget(figCanvas)
コード例 #19
0
ファイル: exsample.py プロジェクト: umyuu/Sample
    def __init__(self, parent=None):
        super().__init__(parent)

        self.figure = plt.figure()
        self.axes = self.figure.add_subplot(111)
        # We want the axes cleared every time plot() is called
        self.axes.hold(False)
        self.canvas = FigureCanvas(self.figure)

        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()

        # Just some button
        self.button1 = QtWidgets.QPushButton('Plot')
        self.button1.clicked.connect(self.plot)

        self.button2 = QtWidgets.QPushButton('Save')
        self.button2.clicked.connect(self.save)

        # set the layout
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(self.toolbar)
        layout.addWidget(self.canvas)

        btnlayout = QtWidgets.QHBoxLayout()
        btnlayout.addWidget(self.button1)
        btnlayout.addWidget(self.button2)
        qw = QtWidgets.QWidget(self)
        qw.setLayout(btnlayout)
        layout.addWidget(qw)

        self.setLayout(layout)
コード例 #20
0
ファイル: MyGraph.py プロジェクト: Python3pkg/JupyterHuck
    def __init__(self, fig=None, geo=None, title='temp'):
        super().__init__()
        #mutableなオブジェクトをデフォルトに指定するとまずいのでこのように書く
        if fig == None:
            self.fig = Figure(figsize=(6, 6), dpi=100)
        else:
            self.fig = fig
        if geo == None:
            self.geo = QRect(30, 30, 500, 500)
        else:
            self.geo = geo

        self.canvas = FigureCanvas(self.fig)
        self.canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.navi_toolbar = NavigationToolbar(self.canvas, self)
        self.lassoAction = QAction('lasso', self.canvas)
        self.pointerAction = QAction('pointer', self.canvas)
        self.lineAction = QAction('line', self.canvas)
        self.lassoAction.setCheckable(True)
        self.pointerAction.setCheckable(True)
        self.lineAction.setCheckable(True)
        self.navi_toolbar.addAction(self.lassoAction)
        self.navi_toolbar.addAction(self.pointerAction)
        self.navi_toolbar.addAction(self.lineAction)
        self.lassoAction.triggered.connect(self.lassoTriggered)
        self.pointerAction.triggered.connect(self.pointerTriggered)
        self.lineAction.triggered.connect(self.lineTriggered)

        self.lassoTarget = None  #選択対象 lasso時はcilickでalphaを下げる
        self.selectedLine = None  #選択中の点をself.lassoTargetの上にプロットする
        self.pre_alpha = 1  #alphaを下げる前の値
        self.pre_settings = None  #markerの色とサイズselectedLineをplotする時に使う

        #setTargetで指定したlineの点とそこからlassoで選ばれたindexを保存
        self.xys = None  #numpy.array 列数2の行列
        self.selectedIndices = set()
        self.unselectedIndices = set()

        #クリックされたlineを記憶しておいてgetLineで参照を渡す
        self.line = None
        self.pre_width = 0  #太くした後元に戻すのに使う

        #点の座標を表示する
        self.pointer = MyPointer()
        self.pointer.deactivate()

        self.vbl = QVBoxLayout()
        self.vbl.addWidget(self.navi_toolbar)
        self.vbl.addWidget(self.canvas)
        self.vbl.addWidget(self.pointer)

        self.frontPanel = QWidget()
        self.frontPanel.setLayout(self.vbl)
        self.setCentralWidget(self.frontPanel)

        self.setGeometry(self.geo)
        self.setWindowTitle(title)
        self.show()
コード例 #21
0
    def __init__(self, canvas, parent):
        NavigationToolbar2QT.__init__(self, canvas, parent)

        self.parent = parent  # we assume it has a vCollection

        self.editCheckBox = QW.QCheckBox("Tryb edycji")
        self.addWidget(self.editCheckBox)

        editTypes = ["Dodaj LPM/Usuń PPM", "Przesuń"]
        self.editTypeComboBox = QW.QComboBox()
        self.editTypeComboBox.addItems(editTypes)
        self.addWidget(self.editTypeComboBox)

        self.selectedLabel = QW.QLabel("Wybrane punkty:")
        self.addWidget(self.selectedLabel)

        self.selectedPointsComboBox = QW.QComboBox()
        self.addWidget(self.selectedPointsComboBox)
コード例 #22
0
    def __init__(self, parent):

        self.canvas = parent.central_widget.canvas

        # Set up virtual Matplotlib navigation toolbar (don't show it)
        self._mpl_nav = NavigationToolbar2QT(self.canvas, parent)
        self._mpl_nav.hide()

        BasicToolbar.__init__(self, parent)
コード例 #23
0
    def __init__(self, canvas, parent):
        NavigationToolbar2QT.__init__(self, canvas, parent)

        self.parent = parent  # we assume it has a vCollection

        self.editCheckBox = QW.QCheckBox("Edit mode")
        self.addWidget(self.editCheckBox)

        editTypes = ["Add LMB/Delete RMB", "Move"]
        self.editTypeComboBox = QW.QComboBox()
        self.editTypeComboBox.addItems(editTypes)
        self.addWidget(self.editTypeComboBox)

        self.selectedLabel = QW.QLabel("Chosen points:")
        self.addWidget(self.selectedLabel)

        self.selectedPointsComboBox = QW.QComboBox()
        self.addWidget(self.selectedPointsComboBox)
コード例 #24
0
    def __init__(self, figure_canvas,axes_canvas, parent= None):
        self.toolitems = (('Home', 'Reset', 'home', 'home'),
            ('Pan', 'Pan', 'move', 'pan'),
            ('Zoom', 'Zoom', 'zoom_to_rect', 'zoom'),
            (None, None, None, None),
            ('Transect', 'make a transect',os.path.join(root_path,'icons','transect'), 'transect_tool'),
            ('View', 'Switch view',os.path.join(root_path,'icons','switch'), 'switch_view'),
            ('Selector', 'Select node', os.path.join(root_path,'icons','select'), 'select_tool'),
            (None, None, None, None),
            ('Save', 'Save', 'filesave', 'save_figure'))


        #('Subplots', 'putamus parum claram', 'subplots', 'configure_subplots'),
        self.figure_canvas=figure_canvas
        self.axes_canvas=axes_canvas
    

        NavigationToolbar.__init__(self, figure_canvas, parent= parent)
コード例 #25
0
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)

        # self.figure = plt.figure()
        # self.axes = self.figure.add_subplot(111)
        # # We want the axes cleared every time plot() is called
        # self.axes.hold(False)
        # self.canvas = FigureCanvas(self.figure)
        # self.canvas = Figure_Canvas()
        # self.canvas.plotleadone()

        self.viewer = MyView()

        self.toolbar = NavigationToolbar(self.viewer.canvas, self)
        # self.toolbar.hide()

        # Just some button
        self.button1 = QtWidgets.QPushButton('Plot')
        self.button1.clicked.connect(self.plot)

        self.button2 = QtWidgets.QPushButton('Zoom')
        self.button2.clicked.connect(self.zoom)

        self.button3 = QtWidgets.QPushButton('Pan')
        self.button3.clicked.connect(self.pan)

        self.button4 = QtWidgets.QPushButton('Home')
        self.button4.clicked.connect(self.home)

        # set the layout
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(self.toolbar)

        #
        # self.graphicview = QGraphicsView()  # 第一步,创建一个QGraphicsView
        # self.graphicview.setObjectName("figure_graphicview")
        # graphicscene = QGraphicsScene()  # 第三步,创建一个QGraphicsScene,因为加载的图形(FigureCanvas)不能直接放到graphicview控件中,必须先放到graphicScene,然后再把graphicscene放到graphicview中
        # graphicscene.addWidget(self.canvas)  # 第四步,把图形放到QGraphicsScene中,注意:图形是作为一个QWidget放到QGraphicsScene中的
        # self.graphicview.setScene(graphicscene)  # 第五步,把QGraphicsScene放入QGraphicsView
        # self.graphicview.show()  # 最后,调用show方法呈现图形!Voila!!

        layout.addWidget(self.viewer)
        # layout.addWidget(self.graphicview)
        # layout.addWidget(self.canvas)

        btnlayout = QtWidgets.QHBoxLayout()
        btnlayout.addWidget(self.button1)
        btnlayout.addWidget(self.button2)
        btnlayout.addWidget(self.button3)
        btnlayout.addWidget(self.button4)
        qw = QtWidgets.QWidget(self)
        qw.setLayout(btnlayout)
        layout.addWidget(qw)

        self.setLayout(layout)
コード例 #26
0
    def __init__(self, viewer):

        self.canvas = viewer.central_widget.canvas

        # Set up virtual Matplotlib navigation toolbar (don't show it)
        self._mpl_nav = NavigationToolbar2QT(self.canvas, viewer)
        self._mpl_nav.hide()

        BasicToolbar.__init__(self, viewer)

        viewer.window_closed.connect(self.close)
コード例 #27
0
ファイル: Graph.py プロジェクト: c2pir/image
    def __init__(self, canvas, parent):
        NavigationToolbar.__init__(self, canvas, parent)
        self.clearButtons = []
        # Search through existing buttons
        nextB = None

        not_in = ('Subplots', 'Customize')

        for c in self.findChildren(QtWidgets.QToolButton):
            if nextB is None:
                nextB = c
            # Don't want to see subplots and customize
            if str(c.text()) in not_in:
                c.defaultAction().setVisible(False)
                continue
            # Need to keep track of pan and zoom buttons
            # Also grab toggled event to clear checked status of picker button
            if str(c.text()) in ('Pan', 'Zoom'):
                self.clearButtons.append(c)
                nextB = None
コード例 #28
0
ファイル: plot_widget.py プロジェクト: luuleitner/deepMTJ
    def __init__(self, parent=None):
        QtWidgets.QWidget.__init__(self, parent)
        self.canvas = MplCanvas()
        self.toolbar = NavigationToolbar2QT(self.canvas, self)

        self.vbl = QtWidgets.QVBoxLayout()
        self.vbl.addWidget(self.canvas)
        self.vbl.addWidget(self.toolbar)
        self.setLayout(self.vbl)

        self.canvas.fig.canvas.mpl_connect('button_press_event', self.onclick)
コード例 #29
0
ファイル: canvases.py プロジェクト: Qrc/account-analyzer
    def __init__(self, figure_title='', x_axis_title='', y_axis_title=''):
        super().__init__()

        self.figure_title = figure_title
        self.x_axis_title = x_axis_title
        self.y_axis_title = y_axis_title
        self.figure, self.axes = pyplot.subplots()
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        self._set_layout()
        self._initialize_figure()
コード例 #30
0
ファイル: plot.py プロジェクト: vn-ki/solar-viewer
 def initMainCanvas(self):
     self.figure = plt.figure()
     self.canvas = FigureCanvas(self.figure)
     self.toolbar = NavigationToolbar2QT(self.canvas, self)
     self.toolbar.setVisible(False)
     FigureCanvas.setSizePolicy(self.canvas,
                                QtWidgets.QSizePolicy.Expanding,
                                QtWidgets.QSizePolicy.Expanding)
     FigureCanvas.updateGeometry(self.canvas)
     self.canvas.hide()
     self.ui.verticalLayout.addWidget(self.canvas)
コード例 #31
0
    def __init__(self, canvas, parent, coordinates=True):
        NavigationToolbar2QT.__init__(self, canvas, parent, coordinates=True)
        self.axes = self.parent.axes
        self.N = 1000
        self.t = []
        self.V = []
        self.ch_n = []
        self.fn = []
        self.Ncontrol = QtWidgets.QLineEdit(self)
        self.Ncontrol.setValidator(QtGui.QIntValidator(self.Ncontrol))
        self.Ncontrol.setFixedWidth(50)
        self.Ncontrol.setText(str(self.N))
        self.Nlabel = QtWidgets.QLabel('Data points on Fig, N=', self)

        self.refr = QtWidgets.QPushButton(QtGui.QIcon('refresh.png'), None,
                                          self)
        self.refr.clicked.connect(self.getN)

        self.addWidget(self.Nlabel)
        self.addWidget(self.Ncontrol)
        self.addWidget(self.refr)
コード例 #32
0
 def __init__(self, graph, plotWindow):
     NavigationToolbar2QT.__init__(self, graph, plotWindow)
     self._nav_stack = NStack()
コード例 #33
0
 def edit_parameters(self):
     self.canvas.fig.editAxes = True
     NavigationToolbar2QT.edit_parameters(self)
     self.canvas.fig.editAxes = False
コード例 #34
0
ファイル: multitab.py プロジェクト: apodemus/grafico
 def add(self, canvas, parent):
     tool = NavigationToolbar(canvas, parent)
     self.toolbars.append( tool )
     self.vbox.addWidget( tool )
     tool.setVisible(False)
コード例 #35
0
 def __init__(self, canvas, parent):
     NavigationToolbar2QT.__init__(self, canvas, parent)