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


Python QtGui.QGridLayout类代码示例

本文整理汇总了Python中guidata.qt.QtGui.QGridLayout的典型用法代码示例。如果您正苦于以下问题:Python QGridLayout类的具体用法?Python QGridLayout怎么用?Python QGridLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: SubplotWidget

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)
开发者ID:alimuldal,项目名称:guiqwt,代码行数:34,代码来源:plot.py

示例2: __init__

 def __init__(self, item, parent_layout):
     super(TabGroupWidget, self).__init__(item, parent_layout)
     self.tabs = QTabWidget()
     items = item.item.group
     self.widgets = []
     for item in items:
         if item.get_prop_value("display", parent_layout.instance,
                                "hide", False):
             continue
         item.set_prop("display", embedded=True)
         widget = parent_layout.build_widget(item)
         frame = QFrame()
         label = widget.item.get_prop_value("display", "label")
         icon = widget.item.get_prop_value("display", "icon", None)
         if icon is not None:
             self.tabs.addTab(frame, get_icon(icon), label)
         else:
             self.tabs.addTab(frame, label)
         layout = QGridLayout()
         layout.setAlignment(Qt.AlignTop)
         frame.setLayout(layout)
         widget.place_on_grid(layout, 0, 0, 1)
         try:
             widget.get()
         except Exception:
             print("Error building item :", item.item._name)
             raise
         self.widgets.append(widget)
开发者ID:artillan,项目名称:guidata,代码行数:28,代码来源:qtitemwidgets.py

示例3: create_slice_dock

    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)
开发者ID:fbianco,项目名称:thoth,代码行数:31,代码来源:thoth.py

示例4: __init__

 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
开发者ID:CARIBOuSystem,项目名称:guidata,代码行数:12,代码来源:rotatedlabel.py

示例5: __init__

    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()
开发者ID:alimuldal,项目名称:guiqwt,代码行数:26,代码来源:plot.py

示例6: __init__

    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'))
开发者ID:stonebig,项目名称:guiqwt-1,代码行数:26,代码来源:pyplot.py

示例7: __init__

 def __init__(self, manager, parent=None):
     QSplitter.__init__(self, Qt.Horizontal, parent)
     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)
开发者ID:HaMF,项目名称:guiqwt,代码行数:10,代码来源:plot.py

示例8: __init__

 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)
开发者ID:CARIBOuSystem,项目名称:guidata,代码行数:23,代码来源:qtitemwidgets.py

示例9: setup_widget_layout

 def setup_widget_layout(self):
     self.fit_layout = QHBoxLayout()
     self.params_layout = QGridLayout()
     params_group = create_groupbox(self, _("Fit parameters"),
                                    layout=self.params_layout)
     if self.auto_fit_enabled:
         auto_group = self.create_autofit_group()
         self.fit_layout.addWidget(auto_group)
     self.fit_layout.addWidget(params_group)
     self.plot_layout.addLayout(self.fit_layout, 1, 0)
     
     vlayout = QVBoxLayout(self)
     vlayout.addWidget(self.toolbar)
     vlayout.addLayout(self.plot_layout)
     self.setLayout(vlayout)
开发者ID:CaptainAL,项目名称:Spyder,代码行数:15,代码来源:fit.py

示例10: __init__

    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)
开发者ID:gyenney,项目名称:Tools,代码行数:21,代码来源:manager.py

示例11: setup_instance

 def setup_instance(self, instance):
     """Construct main layout"""
     grid = QGridLayout()
     grid.setAlignment(Qt.AlignTop)
     self.layout.addLayout(grid)
     self.edit_layout.append( self.layout_factory( instance, grid) )
开发者ID:Alwnikrotikz,项目名称:guidata,代码行数:6,代码来源:qtwidgets.py

示例12: FloatArrayWidget

class FloatArrayWidget(AbstractDataSetWidget):
    """
    FloatArrayItem widget
    """
    def __init__(self, item, parent_layout):
        super(FloatArrayWidget, self).__init__(item, parent_layout)
        _label = item.get_prop_value("display", "label")
        self.groupbox = self.group = QGroupBox(_label)
        self.layout = QGridLayout()
        self.layout.setAlignment(Qt.AlignLeft)
        self.groupbox.setLayout(self.layout)
        
        self.first_line, self.dim_label = get_image_layout("shape.png",
                                   _("Number of rows x Number of columns"))
        edit_button = QPushButton(get_icon("arredit.png"), "")
        edit_button.setToolTip(_("Edit array contents"))
        edit_button.setMaximumWidth(32)
        self.first_line.addWidget(edit_button)
        self.layout.addLayout(self.first_line, 0, 0)
        
        self.min_line, self.min_label = get_image_layout("min.png",
                                                 _("Smallest element in array"))
        self.layout.addLayout(self.min_line, 1, 0)
        self.max_line, self.max_label = get_image_layout("max.png",
                                                 _("Largest element in array"))
        self.layout.addLayout(self.max_line, 2, 0)
        
        edit_button.clicked.connect(self.edit_array)
        self.arr = None # le tableau si il a été modifié
        self.instance = None

    def edit_array(self):
        """Open an array editor dialog"""
        parent = self.parent_layout.parent
        label = self.item.get_prop_value("display", "label")
        try:
            # Spyder 3
            from spyderlib.widgets.variableexplorer import arrayeditor
        except ImportError:
            # Spyder 2
            from spyderlib.widgets import arrayeditor
        editor = arrayeditor.ArrayEditor(parent)
        if editor.setup_and_check(self.arr, title=label):
            if editor.exec_():
                self.update(self.arr)
        
    def get(self):
        """Override AbstractDataSetWidget method"""
        self.arr = numpy.array(self.item.get(), copy=False)
        if self.item.get_prop_value("display", "transpose"):
            self.arr = self.arr.T
        self.update(self.arr)

    def update(self, arr):
        """Override AbstractDataSetWidget method"""
        shape = arr.shape
        if len(shape) == 1:
            shape = (1,) + shape
        dim = " x ".join( [ str(d) for d in shape ])
        self.dim_label.setText(dim)
        
        format = self.item.get_prop_value("display", "format")
        minmax = self.item.get_prop_value("display", "minmax")
        try:
            if minmax == "all":
                mint = format % arr.min()
                maxt = format % arr.max()
            elif minmax == "columns":
                mint = ", ".join([format % arr[r,:].min()
                                  for r in range(arr.shape[0])])
                maxt = ", ".join([format % arr[r,:].max()
                                  for r in range(arr.shape[0])])
            else:
                mint = ", ".join([format % arr[:, r].min()
                                  for r in range(arr.shape[1])])
                maxt = ", ".join([format % arr[:, r].max()
                                  for r in range(arr.shape[1])])
        except (TypeError, IndexError):
            mint, maxt = "-", "-"
        self.min_label.setText(mint)
        self.max_label.setText(maxt)

    def set(self):
        """Override AbstractDataSetWidget method"""
        if self.item.get_prop_value("display", "transpose"):
            value = self.value().T
        else:
            value = self.value()
        self.item.set(value)

    def value(self):
        return self.arr

    def place_on_grid(self, layout, row, label_column, widget_column,
                      row_span=1, column_span=1):
        """Override AbstractDataSetWidget method"""
        layout.addWidget(self.group, row, label_column, row_span, column_span+1)
