Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Using a graph on two tabs.
Forum Updated to NodeBB v4.3 + New Features

Using a graph on two tabs.

Scheduled Pinned Locked Moved Solved Qt for Python
2 Posts 1 Posters 431 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Ed Schneider
    wrote on last edited by
    #1

    I realize that a widget can appear in only one place. In the past I used matplotlib to create a fig and then the code below to put one instance of it on one tab (Plot) and another instance, a different name, on another tab (Gallery). The first replaces whatever had been on the tab before. The second goes to the end of whatever is on the tab. I now want to do the same thing except using pyqtgraph rather than matplotlib. Is there a way to do that? Just substituting a new_fig for fig gets an attribute error. Here's the original code:
    def plot_to_gui(self, fig):

    	# Add the plot to the Plot tab (replace the current plot)
    	canvas_plot = FigureCanvas(fig)
    	width, height = (
    		int(fig.get_size_inches()[0] * fig.dpi),
    		int(fig.get_size_inches()[1] * fig.dpi))
    	canvas_plot.setFixedSize(width, height)
    	canvas_plot.draw()
    	self.tab_plot_scroll_area.setWidget(canvas_plot)
    	# #
    
    	# Add the plot to the Gallery tab (append to existing plots)
    	canvas_gallery = FigureCanvas(fig)
    	canvas_gallery.setFixedSize(width, height)
    	canvas_gallery.draw()
    	self.tab_gallery_layout.addWidget(canvas_gallery)
    
    	# Add a spacer at the end to push plots to the top
    	spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
    	self.tab_gallery_layout.addItem(spacer)
    
    	plt.close(fig)
    
    1 Reply Last reply
    0
    • E Ed Schneider has marked this topic as solved on
    • E Offline
      E Offline
      Ed Schneider
      wrote on last edited by
      #2

      For solution see "Attribute Error...."

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved