本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.height方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.height方法的具体用法?Python FigureCanvasQTAgg.height怎么用?Python FigureCanvasQTAgg.height使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.height方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StatsDialog
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import height [as 别名]
class StatsDialog(QDialog):
def __init__(self, standalone=True):
QDialog.__init__(self)
self.setWindowIcon(QIcon("img/32x32/view-statistics.png"))
self.setWindowTitle("Statistics")
layout = QVBoxLayout()
self.canvas_width = 0
self.canvas_height = 0
self.canvas = None
self.standalone = standalone
self.page = 0
self.len_page = 100
self.fig = None
self.tabs = QTabWidget()
self.stats_image = QWidget()
self.tabs.addTab(self.stats_image, QIcon("img/32x32/view-investment.png"), "Statistics")
self.list_container = QWidget()
list_layout = QVBoxLayout()
self.list_pager = QWidget()
pager_layout = QHBoxLayout()
self.page_num_label = QLabel()
first_button = QPushButton(QIcon.fromTheme("arrow-left-double", QIcon.fromTheme("go-first")), "")
prev_button = QPushButton(QIcon.fromTheme("arrow-left", QIcon.fromTheme("go-previous")), "")
next_button = QPushButton(QIcon.fromTheme("arrow-right", QIcon.fromTheme("go-next")), "")
last_button = QPushButton(QIcon.fromTheme("arrow-right-double", QIcon.fromTheme("go-last")), "")
self.connect(prev_button, SIGNAL("clicked()"), self.prev_page)
self.connect(next_button, SIGNAL("clicked()"), self.next_page)
self.connect(first_button, SIGNAL("clicked()"), self.first_page)
self.connect(last_button, SIGNAL("clicked()"), self.last_page)
pager_layout.addStretch()
pager_layout.addWidget(first_button)
pager_layout.addWidget(prev_button)
pager_layout.addWidget(self.page_num_label)
pager_layout.addWidget(next_button)
pager_layout.addWidget(last_button)
pager_layout.addStretch()
self.list_widget = QTableWidget()
self.list_widget.insertColumn(0)
self.list_widget.insertColumn(0)
self.list_widget.insertColumn(0)
self.list_widget.setColumnWidth(0, 150)
self.list_widget.setColumnWidth(2, 150)
self.list_widget.setHorizontalHeaderItem(0, QTableWidgetItem("Name"))
self.list_widget.setHorizontalHeaderItem(1, QTableWidgetItem("Price"))
self.list_widget.setHorizontalHeaderItem(2, QTableWidgetItem("Time/Date"))
self.list_pager.setLayout(pager_layout)
list_layout.addWidget(self.list_pager)
list_layout.addWidget(self.list_widget)
self.list_container.setLayout(list_layout)
self.tabs.addTab(self.list_container, QIcon("img/32x32/view-income-categories.png"), "List")
layout.addWidget(self.tabs)
if self.standalone:
button_box = QDialogButtonBox()
ok_button = button_box.addButton(button_box.Ok)
self.connect(ok_button, SIGNAL("clicked()"), self.ok_clicked)
layout.addWidget(button_box)
self.setLayout(layout)
def update(self, transactions):
self.transactions = transactions
self.page = 0
self.update_list(self.transactions)
fig = renderPlot(self.transactions)
if self.canvas:
self.canvas.setParent(None)
self.canvas.destroy()
try:
self.canvas = FigureCanvasQTAgg(fig)
self.hide()
self.canvas.setParent(self.stats_image)
self.show()
self.resize(self.canvas.width(), self.canvas.height() + 100)
except AttributeError:
# pass if there are still no transactions
pass
def update_list(self, transactions):
self.transactions = transactions
self.list_widget.clear()
self.list_widget.setRowCount(0)
reverse_transactions = transactions.reverse()
self.page_num_label.setText(str(self.page + 1) + "/" + str(len(transactions) / self.len_page + 1))
for idx, transaction in enumerate(transactions[self.page * self.len_page : (self.page + 1) * self.len_page]):
self.list_widget.insertRow(idx)
self.list_widget.setCellWidget(idx, 0, QLabel(transaction.customer.name))
self.list_widget.setCellWidget(idx, 1, QLabel(str(transaction.price) + u" \u20AC"))
self.list_widget.setCellWidget(idx, 2, QLabel(transaction.time.strftime("%H:%M:%S, %d.%m.%Y")))
def first_page(self):
if self.page != 0:
self.page = 0
self.update_list(self.transactions)
def prev_page(self):
if self.page > 0:
self.page -= 1
#.........这里部分代码省略.........
示例2: IScatterWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import height [as 别名]
#.........这里部分代码省略.........
self.export_to_cp_btn = QtGui.QPushButton('Export image clipboard')
axis_selector_layout.addWidget(self.export_to_cp_btn)
self.export_to_cp_btn.clicked.connect(self.export_axes_to_clipboard)
self.cmb_colormap = QtGui.QComboBox(self)
for c in SimpleMplImageViewerWithBlending.colors:
self.cmb_colormap.addItem(c)
axis_selector_layout.addWidget(self.cmb_colormap)
self.cmb_colormap.currentIndexChanged[str].connect(self.colormap_changed)
self.btn_move_to_combined_image = QtGui.QPushButton('vv')
axis_selector_layout.addWidget(self.btn_move_to_combined_image)
self.btn_move_to_combined_image.clicked.connect(self.move_to_combined_image)
axis_selector.setLayout(axis_selector_layout)
layout.addWidget(axis_selector)
self.setLayout(layout)
self.canvas.mpl_connect('scroll_event', self.mouse_wheel_zoom)
def colormap_changed(self, colormap):
self.current_cmap = str(colormap)
self.update_axis()
def move_to_combined_image(self):
self.send_current_image.emit(self.current_raw_images)
def export_axes_to_clipboard(self):
bbox = self.axes.get_window_extent().transformed(self.figure.dpi_scale_trans.inverted())
x, y, width, height = bbox.x0, bbox.y1, bbox.width, bbox.height
width *= self.figure.dpi
height *= self.figure.dpi
x *= self.figure.dpi
y *= self.figure.dpi
pixmap = QtGui.QPixmap.grabWidget(self.canvas, int(x)+3, self.canvas.height() - int(y)+3, int(width)-5, int(height)-5)
QtGui.QApplication.clipboard().setPixmap(pixmap)
def export_axes_to_image(self):
file_name = QtGui.QFileDialog.getSaveFileName(self, "Select file name", ".", "Image Files (*.png *.jpg *.pdf)")
print file_name
if file_name:
extent = self.axes.get_window_extent().transformed(self.figure.dpi_scale_trans.inverted())
self.figure.savefig(str(file_name), bbox_inches=extent)
def sample_selection_changed(self, type_, idx):
self.sample_selection = [True] * len(self.sample_selection)
lkp_tmp = dict([v, u] for u, v in enumerate(['Plate', 'Well', 'Site', 'Treatment 1', 'Treatment 2', 'Group']))
for cur_sel_type, cur_sel_box in self.sample_selection_dct.items():
cur_sel = str(cur_sel_box.currentText())
if cur_sel.startswith('All'):
continue
for i, s in enumerate(self.sample_ids):
if not s[lkp_tmp[cur_sel_type]].startswith(cur_sel):
self.sample_selection[i] = False
self.update_axis()
def result_selection_changed(self, type_):
self.update_axis()