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


Python QtGui.QWidget方法代码示例

本文整理汇总了Python中PyQt5.QtGui.QWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QWidget方法的具体用法?Python QtGui.QWidget怎么用?Python QtGui.QWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtGui的用法示例。


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

示例1: tabbed_qt5_window

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def tabbed_qt5_window(self):
        from PyQt5 import QtGui, QtWidgets
        from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg, NavigationToolbar2QT
        # mpl backend can already create instance
        # https://stackoverflow.com/a/40031190
        app = QtGui.QGuiApplication.instance()
        if app is None:
            app = QtWidgets.QApplication([self.title])
        self.root_window = QtWidgets.QTabWidget()
        self.root_window.setWindowTitle(self.title)
        for name, fig in self.figures.items():
            tab = QtWidgets.QWidget(self.root_window)
            tab.canvas = FigureCanvasQTAgg(fig)
            vbox = QtWidgets.QVBoxLayout(tab)
            vbox.addWidget(tab.canvas)
            toolbar = NavigationToolbar2QT(tab.canvas, tab)
            vbox.addWidget(toolbar)
            tab.setLayout(vbox)
            for axes in fig.get_axes():
                if isinstance(axes, Axes3D):
                    # must explicitly allow mouse dragging for 3D plots
                    axes.mouse_init()
            self.root_window.addTab(tab, name)
        self.root_window.show()
        app.exec_() 
开发者ID:MichaelGrupp,项目名称:evo,代码行数:27,代码来源:plot.py

示例2: init_external_tab_ui

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def init_external_tab_ui(self):
        """External data."""
        self.external_tab = QtGui.QWidget()
        self.external_tab.setEnabled(False)
        self.external_layout = QtGui.QVBoxLayout(self.external_tab)

        self.import_data_name = QtGui.QLabel('Import External Data')
        self.import_data_label = QtGui.QLabel('...')
        self.import_data_btn = QtGui.QPushButton('Import')
        self.import_data_btn.clicked.connect(self.open_file)

        self.external_layout.addWidget(
            self.import_data_name, 0, QtCore.Qt.AlignCenter
        )
        self.external_layout.addWidget(
            self.import_data_label, 0, QtCore.Qt.AlignCenter
        )
        self.external_layout.addWidget(
            self.import_data_btn, 0, QtCore.Qt.AlignCenter
        )

        self.select_source.addTab(self.external_tab, 'Custom data') 
开发者ID:constverum,项目名称:Quantdom,代码行数:24,代码来源:ui.py

示例3: tabbed_qt4_window

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def tabbed_qt4_window(self):
        from PyQt4 import QtGui
        from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg, NavigationToolbar2QT
        # mpl backend can already create instance
        # https://stackoverflow.com/a/40031190
        app = QtGui.QApplication.instance()
        if app is None:
            app = QtGui.QApplication([self.title])
        self.root_window = QtGui.QTabWidget()
        self.root_window.setWindowTitle(self.title)
        for name, fig in self.figures.items():
            tab = QtGui.QWidget(self.root_window)
            tab.canvas = FigureCanvasQTAgg(fig)
            vbox = QtGui.QVBoxLayout(tab)
            vbox.addWidget(tab.canvas)
            toolbar = NavigationToolbar2QT(tab.canvas, tab)
            vbox.addWidget(toolbar)
            tab.setLayout(vbox)
            for axes in fig.get_axes():
                if isinstance(axes, Axes3D):
                    # must explicitly allow mouse dragging for 3D plots
                    axes.mouse_init()
            self.root_window.addTab(tab, name)
        self.root_window.show()
        app.exec_() 
开发者ID:MichaelGrupp,项目名称:evo,代码行数:27,代码来源:plot.py

示例4: mouseMoveEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def mouseMoveEvent(self, event):
        if self.show_rubberband is True:
            if self.rubberband.isVisible():
                pos = self.frame.mapFrom(self, event.pos())
                # todo: limit size
                self.rubberband.setGeometry(QtCore.QRect(self.origin, pos).normalized())
        else:
            if event.buttons() == QtCore.Qt.LeftButton:
                self.imageLabel.move(event.x() - self.dragX, event.y() - self.dragY)
            elif event.buttons() == QtCore.Qt.RightButton:
                if hasattr(self, "posval"):
                    xoff = self.central.x() + self.frame.x()
                    yoff = self.central.y() + self.frame.y()
                    x = event.x() - xoff
                    y = event.y() - yoff
                    txt = self.getPosVal(x, y)
                    self.posval.setText(txt)
                    self.posval.adjustSize()
        QtWidgets.QWidget.mouseMoveEvent(self, event) 
开发者ID:birgander2,项目名称:PyRAT,代码行数:21,代码来源:Viewer.py

示例5: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def __init__(self, parent_plot):
        QtGui.QWidget.__init__(self)
        self.parent_plot = parent_plot
        self.model = parent_plot.model

        self.plot = pg.PlotWidget(background='default')
        self.plot.showGrid(True, True, alpha=.5)
        self.plot.setMenuEnabled(True)
        self.plot.enableAutoRange()

        self.layout = QtGui.QVBoxLayout(self)
        self.layout.addWidget(self.plot) 