开发者ID:artillan,项目名称:guidata,代码行数:97,代码来源:qtitemwidgets.py

示例13: Window

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()
开发者ID:stonebig,项目名称:guiqwt-1,代码行数:71,代码来源:pyplot.py

示例14: FitWidgetMixin

class FitWidgetMixin(CurveWidgetMixin):
    def __init__(self, wintitle="guiqwt plot", icon="guiqwt.svg",
                 toolbar=False, options=None, panels=None, param_cols=1,
                 legend_anchor='TR', auto_fit=True):
        if wintitle is None:
            wintitle = _('Curve fitting')

        self.x = None
        self.y = None
        self.fitfunc = None
        self.fitargs = None
        self.fitkwargs = None
        self.fitparams = None
        self.autofit_prm = None
        
        self.data_curve = None
        self.fit_curve = None
        self.legend = None
        self.legend_anchor = legend_anchor
        self.xrange = None
        self.show_xrange = False
        
        self.param_cols = param_cols
        self.auto_fit_enabled = auto_fit      
        self.button_list = [] # list of buttons to be disabled at startup

        self.fit_layout = None
        self.params_layout = None
        
        CurveWidgetMixin.__init__(self, wintitle=wintitle, icon=icon, 
                                  toolbar=toolbar, options=options,
                                  panels=panels)
        
        self.refresh()
        
    # QWidget API --------------------------------------------------------------
    def resizeEvent(self, event):
        QWidget.resizeEvent(self, event)
        self.get_plot().replot()
        
    # CurveWidgetMixin API -----------------------------------------------------
    def setup_widget_layout(self):
        self.fit_layout = QHBoxLayout()
        self.params_layout = QGridLayout()
        params_group = create_groupbox(self, _("Fit parameters"),
                                       layout=self.params_layout)
        if self.auto_fit_enabled:
            auto_group = self.create_autofit_group()
            self.fit_layout.addWidget(auto_group)
        self.fit_layout.addWidget(params_group)
        self.plot_layout.addLayout(self.fit_layout, 1, 0)
        
        vlayout = QVBoxLayout(self)
        vlayout.addWidget(self.toolbar)
        vlayout.addLayout(self.plot_layout)
        self.setLayout(vlayout)
        
    def create_plot(self, options):
        CurveWidgetMixin.create_plot(self, options)
        for plot in self.get_plots():
            plot.SIG_RANGE_CHANGED.connect(self.range_changed)
        
    # Public API ---------------------------------------------------------------  
    def set_data(self, x, y, fitfunc=None, fitparams=None,
                 fitargs=None, fitkwargs=None):
        if self.fitparams is not None and fitparams is not None:
            self.clear_params_layout()
        self.x = x
        self.y = y
        if fitfunc is not None:
            self.fitfunc = fitfunc
        if fitparams is not None:
            self.fitparams = fitparams
        if fitargs is not None:
            self.fitargs = fitargs
        if fitkwargs is not None:
            self.fitkwargs = fitkwargs
        self.autofit_prm = AutoFitParam(title=_("Automatic fitting options"))
        self.autofit_prm.xmin = x.min()
        self.autofit_prm.xmax = x.max()
        self.compute_imin_imax()
        if self.fitparams is not None and fitparams is not None:
            self.populate_params_layout()
        self.refresh()
        
    def set_fit_data(self, fitfunc, fitparams, fitargs=None, fitkwargs=None):
        if self.fitparams is not None:
            self.clear_params_layout()
        self.fitfunc = fitfunc
        self.fitparams = fitparams
        self.fitargs = fitargs
        self.fitkwargs = fitkwargs
        self.populate_params_layout()
        self.refresh()
        
    def clear_params_layout(self):
        for i, param in enumerate(self.fitparams):
            for widget in param.get_widgets():
                if widget is not None:
                    self.params_layout.removeWidget(widget)
#.........这里部分代码省略.........
开发者ID:CaptainAL,项目名称:Spyder,代码行数:101,代码来源:fit.py

示例15: CurveWidgetMixin

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)
开发者ID:alimuldal,项目名称:guiqwt,代码行数:68,代码来源:plot.py


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