Python PyQt5.QtGui.QWidget() Examples

The following are 28 code examples of PyQt5.QtGui.QWidget(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .
Example #1
Source File: Viewer.py    From PyRAT with Mozilla Public License 2.0 6 votes vote down vote up
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) 
Example #2
Source File: plot.py    From evo_slam with GNU General Public License v3.0 6 votes vote down vote up
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_() 
Example #3
Source File: plot.py    From evo with GNU General Public License v3.0 6 votes vote down vote up
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_() 
Example #4
Source File: plot.py    From evo with GNU General Public License v3.0 6 votes vote down vote up
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_() 
Example #5
Source File: ui.py    From Quantdom with Apache License 2.0 6 votes vote down vote up
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') 
Example #6
Source File: plot.py    From evo_slam with GNU General Public License v3.0 6 votes vote down vote up
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_() 
Example #7
Source File: rungui.py    From suite2p with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent=None):
        super(RunWindow, self).__init__(parent)
        self.setGeometry(10,10,1500,900)
        self.setWindowTitle('Choose run options (hold mouse over parameters to see descriptions)')
        self.parent = parent
        self.win = QtGui.QWidget(self)
        self.layout = QtGui.QGridLayout()
        self.layout.setVerticalSpacing(2)
        self.layout.setHorizontalSpacing(25)
        self.win.setLayout(self.layout)
        # initial ops values
        self.opsfile = parent.opsuser
        try:
            self.reset_ops()
            print('loaded default ops')
        except Exception as e:
            print('ERROR: %s'%e)
            print('could not load default ops, using built-in ops settings')
            self.ops = run_s2p.default_ops()

        # remove any remaining ops files
        fs = glob.glob('ops*.npy')
        for f in fs:
            os.remove(f)
        fs = glob.glob('db*.npy')
        for f in fs:
            os.remove(f)

        self.data_path = []
        self.save_path = []
        self.fast_disk = []
        self.opslist = []
        self.batch = False
        self.f = 0
        self.create_buttons() 
Example #8
Source File: Viewer.py    From PyRAT with Mozilla Public License 2.0 5 votes vote down vote up
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) 
Example #9
Source File: gui.py    From soapy with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)
        self.canvas = PlotCanvas()
        self.vbl = QtGui.QVBoxLayout()
        self.vbl.addWidget(self.canvas)
        self.setLayout(self.vbl) 
Example #10
Source File: gui.py    From soapy with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #11
Source File: ui.py    From Quantdom with Apache License 2.0 5 votes vote down vote up
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') 
Example #12
Source File: classgui.py    From suite2p with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #13
Source File: rungui.py    From suite2p with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #14
Source File: base.py    From spinalcordtoolbox with MIT License 5 votes vote down vote up
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 
Example #15
Source File: base.py    From spinalcordtoolbox with MIT License 5 votes vote down vote up
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') 
Example #16
Source File: base.py    From spinalcordtoolbox with MIT License 5 votes vote down vote up
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') 
Example #17
Source File: dummy_plugin.py    From ayab-desktop with GNU General Public License v3.0 5 votes vote down vote up
def setup_ui(self, parent_ui):
    self.parent_ui = parent_ui
    dock = parent_ui.ui.knitting_options_dock
    self.qwidget = QtGui.QWidget(dock)
    self.configure_button = QtGui.QPushButton(self.qwidget)
    self.configure_button.setObjectName(_fromUtf8("configure_button"))
    self.configure_button.setText(_translate("DockWidget", "Configure", None))
    self.configure_button.clicked.connect(self.__conf_button_function)
    dock.setWidget(self.qwidget) 
Example #18
Source File: QtShim.py    From grap with MIT License 5 votes vote down vote up
def get_QWidget():
    """QWidget getter."""

    try:
        import PySide.QtGui as QtGui
        return QtGui.QWidget
    except ImportError:
        import PyQt5.QtWidgets as QtWidgets
        return QtWidgets.QWidget 
Example #19
Source File: dummy_plugin.py    From ayab-desktop with GNU General Public License v3.0 5 votes vote down vote up
def cleanup_ui(self, parent_ui):
    self.parent_ui = parent_ui
    dock = parent_ui.ui.knitting_options_dock
    cleaner = QtCore.QObjectCleanupHandler()
    cleaner.add(self.qwidget)
    self.__qw = QtGui.QWidget()
    dock.setWidget(self.__qw) 