开发者ID:pyrocko,项目名称:kite,代码行数:14,代码来源:tab_covariance.py

示例6: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def __init__(self, horizontal=True, parent=None, decimals=3, step=.005,
                 slider_exponent=1):
        QtGui.QWidget.__init__(self, parent)
        self.vmin = None
        self.vmax = None
        self.slider_exponent = slider_exponent
        self.decimals = decimals
        self.step = 100
        self.valueLen = 2
        self.suffix = None
        self._value = None

        self.spin = QtGui.QDoubleSpinBox()
        self.spin.setDecimals(decimals)
        self.spin.setSingleStep(step)
        self.spin.valueChanged.connect(self._spin_updated)
        self.spin.setFrame(False)

        self.slider = QtGui.QSlider(
            QtCore.Qt.Orientation(1 if horizontal else 0), self)  # 1 = hor.
        self.slider.setTickPosition(
            QtGui.QSlider.TicksAbove if horizontal
            else QtGui.QSlider.TicksLeft)
        self.slider.setRange(0, 99)
        self.slider.sliderMoved.connect(self._slider_updated)

        layout = QtGui.QHBoxLayout() if horizontal else QtGui.QVBoxLayout()
        self.setLayout(layout)
        layout.addWidget(self.slider)
        layout.addWidget(self.spin) 
开发者ID:pyrocko,项目名称:kite,代码行数:32,代码来源:qt_utils.py

示例7: get_QWidget

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def get_QWidget():
    """QWidget getter."""

    try:
        import PySide.QtGui as QtGui
        return QtGui.QWidget
    except ImportError:
        import PyQt5.QtWidgets as QtWidgets
        return QtWidgets.QWidget 
开发者ID:AirbusCyber,项目名称:grap,代码行数:11,代码来源:QtShim.py

示例8: _init_canvas

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def _init_canvas(self, parent):
        """

        Parameters
        ----------
        parent : QtGui.QWidget
            The widget / dialog that will host the canvas layout
        """
        raise NotImplementedError('Include _init_canvas in your class declaration') 
开发者ID:neuropoly,项目名称:spinalcordtoolbox,代码行数:11,代码来源:base.py

示例9: _init_controls

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def _init_controls(self, parent):
        """

        Parameters
        ----------
        parent : QtGui.QWidget
            The widget / dialog that will host the control layout

        """
        raise NotImplementedError('Include _init_controls in your class declaration') 
开发者ID:neuropoly,项目名称:spinalcordtoolbox,代码行数:12,代码来源:base.py

示例10: _init_footer

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def _init_footer(self, parent):
        """

        Parameters
        ----------
        parent : QtGui.QWidget
            The widget / dialog that will host the footer layout

        Returns
        -------
            The footer layout created
        """
        ctrl_layout = QtWidgets.QHBoxLayout()

        if sys.platform.lower() == 'darwin':
            cmd_key = 'Cmd'
        else:
            cmd_key = 'Ctrl'

        self.btn_ok = QtWidgets.QPushButton('Save and Quit [%s+S]' % cmd_key)
        self.btn_undo = QtWidgets.QPushButton('Undo [%s+Z]' % cmd_key)

        ctrl_layout.addStretch()
        ctrl_layout.addWidget(self.btn_undo)
        ctrl_layout.addWidget(self.btn_ok)

        self.btn_undo.clicked.connect(self.on_undo)
        self.btn_ok.clicked.connect(self.on_save_quit)

        parent.addLayout(ctrl_layout)
        return ctrl_layout 
开发者ID:neuropoly,项目名称:spinalcordtoolbox,代码行数:33,代码来源:base.py

示例11: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def __init__(self,parent=None):
        super(TextChooser, self).__init__(parent)
        self.setGeometry(300,300,180,100)
        self.setWindowTitle('h5 key')
        self.win = QtGui.QWidget(self)
        layout = QtGui.QGridLayout()
        self.win.setLayout(layout)
        self.qedit = QtGui.QLineEdit('data')
        layout.addWidget(QtGui.QLabel('h5 key for data field'),0,0,1,3)
        layout.addWidget(self.qedit,1,0,1,2)
        done = QtGui.QPushButton('OK')
        done.clicked.connect(self.exit_list)
        layout.addWidget(done,2,1,1,1) 
开发者ID:MouseLand,项目名称:suite2p,代码行数:15,代码来源:rungui.py

