本文整理汇总了Python中guidata.qt.QtGui.QGridLayout.addWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QGridLayout.addWidget方法的具体用法?Python QGridLayout.addWidget怎么用?Python QGridLayout.addWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类guidata.qt.QtGui.QGridLayout
的用法示例。
在下文中一共展示了QGridLayout.addWidget方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SubplotWidget
# 需要导入模块: from guidata.qt.QtGui import QGridLayout [as 别名]
# 或者: from guidata.qt.QtGui.QGridLayout import addWidget [as 别名]
class SubplotWidget(QSplitter):
"""Construct a Widget that helps managing several plots
together handled by the same manager
Since the plots must be added to the manager before the panels
the add_itemlist method can be called after having declared
all the subplots
"""
def __init__(self, manager, parent=None, **kwargs):
super(SubplotWidget, self).__init__(parent, **kwargs)
self.setOrientation(Qt.Horizontal)
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.manager = manager
self.plots = []
self.itemlist = None
main = QWidget()
self.plotlayout = QGridLayout()
main.setLayout(self.plotlayout)
self.addWidget(main)
def add_itemlist(self, show_itemlist=False):
self.itemlist = PlotItemList(self)
self.itemlist.setVisible(show_itemlist)
self.addWidget(self.itemlist)
configure_plot_splitter(self)
self.manager.add_panel(self.itemlist)
def add_subplot(self, plot, i=0, j=0, plot_id=None):
"""Add a plot to the grid of plots"""
self.plotlayout.addWidget(plot, i, j)
self.plots.append(plot)
if plot_id is None:
plot_id = id(plot)
self.manager.add_plot(plot, plot_id)
示例2: create_slice_dock
# 需要导入模块: from guidata.qt.QtGui import QGridLayout [as 别名]
# 或者: from guidata.qt.QtGui.QGridLayout import addWidget [as 别名]
def create_slice_dock(self):
widget = QWidget()
dock = QDockWidget("Slice", self)
dock.setAllowedAreas(Qt.TopDockWidgetArea | Qt.BottomDockWidgetArea |
Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.addDockWidget(Qt.BottomDockWidgetArea, dock)
layout = QGridLayout(widget)
self.slice_index_spin_box = QSpinBox()
index_max = self.map_.measurement.param.axis3.get_length()
self.slice_index_spin_box.setRange(0, index_max-1 )
slice_slider = QSlider(Qt.Horizontal)
slice_slider.setRange(0, index_max-1)
self.connect(self.slice_index_spin_box, SIGNAL("valueChanged(int)"),
self.set_slice_index)
self.connect(slice_slider, SIGNAL("valueChanged(int)"),
self.slice_index_spin_box.setValue)
self.connect(self.slice_index_spin_box, SIGNAL("valueChanged(int)"),
slice_slider.setValue)
self.slice_value_spin_box = QDoubleSpinBox()
scale = self.map_.measurement.param.axis3.get_scale()
self.slice_value_spin_box.setRange(scale.min(),scale.max())
self.slice_value_spin_box.setValue(scale[0])
self.connect(self.slice_value_spin_box, SIGNAL("valueChanged(double)"),
self.set_slice_value)
unit = self.map_.measurement.param.axis3.unit
self.slice_value_spin_box.setSuffix(unit)
layout.addWidget(slice_slider, 0, 0)
layout.addWidget(self.slice_index_spin_box, 0, 1)
layout.addWidget(self.slice_value_spin_box, 0, 2)
dock.setWidget(widget)
示例3: __init__
# 需要导入模块: from guidata.qt.QtGui import QGridLayout [as 别名]
# 或者: from guidata.qt.QtGui.QGridLayout import addWidget [as 别名]
def __init__(self, parent=None):
QFrame.__init__(self, parent)
layout = QGridLayout()
self.setLayout(layout)
angle = 0
for row in range(7):
for column in range(7):
layout.addWidget(RotatedLabel("Label %03d°" % angle,
angle=angle, color=Qt.blue,
bold=True),
row, column, Qt.AlignCenter)
angle += 10
示例4: __init__
# 需要导入模块: from guidata.qt.QtGui import QGridLayout [as 别名]
# 或者: from guidata.qt.QtGui.QGridLayout import addWidget [as 别名]
def __init__(self, item, parent_layout):
super(MultipleChoiceWidget, self).__init__(item, parent_layout)
self.groupbox = self.group = QGroupBox(item.get_prop_value("display", "label"))
layout = QGridLayout()
self.boxes = []
nx, ny = item.get_prop_value("display", "shape")
cx, cy = 0, 0
_choices = item.get_prop_value("data", "choices")
for _, choice, _img in _choices:
checkbox = QCheckBox(choice)
layout.addWidget(checkbox, cx, cy)
if nx < 0:
cy += 1
if cy >= ny:
cy = 0
cx += 1
else:
cx += 1
if cx >= nx:
cx = 0
cy += 1
self.boxes.append(checkbox)
self.groupbox.setLayout(layout)
示例5: __init__
# 需要导入模块: from guidata.qt.QtGui import QGridLayout [as 别名]
# 或者: from guidata.qt.QtGui.QGridLayout import addWidget [as 别名]
def __init__(self, parent):
QWidget.__init__(self, parent)
layout = QGridLayout()
self.setLayout(layout)
self.plot1 = ImagePlot(self)
layout.addWidget(self.plot1, 0, 0, 1, 1)
self.plot2 = ImagePlot(self)
layout.addWidget(self.plot2, 1, 0, 1, 1)
self.contrast = ContrastAdjustment(self)
layout.addWidget(self.contrast, 2, 0, 1, 2)
self.itemlist = PlotItemList(self)
layout.addWidget(self.itemlist, 0, 1, 2, 1)
self.manager = PlotManager(self)
for plot in (self.plot1, self.plot2):
self.manager.add_plot(plot)
for panel in (self.itemlist, self.contrast):
self.manager.add_panel(panel)
示例6: CurveWidgetMixin
# 需要导入模块: from guidata.qt.QtGui import QGridLayout [as 别名]
# 或者: from guidata.qt.QtGui.QGridLayout import addWidget [as 别名]
class CurveWidgetMixin(PlotManager):
def __init__(self, wintitle="guiqwt plot", icon="guiqwt.svg",
toolbar=False, options=None, panels=None):
PlotManager.__init__(self, main=self)
self.plot_layout = QGridLayout()
if options is None:
options = {}
self.plot_widget = None
self.create_plot(options)
if panels is not None:
for panel in panels:
self.add_panel(panel)
self.toolbar = QToolBar(_("Tools"))
if not toolbar:
self.toolbar.hide()
# Configuring widget layout
self.setup_widget_properties(wintitle=wintitle, icon=icon)
self.setup_widget_layout()
# Configuring plot manager
self.add_toolbar(self.toolbar, "default")
self.register_tools()
def setup_widget_layout(self):
raise NotImplementedError
def setup_widget_properties(self, wintitle, icon):
self.setWindowTitle(wintitle)
if is_text_string(icon):
icon = get_icon(icon)
if icon is not None:
self.setWindowIcon(icon)
self.setMinimumSize(320, 240)
self.resize(640, 480)
def register_tools(self):
"""
Register the plotting dialog box tools: the base implementation
provides standard, curve-related and other tools - i.e. calling
this method is exactly the same as calling
:py:meth:`guiqwt.plot.CurveDialog.register_all_curve_tools`
This method may be overriden to provide a fully customized set of tools
"""
self.register_all_curve_tools()
def create_plot(self, options, row=0, column=0, rowspan=1, columnspan=1):
"""
Create the plotting widget (which is an instance of class
:py:class:`guiqwt.plot.BaseCurveWidget`), add it to the dialog box
main layout (:py:attr:`guiqwt.plot.CurveDialog.plot_layout`) and
then add the `item list` panel
May be overriden to customize the plot layout
(:py:attr:`guiqwt.plot.CurveDialog.plot_layout`)
"""
self.plot_widget = BaseCurveWidget(self, **options)
self.plot_layout.addWidget(self.plot_widget,
row, column, rowspan, columnspan)
# Configuring plot manager
self.add_plot(self.plot_widget.plot)
self.add_panel(self.plot_widget.itemlist)
示例7: Window
# 需要导入模块: from guidata.qt.QtGui import QGridLayout [as 别名]
# 或者: from guidata.qt.QtGui.QGridLayout import addWidget [as 别名]
class Window(QMainWindow):
def __init__(self, wintitle):
super(Window, self).__init__()
self.default_tool = None
self.plots = []
self.itemlist = PlotItemList(None)
self.contrast = ContrastAdjustment(None)
self.xcsw = XCrossSection(None)
self.ycsw = YCrossSection(None)
self.manager = PlotManager(self)
self.toolbar = QToolBar(_("Tools"), self)
self.manager.add_toolbar(self.toolbar, "default")
self.toolbar.setMovable(True)
self.toolbar.setFloatable(True)
self.addToolBar(Qt.TopToolBarArea, self.toolbar)
frame = QFrame(self)
self.setCentralWidget(frame)
self.layout = QGridLayout()
layout = QVBoxLayout(frame)
frame.setLayout(layout)
layout.addLayout(self.layout)
self.frame = frame
self.setWindowTitle(wintitle)
self.setWindowIcon(get_icon('guiqwt.svg'))
def closeEvent(self, event):
global _figures, _current_fig, _current_axes
figure_title = to_text_string(self.windowTitle())
if _figures.pop(figure_title) == _current_fig:
_current_fig = None
_current_axes = None
self.itemlist.close()
self.contrast.close()
self.xcsw.close()
self.ycsw.close()
event.accept()
def add_plot(self, i, j, plot):
self.layout.addWidget(plot, i, j)
self.manager.add_plot(plot)
self.plots.append(plot)
def replot(self):
for plot in self.plots:
plot.replot()
item = plot.get_default_item()
if item is not None:
plot.set_active_item(item)
item.unselect()
def add_panels(self, images=False):
self.manager.add_panel(self.itemlist)
if images:
for panel in (self.ycsw, self.xcsw, self.contrast):
panel.hide()
self.manager.add_panel(panel)
def register_tools(self, images=False):
if images:
self.manager.register_all_image_tools()
else:
self.manager.register_all_curve_tools()
def display(self):
self.show()
self.replot()
self.manager.get_default_tool().activate()
self.manager.update_tools_status()