Example #20
Source File: qt_utils.py    From kite with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #21
Source File: tab_covariance.py    From kite with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #22
Source File: ayab_control.py    From ayab-desktop with GNU General Public License v3.0 4 votes vote down vote up
def cleanup_ui(self, parent_ui):
    """Cleans up UI elements inside knitting option dock."""
    #dock = parent_ui.knitting_options_dock
    dock = self.dock
    cleaner = QtCore.QObjectCleanupHandler()
    cleaner.add(dock.widget())
    self.__qw = QtGui.QWidget()
    dock.setWidget(self.__qw)
    self.unset_translator() 
Example #23
Source File: utilities.py    From raster-vision-qgis with GNU General Public License v3.0 4 votes vote down vote up
def get_qgis_app():
    """ Start one QGIS application to test against.

    :returns: Handle to QGIS app, canvas, iface and parent. If there are any
        errors the tuple members will be returned as None.
    :rtype: (QgsApplication, CANVAS, IFACE, PARENT)

    If QGIS is already running the handle to that app will be returned.
    """

    try:
        from PyQt5 import QtGui, QtCore
        from qgis.core import QgsApplication
        from qgis.gui import QgsMapCanvas
        from .qgis_interface import QgisInterface
    except ImportError:
        return None, None, None, None

    global QGIS_APP  # pylint: disable=W0603

    if QGIS_APP is None:
        gui_flag = True  # All test will run qgis in gui mode
        #noinspection PyPep8Naming
        QGIS_APP = QgsApplication(sys.argv, gui_flag)
        # Make sure QGIS_PREFIX_PATH is set in your env if needed!
        QGIS_APP.initQgis()
        s = QGIS_APP.showSettings()
        LOGGER.debug(s)

    global PARENT  # pylint: disable=W0603
    if PARENT is None:
        #noinspection PyPep8Naming
        PARENT = QtGui.QWidget()

    global CANVAS  # pylint: disable=W0603
    if CANVAS is None:
        #noinspection PyPep8Naming
        CANVAS = QgsMapCanvas(PARENT)
        CANVAS.resize(QtCore.QSize(400, 400))

    global IFACE  # pylint: disable=W0603
    if IFACE is None:
        # QgisInterface is a stub implementation of the QGIS plugin interface
        #noinspection PyPep8Naming
        IFACE = QgisInterface(CANVAS)

    return QGIS_APP, CANVAS, IFACE, PARENT 
Example #24
Source File: Viewer.py    From PyRAT with Mozilla Public License 2.0 4 votes vote down vote up
def makeView(self):
        # self.central = QtGui.QWidget()
        # self.HLayout = QtGui.QHBoxLayout(self.central)
        self.central = QtWidgets.QSplitter(self)
        self.central.setOpaqueResize(False)
        self.central.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)

        self.tree = LayerWidget(self)
        # self.tree.setFixedWidth(200)
        # self.tree.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding)
        self.central.addWidget(self.tree)

        # self.HLayout.addItem(self.spacer)

        self.frame = QtWidgets.QWidget()
        # self.frame = DelayedUpdater()

        self.frame.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        self.imageLabel = QtWidgets.QLabel(self.frame)
        self.imageLabel.setBackgroundRole(QtGui.QPalette.Base)
        self.imageLabel.setStyleSheet("QLabel { background-color: #333 }")
        self.imageLabel.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        self.imageLabel.setScaledContents(False)
        self.imageLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.imageLabel.resize(self.frame.width(), self.frame.height())
        self.central.addWidget(self.frame)

        self.setCentralWidget(self.central)

        self.resizeframeevent = self.frame.resizeEvent
        self.frame.resizeEvent = self.resizeFrameEvent  # a bit dirtyt to overload like this...

        # self.central.move.connect(lambda: self.splitterMoved())

        # self.frame = QtGui.QWidget()
        # self.imageLabel = QtGui.QLabel(self.frame)
        # self.imageLabel.setBackgroundRole(QtGui.QPalette.Base)
        # self.imageLabel.setStyleSheet("QLabel { background-color: #333 }")
        # self.imageLabel.setSizePolicy(QtGui.QSizePolicy.Ignored, QtGui.QSizePolicy.Ignored)
        # self.imageLabel.setScaledContents(False)
        # self.imageLabel.resize(self.frame.width(), self.frame.height())
        # self.setCentralWidget(self.frame)

    # def split(self, event):
    #     # QtGui.QWidget.resizeEvent(self.frame, event)
    #     # self.central.update()
    #     self.resizeEvent(event)
    #     # self.central.update()
    #     print("Event", self.frame.width(), self.frame.height()) 