示例12: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def __init__(self, Text, parent=None):
        super(ListChooser, self).__init__(parent)
        self.setGeometry(300,300,500,320)
        self.setWindowTitle(Text)
        self.win = QtGui.QWidget(self)
        layout = QtGui.QGridLayout()
        self.win.setLayout(layout)
        #self.setCentralWidget(self.win)
        loadcell = QtGui.QPushButton('Load iscell.npy')
        loadcell.resize(200,50)
        loadcell.clicked.connect(self.load_cell)
        layout.addWidget(loadcell,0,0,1,1)
        loadtext = QtGui.QPushButton('Load txt file list')
        loadtext.clicked.connect(self.load_text)
        layout.addWidget(loadtext,0,1,1,1)
        layout.addWidget(QtGui.QLabel('(select multiple using ctrl)'),1,0,1,1)
        self.list = QtGui.QListWidget(parent)
        layout.addWidget(self.list,2,0,5,4)
        #self.list.resize(450,250)
        self.list.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)
        save = QtGui.QPushButton('build classifier')
        save.clicked.connect(lambda: self.build_classifier(parent))
        layout.addWidget(save,8,0,1,1)
        self.apply = QtGui.QPushButton('load in GUI')
        self.apply.clicked.connect(lambda: self.apply_class(parent))
        self.apply.setEnabled(False)
        layout.addWidget(self.apply,8,1,1,1)
        self.saveasdefault = QtGui.QPushButton('save as default')
        self.saveasdefault.clicked.connect(lambda: self.save_default(parent))
        self.saveasdefault.setEnabled(False)
        layout.addWidget(self.saveasdefault,8,2,1,1)
        done = QtGui.QPushButton('close')
        done.clicked.connect(self.exit_list)
        layout.addWidget(done,8,3,1,1) 
开发者ID:MouseLand,项目名称:suite2p,代码行数:36,代码来源:classgui.py

示例13: init_shares_tab_ui

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def init_shares_tab_ui(self):
        """Shares."""
        self.shares_tab = QtGui.QWidget()
        self.shares_layout = QtGui.QFormLayout(self.shares_tab)
        today = datetime.today()

        self.shares_date_from = QtGui.QDateEdit()
        self.shares_date_from.setMinimumDate(QtCore.QDate(1900, 1, 1))
        self.shares_date_from.setMaximumDate(QtCore.QDate(2030, 12, 31))
        self.shares_date_from.setDate(QtCore.QDate(today.year, 1, 1))
        self.shares_date_from.setDisplayFormat('dd.MM.yyyy')

        self.shares_date_to = QtGui.QDateEdit()
        self.shares_date_to.setMinimumDate(QtCore.QDate(1900, 1, 1))
        self.shares_date_to.setMaximumDate(QtCore.QDate(2030, 12, 31))
        self.shares_date_to.setDate(
            QtCore.QDate(today.year, today.month, today.day)
        )
        self.shares_date_to.setDisplayFormat('dd.MM.yyyy')

        self.shares_symbol_list = QtGui.QComboBox()
        self.shares_symbol_list.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.shares_symbol_list.setMaxVisibleItems(20)
        self.shares_symbol_list.setEditable(True)

        self.shares_show_btn = QtGui.QPushButton('Load')
        self.shares_show_btn.clicked.connect(self.update_data)

        self.shares_layout.addRow('From', self.shares_date_from)
        self.shares_layout.addRow('To', self.shares_date_to)
        self.shares_layout.addRow('Symbol', self.shares_symbol_list)
        self.shares_layout.addRow(None, self.shares_show_btn)

        self.select_source.addTab(self.shares_tab, 'Shares/Futures/ETFs') 
开发者ID:constverum,项目名称:Quantdom,代码行数:36,代码来源:ui.py

示例14: __init__

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def __init__(self, nAxes, parent = None):
        QtGui.QWidget.__init__(self, parent)
        self.canvas = OverlapCanvas(nAxes)
        self.vbl = QtGui.QVBoxLayout()
        self.vbl.addWidget(self.canvas)
        self.setLayout(self.vbl) 
开发者ID:AOtools,项目名称:soapy,代码行数:8,代码来源:gui.py

示例15: mousePressEvent

# 需要导入模块: from PyQt5 import QtGui [as 别名]
# 或者: from PyQt5.QtGui import QWidget [as 别名]
def mousePressEvent(self, event):
        if self.show_rubberband is True:
            # self.origin = event.pos()
            self.origin = self.frame.mapFrom(self, event.pos())
            self.rubberband.setGeometry(QtCore.QRect(self.origin, QtCore.QSize()))
            self.rubberband.show()
        else:
            if event.button() == QtCore.Qt.RightButton and self.current is not None:
                xoff = self.central.x() + self.frame.x()  # easier with self.frame.mapFrom()
                yoff = self.central.y() + self.frame.y()
                x = event.x() - xoff
                y = event.y() - yoff
                txt = self.getPosVal(x, y)
                if hasattr(self, "posval"):
                    self.posval.setText(txt)
                    self.posval.adjustSize()
                    self.posval.show()
                else:
                    self.posval = QtWidgets.QLabel(txt)
                    self.posval.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
                    self.posval.setWindowTitle("position / value")
                    self.posval.setGeometry(self.x() + xoff, self.y() + yoff, 200, 100)
                    self.posval.adjustSize()
                    self.posval.show()
            else:
                self.dragX = event.x()
                self.dragY = event.y()

        QtWidgets.QWidget.mousePressEvent(self, event) 
开发者ID:birgander2,项目名称:PyRAT,代码行数:31,代码来源:Viewer.py


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