Example #25
Source File: merge.py    From suite2p with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, parent=None):
        super(MergeWindow, self).__init__(parent)
        self.setGeometry(700,300,700,700)
        self.setWindowTitle('Choose merge options')
        self.cwidget = QtGui.QWidget(self)
        self.layout = QtGui.QGridLayout()
        self.layout.setVerticalSpacing(2)
        self.layout.setHorizontalSpacing(25)
        self.cwidget.setLayout(self.layout)
        self.win = pg.GraphicsLayoutWidget()
        self.layout.addWidget(self.win, 11, 0, 4, 4)
        self.p0 = self.win.addPlot(row=0, col=0)
        self.p0.setMouseEnabled(x=False,y=False)
        self.p0.enableAutoRange(x=True,y=True)
        # initial ops values
        mkeys = ['corr_thres', 'dist_thres']
        mlabels = ['correlation threshold', 'euclidean distance threshold']
        self.ops = {'corr_thres': 0.8, 'dist_thres': 100.0}
        self.layout.addWidget(QtGui.QLabel('Press enter in a text box to update params'), 0, 0, 1,2)
        self.layout.addWidget(QtGui.QLabel('(Correlations use "activity mode" and "bin" from main GUI)'), 1, 0, 1,2)
        self.layout.addWidget(QtGui.QLabel('>>>>>>>>>>>> Parameters <<<<<<<<<<<'), 2, 0, 1,2)
        self.doMerge = QtGui.QPushButton('merge selected ROIs', default=False, autoDefault=False)
        self.doMerge.clicked.connect(lambda: self.do_merge(parent))
        self.doMerge.setEnabled(False)
        self.layout.addWidget(self.doMerge, 9,0,1,1)

        self.suggestMerge = QtGui.QPushButton('next merge suggestion', default=False, autoDefault=False)
        self.suggestMerge.clicked.connect(lambda: self.suggest_merge(parent))
        self.suggestMerge.setEnabled(False)
        self.layout.addWidget(self.suggestMerge, 10,0,1,1)

        self.nMerge = QtGui.QLabel('= X possible merges found with these parameters')
        self.layout.addWidget(self.nMerge, 7,0,1,2)

        self.iMerge = QtGui.QLabel('suggested ROIs to merge: ')
        self.layout.addWidget(self.iMerge, 8,0,1,2)

        self.editlist = []
        self.keylist = []
        k=1
        for lkey,llabel in zip(mkeys, mlabels):
            qlabel = QtGui.QLabel(llabel)
            qlabel.setFont(QtGui.QFont("Times",weight=QtGui.QFont.Bold))
            self.layout.addWidget(qlabel, k*2+1,0,1,2)
            qedit = LineEdit(lkey,self)
            qedit.set_text(self.ops)
            qedit.setFixedWidth(90)
            qedit.returnPressed.connect(lambda: self.compute_merge_list(parent))
            self.layout.addWidget(qedit, k*2+2,0,1,2)
            self.editlist.append(qedit)
            self.keylist.append(lkey)
            k+=1

        print('creating merge window... this may take some time')
        self.CC  = np.matmul(parent.Fbin[parent.iscell], parent.Fbin[parent.iscell].T) / parent.Fbin.shape[-1]
        self.CC /= np.matmul(parent.Fstd[parent.iscell][:,np.newaxis],
                             parent.Fstd[parent.iscell][np.newaxis,:]) + 1e-3
        self.CC -= np.diag(np.diag(self.CC))

        self.compute_merge_list(parent) 
Example #26
Source File: UI_corriente.py    From pychemqt with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, parent=None):
        super(SolidDistribution, self).__init__(parent)
        self.setWindowTitle(QtWidgets.QApplication.translate(
            "pychemqt", "Generate solid distribution"))
        self.matriz = []

        layout = QtWidgets.QGridLayout(self)
        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Model")), 0, 0)
        self.modelo = QtWidgets.QComboBox()
        layout.addWidget(self.modelo, 0, 1)
        self.stacked = QtWidgets.QStackedWidget()
        self.modelo.currentIndexChanged.connect(self.stacked.setCurrentIndex)
        layout.addWidget(self.stacked, 1, 0, 1, 2)

        layout.addWidget(QtWidgets.QLabel(QtWidgets.QApplication.translate(
            "pychemqt", "Standards:")), 2, 0, 1, 1)
        self.standard = QtWidgets.QComboBox()
        self.standard.addItem("Tyler")
        self.standard.addItem("ASTM")
        self.standard.addItem("DIN")
        self.standard.addItem("BS")
        self.standard.addItem("AFNOR")
        self.standard.addItem("ISO")
        self.standard.addItem(QtWidgets.QApplication.translate("pychemqt", "Custom"))
        self.standard.currentIndexChanged[str].connect(self.standardCambiado)
        layout.addWidget(self.standard, 2, 1, 1, 1)

        self.diametros = QtWidgets.QLineEdit()
        layout.addWidget(self.diametros, 3, 1, 1, 2)

        layout.addItem(QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding,
                                         QtWidgets.QSizePolicy.Expanding), 4, 1, 1, 3)
        self.buttonBox = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Cancel |
                                                QtWidgets.QDialogButtonBox.Ok)
        self.buttonBox.rejected.connect(self.reject)
        self.buttonBox.accepted.connect(self.aceptar)
        layout.addWidget(self.buttonBox, 5, 0, 1, 2)

        self.entries = {}
        for key in ("Rosin Rammler Sperling", "Gates Gaudin Schumann",
                    "Broadbent Callcott", "Gaudin Meloy", "Lognormal", "Harris"):
            widget = QtWidgets.QWidget()
            self.modelo.addItem(key)
            lyt = QtWidgets.QGridLayout(widget)
            for i, label in enumerate(self.model[key]["title"]):
                lyt.addWidget(QtWidgets.QLabel(label), i, 1)
            self.entries[key] = []
            for i, unit in enumerate(self.model[key]["unit"]):
                entry = Entrada_con_unidades(unit, self.model[key]["magnitud"][i])
                self.entries[key].append(entry)
                lyt.addWidget(entry, i, 2)
            lyt.addItem(QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Expanding,
                                          QtWidgets.QSizePolicy.Expanding), i+1, 1)
            self.stacked.addWidget(widget)

        self.standardCambiado("Tyler") 
Example #27
Source File: qt_utils.py    From kite with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, parent=None):
        """Create a new QRangeSlider instance.

            :param parent: QWidget parent
            :return: New QRangeSlider instance.

        """
        super().__init__(parent)
        self.setupUi(self)
        self.setMouseTracking(False)

        # self._splitter.setChildrenCollapsible(False)
        self._splitter.splitterMoved.connect(self._handleMoveSplitter)

        # head layout
        self._head_layout = QtWidgets.QHBoxLayout()
        self._head_layout.setSpacing(0)
        # self._head_layout.setMargin(0)
        self._head.setLayout(self._head_layout)
        self.head = Head(self._head, main=self)
        self._head_layout.addWidget(self.head)

        # handle layout
        self._handle_layout = QtWidgets.QHBoxLayout()
        self._handle_layout.setSpacing(0)
        # self._handle_layout.setMargin(0)
        self._handle.setLayout(self._handle_layout)
        self.handle = Handle(self._handle, main=self)
        self.handle.setTextColor((150, 255, 150))
        self._handle_layout.addWidget(self.handle)

        # tail layout
        self._tail_layout = QtWidgets.QHBoxLayout()
        self._tail_layout.setSpacing(0)
        # self._tail_layout.setMargin(0)
        self._tail.setLayout(self._tail_layout)
        self.tail = Tail(self._tail, main=self)
        self._tail_layout.addWidget(self.tail)

        self._formatter = None

        # defaults
        self.setMin(0)
        self.setMax(99)
        self.setStart(0)
        self.setEnd(99)
        self.setDrawValues(True) 
Example #28
Source File: utilities.py    From Hqgis with GNU General Public License v3.0 4 votes vote down vote up
def get_qgis_app():
    """ Start one QGIS application to test against.

    :returns: Handle to QGIS app, canvas, iface and parent. If there are any
        errors the tuple members will be returned as None.
    :rtype: (QgsApplication, CANVAS, IFACE, PARENT)

    If QGIS is already running the handle to that app will be returned.
    """

    try:
        from PyQt5 import QtGui, QtCore
        from qgis.core import QgsApplication
        from qgis.gui import QgsMapCanvas
        from .qgis_interface import QgisInterface
    except ImportError:
        return None, None, None, None

    global QGIS_APP  # pylint: disable=W0603

    if QGIS_APP is None:
        gui_flag = True  # All test will run qgis in gui mode
        # noinspection PyPep8Naming
        QGIS_APP = QgsApplication(sys.argv, gui_flag)
        # Make sure QGIS_PREFIX_PATH is set in your env if needed!
        QGIS_APP.initQgis()
        s = QGIS_APP.showSettings()
        LOGGER.debug(s)

    global PARENT  # pylint: disable=W0603
    if PARENT is None:
        # noinspection PyPep8Naming
        PARENT = QtGui.QWidget()

    global CANVAS  # pylint: disable=W0603
    if CANVAS is None:
        # noinspection PyPep8Naming
        CANVAS = QgsMapCanvas(PARENT)
        CANVAS.resize(QtCore.QSize(400, 400))

    global IFACE  # pylint: disable=W0603
    if IFACE is None:
        # QgisInterface is a stub implementation of the QGIS plugin interface
        # noinspection PyPep8Naming
        IFACE = QgisInterface(CANVAS)

    return QGIS_APP, CANVAS, IFACE, PARENT