Beispiel #1
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.setWindowFlags(Qt.Window)

        self._mdi_area = QMdiArea()
        self._mdi_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self._mdi_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self.setCentralWidget(self._mdi_area)
        # set the size of mid_area and DocumentViewManager based on the
        # screen size.
        screen = QDesktopWidget().availableGeometry()
        self._mdi_area.resize(screen.width() - 30, screen.height() - 80)
        self.resize(self._mdi_area.size())
        self._mdi_area.subWindowActivated.connect(self.update_actions)
        self._viewer_mapper = QSignalMapper(self)
        self._viewer_mapper.mapped[QWidget].connect(self.set_active_sub_window)

        win_title = QApplication.translate("DocumentViewManager",
                                           "Document Viewer")
        self.setWindowTitle(win_title)
        self.setUnifiedTitleAndToolBarOnMac(True)
        self.statusBar().showMessage(
            QApplication.translate("DocumentViewManager", "Ready"))
        self._doc_viewers = {}

        self._create_menu_actions()
        self.update_actions()
Beispiel #2
0
    def __init__(self, main_plugin):
        # create GUI
        QMainWindow.__init__(self)
        self.plugin = main_plugin

        self.selected_date = None
        self.setWindowTitle('Calendar widget')
        # Set the window dimensions
        self.resize(400, 300)

        # vertical layout for widgets
        self.vbox = QVBoxLayout()
        self.setLayout(self.vbox)

        # Create a calendar widget and add it to our layout
        self.cal = QCalendarWidget()
        self.cal.setFirstDayOfWeek(Qt.Monday)

        self.vbox.addWidget(self.cal)
        qd = self.get_qdate()
        self.cal.setSelectedDate(QDate(*qd))

        # Create a label which we will use to show the date a week from now
        self.lbl = QLabel()
        self.vbox.addWidget(self.lbl)

        self.ok_box = QPushButton('Ok!')
        self.vbox.addWidget(self.ok_box)

        # Connect the clicked signal to the centre handler
        self.cal.selectionChanged.connect(self.date_changed)

        # Connect the clicked signal to the centre handler
        # self.ok_box.clicked.connect(self.ok_selected)
        self.ok_box.clicked.connect(self.ok_selected)
Beispiel #3
0
 def closeEvent(self, e):
     # save the window state
     settings = QSettings()
     settings.setValue("/rivergis/mainWindow/windowState", self.saveState())
     settings.setValue("/rivergis/mainWindow/geometry", self.saveGeometry())
     settings.setValue("/rivergis/mainWindow/flags", self.windowFlags())
     self.writeSettings()
     QMainWindow.closeEvent(self, e)
Beispiel #4
0
 def __init__(self, project):
     QMainWindow.__init__(self)
     self.setWindowTitle("QuteGIS")
     self.setWindowIcon(QIcon(Settings.iconfile))
     self.canvas = QuteCanvas(self, list(project.mapLayers().values()))
     self.setCentralWidget(self.canvas)
     self.toolbar = self.addToolBar("QuteTools")
     self.tools = qutetools.buildSet(self.canvas)
     self.buildToolbar()
Beispiel #5
0
 def closeEvent(self, event):
     """Activated anytime Mapwindow is closed either by buttons given or
         if the user finds some other way to close the window. 
         Deletes scrap maplayers."""
     try:
         QgsProject.instance().removeMapLayer(self.layer)
         QgsProject.instance().removeMapLayer(self.bg_layer)
     except Exception:
         pass
     QMainWindow.closeEvent(self, event)
Beispiel #6
0
 def closeEvent(self, event):
     """Activated anytime Mapwindow is closed either programmatically or
         if the user finds some other way to close the window. Automatically
         finishes the polygon if it's unconnected."""
     try:
         QgsProject.instance().removeMapLayer(self.bg_layer)
     except Exception:
         pass
     self.toolDraw.finishPolygon()
     QMainWindow.closeEvent(self, event)
Beispiel #7
0
    def closeEvent(self, e):
        self.unregisterAllActions()
        # clear preview, this will delete the layer in preview tab
        self.preview.loadPreview(None)

        # save the window state
        settings = QgsSettings()
        settings.setValue("/DB_Manager/mainWindow/windowState", self.saveState())
        settings.setValue("/DB_Manager/mainWindow/geometry", self.saveGeometry())

        QMainWindow.closeEvent(self, e)
Beispiel #8
0
    def closeEvent(self, e):
        self.unregisterAllActions()
        # clear preview, this will delete the layer in preview tab
        self.preview.loadPreview(None)

        # save the window state
        settings = QgsSettings()
        settings.setValue("/DB_Manager/mainWindow/windowState", self.saveState())
        settings.setValue("/DB_Manager/mainWindow/geometry", self.saveGeometry())

        QMainWindow.closeEvent(self, e)
Beispiel #9
0
    def __init__(self):
        QMainWindow.__init__(self)

        # creating map canvas, which draws the maplayers
        # setting up features like canvas color
        self.canvas = QgsMapCanvas()
        self.canvas.setMinimumSize(550, 700)
        self.canvas.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.canvas.setCanvasColor(Qt.white)
        self.canvas.enableAntiAliasing(True)

        # Qmainwindow requires a central widget. Canvas is placed
        self.setCentralWidget(self.canvas)

        # creating each desired action
        self.actionGet = QAction("Return polygon and close", self)
        self.actionPan = QAction("Pan tool", self)
        self.actionDraw = QAction("Polygon tool", self)
        self.actionConnect = QAction("Connect polygon", self)
        self.actionClear = QAction("Clear", self)
        self.actionCancel = QAction("Cancel and close", self)

        # these two function as on/off. the rest are clickable
        self.actionPan.setCheckable(True)
        self.actionDraw.setCheckable(True)

        # when actions are clicked, do corresponding function
        self.actionPan.triggered.connect(self.pan)
        self.actionDraw.triggered.connect(self.draw)
        self.actionClear.triggered.connect(self.clear)
        self.actionGet.triggered.connect(self.finishedSelection)
        self.actionConnect.triggered.connect(self.connect)
        self.actionCancel.triggered.connect(self.cancel)

        # toolbar at the top of the screen: houses actions as buttons
        # change order here to change their placement on toolbar
        self.toolbar = self.addToolBar("Canvas actions")
        self.toolbar.setContextMenuPolicy(Qt.PreventContextMenu)
        self.toolbar.setMovable(False)
        self.toolbar.addAction(self.actionGet)
        self.toolbar.addAction(self.actionPan)
        self.toolbar.addAction(self.actionDraw)
        self.toolbar.addAction(self.actionConnect)
        self.toolbar.addAction(self.actionClear)
        self.toolbar.addAction(self.actionCancel)

        # link actions to premade map tools
        self.toolPan = QgsMapToolPan(self.canvas)
        self.toolPan.setAction(self.actionPan)
        self.toolDraw = PolygonMapTool(self.canvas)
        self.toolDraw.setAction(self.actionDraw)

        # set draw tool by default
        self.draw()
Beispiel #10
0
 def closeEvent(self, event):
     """Activated anytime Mapwindow is closed either by buttons given or
         if the user finds some other way to close the window. Removes
         selection and deletes scrap maplayer."""
     self.selection_rectangle = self.layer.boundingBoxOfSelected()
     self.layer.removeSelection()
     QgsProject.instance().removeMapLayer(self.layer)
     try:
         QgsProject.instance().removeMapLayer(self.bg_layer)
     except Exception:
         pass
     self.blocks_flag = False
     QMainWindow.closeEvent(self, event)
Beispiel #11
0
    def closeEvent(self, event):

        # disable tracing
        sys.settrace(None)

        settings = QSettings()
        settings.setValue("/plugins/firstaid/debugger-geometry", self.saveGeometry())
        settings.setValue("/plugins/firstaid/debugger-windowstate", self.saveState())

        filenames = list(self.text_edits.keys())
        settings.setValue("/plugins/firstaid/debugger-files", filenames)

        QMainWindow.closeEvent(self, event)
Beispiel #12
0
    def __init__(self, iface, parent=None):
        QMainWindow.__init__(self, parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setupUi()
        self.iface = iface

        # restore the window state
        settings = QgsSettings()
        self.restoreGeometry(settings.value("/DB_Manager/mainWindow/geometry", QByteArray(), type=QByteArray))
        self.restoreState(settings.value("/DB_Manager/mainWindow/windowState", QByteArray(), type=QByteArray))

        self.tabs.currentChanged.connect(self.tabChanged)
        self.tree.selectedItemChanged.connect(self.itemChanged)
        self.itemChanged(None)
Beispiel #13
0
    def __init__(self, iface, parent=None):
        QMainWindow.__init__(self, parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setupUi()
        self.iface = iface

        # restore the window state
        settings = QgsSettings()
        self.restoreGeometry(settings.value("/DB_Manager/mainWindow/geometry", QByteArray(), type=QByteArray))
        self.restoreState(settings.value("/DB_Manager/mainWindow/windowState", QByteArray(), type=QByteArray))

        self.tabs.currentChanged.connect(self.tabChanged)
        self.tree.selectedItemChanged.connect(self.itemChanged)
        self.tree.model().dataChanged.connect(self.iface.reloadConnections)
        self.itemChanged(None)
Beispiel #14
0
def get_iface():
    """
    Will return a mock QgisInterface object with some methods implemented in a generic way.

    You can further control its behavior
    by using the mock infrastructure. Refer to https://docs.python.org/3/library/unittest.mock.html
    for more details.

        Returns
        -------
        QgisInterface

        A mock QgisInterface
    """

    start_app()

    my_iface = mock.Mock(spec=QgisInterface)

    my_iface.mainWindow.return_value = QMainWindow()

    canvas = QgsMapCanvas(my_iface.mainWindow())
    canvas.resize(QSize(400, 400))

    my_iface.mapCanvas.return_value = canvas

    return my_iface
Beispiel #15
0
    def __init__(self, iface, parent=None):
        QMainWindow.__init__(self, parent=parent)

        # build ui
        self.ui = Ui_Form()  #Appelle la fenêtre
        self.ui.setupUi(self)  #Construit l'interface
        self.setCentralWidget(self.ui.PS_Time_Viewer
                              )  #Définit la fenêtre principal de l'interface
        self.first_point = True

        # Set up the user interface from Designer.
        self.iface = iface
        self.canvas = iface.mapCanvas()  #Lie QGIS et la fenêtre

        # connect signals
        self.make_connection()  #Relie les boutons aux actions
Beispiel #16
0
def qgis_app():
    """Start a QGIS application and get the iface.
    Mostly inspired by
    https://github.com/qgis/QGIS/blob/release-2_18/python/testing/mocked.py
    The application is returned as first argument. The QgisInterface is
    returned as second argument.
    The parent can be accessed by iface.mainWindow()
    The canvas can be access by iface.mapCanvas()
    You can further control its behavior
    by using the mock infrastructure.
    Refer to https://docs.python.org/3/library/unittest.mock.html
    for more details.
    :return: The QGIS interface.
    :rtype: QgisInterface
    """
    from qgis.utils import iface
    if iface:
        # We are already in QGIS.
        # I don't know if I can get the current QApplication.
        # But I guess we shouldn't use it too much.
        return None, iface

    # We are not in QGIS, we need to start an app.
    application = start_app()

    my_iface = mock.Mock(spec=QgisInterface)
    my_iface.mainWindow.return_value = QMainWindow()

    canvas = QgsMapCanvas(my_iface.mainWindow())
    canvas.resize(QSize(400, 400))

    my_iface.mapCanvas.return_value = canvas

    return application, my_iface
Beispiel #17
0
    def __init__(self, iface, parent=None):
        QMainWindow.__init__(self, parent)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setupUi()
        self.iface = iface

        # restore the window state
        settings = QgsSettings()
        self.restoreGeometry(settings.value("/DB_Manager/mainWindow/geometry", QByteArray(), type=QByteArray))
        self.restoreState(settings.value("/DB_Manager/mainWindow/windowState", QByteArray(), type=QByteArray))

        self.toolBar.setIconSize(self.iface.iconSize())
        self.toolBarOrientation()
        self.toolBar.orientationChanged.connect(self.toolBarOrientation)
        self.tabs.currentChanged.connect(self.tabChanged)
        self.tree.selectedItemChanged.connect(self.itemChanged)
        self.tree.model().dataChanged.connect(self.iface.reloadConnections)
        self.itemChanged(None)
Beispiel #18
0
    def showEvent(self, event):
        """
        (Re)load map layers in the viewer and main canvas.
        :param event: Window event
        :type event: QShowEvent
        """
        self.setEnabled(True)
        if QTimer is not None:
            QTimer.singleShot(200, self.init_mirror_map)

        return QMainWindow.showEvent(self, event)
Beispiel #19
0
def make_iface_canvas():
    my_iface = mock.Mock(spec=QgisInterface)

    my_iface.mainWindow.return_value = QMainWindow()

    # canvas = QgsMapCanvas(my_iface.mainWindow())
    canvas = MyCanvas()
    canvas.setDestinationCrs(QgsCoordinateReferenceSystem(4326))
    canvas.setFrameStyle(0)
    canvas.resize(400, 400)
    my_iface.mapCanvas.return_value = canvas
    return my_iface
Beispiel #20
0
def make_iface_canvas(test_async):
    my_iface = mock.Mock(spec=QgisInterface)

    my_iface.mainWindow.return_value = QMainWindow()

    canvas = MyCanvas()
    canvas.setDestinationCrs(QgsCoordinateReferenceSystem(4326))
    canvas.setFrameStyle(0)
    canvas.resize(400, 400)
    canvas.closed.connect(test_async._stop_async)

    my_iface.mapCanvas.return_value = canvas
    return my_iface
Beispiel #21
0
    def __init__(self, layer, src, dst):
        QMainWindow.__init__(self)

        self.canvas = QgsMapCanvas()
        self.canvas.setCanvasColor(Qt.white)

        self.canvas.setExtent(layer.extent())
        self.canvas.setLayers([layer, src, dst, rlayer])

        self.setCentralWidget(self.canvas)

        self.actionZoomIn = QAction("Zoom in", self)
        self.actionZoomOut = QAction("Zoom out", self)
        self.actionPan = QAction("Pan", self)

        self.actionZoomIn.setCheckable(True)
        self.actionZoomOut.setCheckable(True)
        self.actionPan.setCheckable(True)

        self.actionZoomIn.triggered.connect(self.zoomIn)
        self.actionZoomOut.triggered.connect(self.zoomOut)
        self.actionPan.triggered.connect(self.pan)

        self.toolbar = self.addToolBar("Canvas actions")
        self.toolbar.addAction(self.actionZoomIn)
        self.toolbar.addAction(self.actionZoomOut)
        self.toolbar.addAction(self.actionPan)

        # create the map tools
        self.toolPan = QgsMapToolPan(self.canvas)
        self.toolPan.setAction(self.actionPan)
        self.toolZoomIn = QgsMapToolZoom(self.canvas, False)  # false = in
        self.toolZoomIn.setAction(self.actionZoomIn)
        self.toolZoomOut = QgsMapToolZoom(self.canvas, True)  # true = out
        self.toolZoomOut.setAction(self.actionZoomOut)

        self.pan()
Beispiel #22
0
    def __init__(self, url_base):
        QMainWindow.__init__(self)

        # creating map canvas, which draws the maplayers
        # setting up features like canvas color
        self.canvas = QgsMapCanvas()
        self.canvas.setMinimumSize(550, 700)
        self.canvas.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.canvas.setCanvasColor(Qt.white)
        #self.canvas.enableAntiAliasing(True)

        self.url_base = url_base

        # Qmainwindow requires a central widget. Canvas is placed
        self.setCentralWidget(self.canvas)
        """'tile widths' refer to the Map proxy WMTS server's settings for displaying
        data of different resolutions. If I understood correctly, these values 
        (got by examining properties of a layer from that server in QGIS) are
        the thresholds at which a different resolution is loaded on the GRIDI-FIN
        tileset. The values represent the tile size in map units (meters). 
        
        Each tile widths is tied to the corresponding resolution, which is used
        to get the correct resolution legend info. The method is only an estimation,
        but ought to produce good enough results for this purpose.
        Smallest resolutions (1, 2, 5) are omitted since only some layers 
        have them. """
        self.tile_widths = {
            2560: 10,
            5120: 20,
            12800: 50,
            25600: 100,
            51200: 200,
            128000: 500,
            256000: 1000
        }

        # get all keys i.e. widths
        self.all_widths = [i for i in self.tile_widths]

        # creating background layer box and housing it with the hardcoded options
        self.bg_layer_box = QComboBox()
        # if ortokuva ever updates to newer versions, just change the year here
        bg_layers = ['Taustakartta', 'Ortokuva_2018', 'No reference layer']

        # set 'No reference layer' as the default option
        self.bg_layer_box.addItems(layer for layer in bg_layers)
        self.bg_layer_box.setCurrentIndex(2)
        self.bg_layer_box.currentIndexChanged.connect(self.addBackgroundLayer)

        # initialize the slider that will control BG layer opacity/transparency
        self.opacity_slider = QSlider(Qt.Horizontal)
        self.opacity_slider.setMinimum(0)
        self.opacity_slider.setMaximum(100)
        self.opacity_slider.setSingleStep(1)
        self.opacity_slider.setMaximumWidth(100)
        self.opacity_slider.valueChanged.connect(self.setBackgroundMapOpacity)

        self.legend_checkbox = QCheckBox("Get attribute info on all layers")

        # explanatory texts for the different widgets are stored as label widgets
        bg_layer_label = QLabel(" Background: ")
        bg_opacity_label = QLabel(" BG opacity: ")
        data_label = QLabel("Data: ")
        spacing = QLabel(" ")

        # all of the data layers are housed in this combobox
        self.layer_box = QComboBox()
        self.layer_box.currentIndexChanged.connect(self.addLayer)

        # creating each desired action
        self.actionPan = QAction("Pan tool", self)
        self.actionLegend = QAction("Attribute info tool", self)
        self.actionCancel = QAction("Close window", self)
        self.actionZoom = QAction("Zoom to full extent", self)

        # these two work as on/off. the rest are clickable
        self.actionPan.setCheckable(True)
        self.actionLegend.setCheckable(True)

        # when actions are clicked, do corresponding function
        self.actionPan.triggered.connect(self.pan)
        self.actionLegend.triggered.connect(self.info)
        self.actionCancel.triggered.connect(self.cancel)
        self.actionZoom.triggered.connect(self.zoomToExtent)

        # defining two toolbars: first one houses layer and opacity selection
        # the other has all the tools and functions
        self.layers_toolbar = self.addToolBar("Select layers")
        self.layers_toolbar.setContextMenuPolicy(Qt.PreventContextMenu)
        self.layers_toolbar.setMovable(False)
        self.addToolBarBreak()
        self.tools_toolbar = self.addToolBar("Tools")
        self.tools_toolbar.setContextMenuPolicy(Qt.PreventContextMenu)
        self.tools_toolbar.setMovable(False)

        # change order here to change their placement on window
        # starting with the layer widgets and the corresponding label texts
        self.layers_toolbar.addWidget(data_label)
        self.layers_toolbar.addWidget(self.layer_box)
        self.layers_toolbar.addWidget(bg_layer_label)
        self.layers_toolbar.addWidget(self.bg_layer_box)
        self.layers_toolbar.addWidget(bg_opacity_label)
        self.layers_toolbar.addWidget(self.opacity_slider)
        self.layers_toolbar.addWidget(spacing)
        self.layers_toolbar.addWidget(self.legend_checkbox)

        # then setting all the canvas tools on the second toolbar
        self.tools_toolbar.addAction(self.actionLegend)
        self.tools_toolbar.addAction(self.actionPan)
        self.tools_toolbar.addAction(self.actionZoom)
        self.tools_toolbar.addAction(self.actionCancel)

        # a large text box that will house the legend info
        self.text_browser = QTextEdit("Legend will be shown here")
        self.text_browser.setReadOnly(True)

        # a dock widget is required for the text browser. Docked to main window
        dock_widget = QDockWidget()
        dock_widget.setFeatures(QDockWidget.NoDockWidgetFeatures)
        dock_widget.setWindowTitle("Legend")
        dock_widget.setWidget(self.text_browser)

        self.addDockWidget(Qt.RightDockWidgetArea, dock_widget)

        # link actions to premade map tools
        self.toolPan = QgsMapToolPan(self.canvas)
        self.toolPan.setAction(self.actionPan)

        self.toolClick = QgsMapToolEmitPoint(self.canvas)
        self.toolClick.canvasClicked.connect(self.getLegendInfo)

        # this is to ensure that the map isn't zoomed out everytime the layer changes
        self.first_start = True

        # this boolean is true while there is no active background layer
        # needed to ensure that e.g. opacity isn't attempted to be set on a nonexisting layer
        self.no_bg_layer_flag = True

        # set pantool as default
        self.pan()
Beispiel #23
0
# QDockWidget split position "jumps" when QMainWindow resized
#
# Comment:
#
# When I encountered this bug it seemed that anything which sets QDockAreaLayoutItem::KeepSize
# avoided the error. This includes things like undocking and re-docking widgets.
#
# My own terribly hacky workaround was thus:
#
#     QByteArray temp = saveState();
#     restoreState(temp);
#
# since restoreState sets the flag.
#

    win = QMainWindow()
    temp = win.saveState()  # Añadido para evitar bug

    canvas = QgsMapCanvas()
    
    project = QgsProject.instance()
    root = project.layerTreeRoot()
    bridge = QgsLayerTreeMapCanvasBridge(root, canvas)

    win.setCentralWidget(canvas)
    
    boton = QPushButton('Botón de prueba')
    dw = QDockWidget("Dock Widget de prueba ", win)
    dw.setWidget(boton)
    win.addDockWidget(Qt.LeftDockWidgetArea, dw)
    
Beispiel #24
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        self.setWindowTitle("First Aid - Debugger")

        self.text_edits = {}  # fully expanded path of the file -> associated SourceWidget
        self.toolbar = self.addToolBar("General")
        self.toolbar.setObjectName("ToolbarGeneral")

        self.tab_widget = QTabWidget()
        self.tab_widget.setTabsClosable(True)
        self.tab_widget.tabCloseRequested.connect(self.on_tab_close_requested)
        self.tab_widget.currentChanged.connect(self.on_pos_changed)

        self.setCentralWidget(self.tab_widget)

        _icon = lambda x: QIcon(os.path.join(os.path.dirname(__file__), "icons", x + ".svg"))

        self.action_load = self.toolbar.addAction(_icon("folder-outline"), "Load Python file (Ctrl+O)", self.on_load)
        self.action_load.setShortcut("Ctrl+O")
        self.action_run = self.toolbar.addAction(_icon("run"), "Run Python file (Ctrl+R)", self.on_run)
        self.action_run.setShortcut("Ctrl+R")
        self.action_bp = self.toolbar.addAction(_icon("record"), "Toggle breakpoint (F9)", self.on_toggle_breakpoint)
        self.action_bp.setShortcut("F9")
        self.toolbar.addSeparator()
        self.action_continue = self.toolbar.addAction(_icon("play"), "Continue (F5)", self.on_continue)
        self.action_continue.setShortcut("F5")
        self.action_step_into = self.toolbar.addAction(_icon("debug-step-into"), "Step into (F11)", self.on_step_into)
        self.action_step_into.setShortcut("F11")
        self.action_step_over = self.toolbar.addAction(_icon("debug-step-over"), "Step over (F10)", self.on_step_over)
        self.action_step_over.setShortcut("F10")
        self.action_step_out = self.toolbar.addAction(_icon("debug-step-out"), "Step out (Shift+F11)", self.on_step_out)
        self.action_step_out.setShortcut("Shift+F11")
        self.action_run_to_cursor = self.toolbar.addAction(_icon("cursor-default-outline"), "Run to cursor (Ctrl+F10)",
                                                           self.on_run_to_cursor)
        self.action_run_to_cursor.setShortcut("Ctrl+F10")

        self.vars_view = VariablesView()
        self.frames_view = FramesView()

        self.dock_frames = QDockWidget("Frames", self)
        self.dock_frames.setObjectName("DockFrames")
        self.dock_frames.setWidget(self.frames_view)
        self.addDockWidget(Qt.BottomDockWidgetArea, self.dock_frames)

        self.dock_vars = QDockWidget("Variables", self)
        self.dock_vars.setObjectName("DockVariables")
        self.dock_vars.setWidget(self.vars_view)
        self.addDockWidget(Qt.BottomDockWidgetArea, self.dock_vars)

        self.resize(800, 800)

        self.debugger = Debugger(self)

        self.update_buttons()

        settings = QSettings()
        self.restoreGeometry(settings.value("/plugins/firstaid/debugger-geometry", b''))
        self.restoreState(settings.value("/plugins/firstaid/debugger-windowstate", b''))

        filenames = settings.value("/plugins/firstaid/debugger-files", [])
        if filenames is None:
            filenames = []

        # load files from previous session
        for filename in filenames:
            self.load_file(filename)

        if self.tab_widget.count() > 1:
            self.tab_widget.setCurrentIndex(0)

        # start tracing
        self.start_tracing()
def qgis_app(request):
    """
    Creates a QGIS application, a QGIS Interface, a QGIS Settings and a set of loaded plugins. The fixture can be
    parametrized with the following options:
    - plugin_names: Plugin names to load
    - plugin_paths: Directories where the plugins are located
    - locale: Language code with the translation that the plugin has to be loaded

    :param request: Fixture request. It contains the indirect parameters for fixture setup
    :type request: FixtureRequest
    :return: The QGIS application objects
    :rtype: (QgsApplication, QgisInterface, QgsSettings, (list of object) or None)
    """
    # Collect parameters
    plugin_names = request.param[
        'plugin_names'] if 'plugin_names' in request.param else None
    plugin_paths = request.param['plugin_paths'] if 'plugin_paths' in request.param \
        else [str(Path(__file__).parent.parent.parent) + '/src']
    locale = request.param['locale'] if 'locale' in request.param else 'EN'
    # Create a QGIS Application
    # noinspection PyTypeChecker
    QgsApplication.setPrefixPath('/usr', True)
    qgs = QgsApplication([], True)
    qgs.initQgis()
    # Mock the QGIS Interface
    iface = unittest.mock.Mock(spec=QgisInterface)
    main_window = QMainWindow()
    iface.mainWindow.return_value = main_window
    canvas = QgsMapCanvas(main_window)
    canvas.resize(QSize(400, 400))
    iface.mapCanvas.return_value = canvas
    # Create the settings
    global_settings = QSettings()
    global_settings.setValue('locale/userLocale', locale)
    qgs_settings = QgsSettings()
    qgs_settings_file = qgs_settings.fileName()
    menu = QMenuBar()
    main_window.setMenuBar(menu)
    qgis.utils.iface = iface
    for plugin_path in plugin_paths:
        sys.path.insert(0, plugin_path)
        qgis.utils.plugin_paths.append(plugin_path)
    qgis.utils.updateAvailablePlugins()
    if plugin_names is not None:
        plugins = list()
        if isinstance(plugin_names, str):
            plugin_names = [plugin_names]
        for plugin_name in plugin_names:
            assert qgis.utils.loadPlugin(plugin_name)
            assert qgis.utils.startPlugin(plugin_name)
            plugins.append(qgis.utils.plugins[plugin_name])
        yield qgs, iface, qgs_settings, plugins
        for plugin_name in plugin_names:
            qgis.utils.unloadPlugin(plugin_name)
            del qgis.utils.plugin_times[plugin_name]
        if plugin_paths is not None:
            for plugin_path in plugin_paths:
                sys.path.remove(plugin_path)
                qgis.utils.plugin_paths.remove(plugin_path)
        qgis.utils.updateAvailablePlugins()
    else:
        yield qgs, iface, qgs_settings, None

    os.remove(qgs_settings_file)
    del qgs
Beispiel #26
0
    def __init__(self, iface):
        QMainWindow.__init__(self)
        self.resize(600, 600)
        self.layer = None
        self.iface = iface
        self.dstpoints = []
        self.srcpoints = []
        self.filename = None
        self.cursrc = None
        self.curdst = None
        self.xform_m2r = None
        self.xform_r2m = None

        self.canvas = QgsMapCanvas(self)
        #self.canvas.setCachingEnabled(True)
        self.canvas.setCanvasColor(Qt.white)
        self.canvas.setWheelAction(QgsMapCanvas.WheelZoomToMouseCursor)

        self.setCentralWidget(self.canvas)

        def t(name):
            return QgsApplication.getThemeIcon('/' + name)
        actionZoomIn = QAction(t('mActionZoomIn.svg'), "Zoom in", self)
        actionZoomOut = QAction(t('mActionZoomOut.svg'), "Zoom out", self)
        actionZoomToLayer = QAction(t('mActionZoomToLayer.svg'), "Zoom To Layer", self)
        actionZoomToDest = QAction("Zoom To Map", self)
        actionPan = QAction(t('mActionPan.svg'), "Pan", self)
        actionOpen = QAction(t('mActionFileOpen.svg'), "Open", self)
        actionSave = QAction(t('mActionFileSaveAs.svg'), "Save", self)
        actionAdd = QAction("Add GCP", self)
        actionDeleteAll = QAction("Delete All GCPs", self)

        actionZoomIn.setCheckable(True)
        actionZoomOut.setCheckable(True)
        actionPan.setCheckable(True)
        actionAdd.setCheckable(True)

        actionZoomIn.triggered.connect(self.zoomIn)
        actionZoomOut.triggered.connect(self.zoomOut)
        actionZoomToLayer.triggered.connect(self.zoomToLayer)
        actionZoomToDest.triggered.connect(self.zoomToDest)
        actionPan.triggered.connect(self.pan)
        actionOpen.triggered.connect(self.showOpen)
        actionSave.triggered.connect(self.savePoints)
        actionAdd.triggered.connect(self.addGcp)
        actionDeleteAll.triggered.connect(self.deleteAll)

        self.toolbar = self.addToolBar("Canvas actions")
        self.toolbar.addAction(actionOpen)
        self.toolbar.addAction(actionSave)
        self.toolbar.addSeparator()
        self.toolbar.addAction(actionPan)
        self.toolbar.addAction(actionZoomIn)
        self.toolbar.addAction(actionZoomOut)
        self.toolbar.addAction(actionZoomToLayer)
        self.toolbar.addAction(actionZoomToDest)
        self.toolbar.addSeparator()
        self.toolbar.addAction(actionAdd)
        self.toolbar.addSeparator()
        self.toolbar.addAction(actionDeleteAll)

        self.toolPan = QgsMapToolPan(self.canvas)
        self.toolPan.setAction(actionPan)
        self.toolZoomIn = QgsMapToolZoom(self.canvas, False)
        self.toolZoomIn.setAction(actionZoomIn)
        self.toolZoomOut = QgsMapToolZoom(self.canvas, True)
        self.toolZoomOut.setAction(actionZoomOut)
        self.toolSrcAdd = CaptureTool(self.canvas, self.iface.cadDockWidget())
        self.toolSrcAdd.pointSelected.connect(self.addSrcPoint)
        self.toolSrcAdd.pointDeleted.connect(self.delSrcPoint)
        self.toolDestAdd = CaptureTool(self.iface.mapCanvas(), self.iface.cadDockWidget())
        self.toolDestAdd.pointSelected.connect(self.addDestPoint)
        self.toolDestAdd.pointDeleted.connect(self.delDestPoint)
        #self.toolDestAdd.setAction(actionAdd)

        self.pan()

        self.overview = QgsMapOverviewCanvas(None, self.canvas)
        self.overview_dock = QDockWidget("Overview")
        self.overview_dock.setWidget(self.overview)
        self.addDockWidget(Qt.BottomDockWidgetArea, self.overview_dock)
        self.canvas.enableOverviewMode(self.overview)

        statusbar = self.statusBar()
        self.coordslabel = QLabel(statusbar)
        self.canvas.xyCoordinates.connect(self.showMouseCoordinates)
        statusbar.addPermanentWidget(self.coordslabel)
Beispiel #27
0
    def __init__(self, iface, parent=None):
        QMainWindow.__init__(self, parent)
        if QApplication.overrideCursor():
            QApplication.restoreOverrideCursor()
        self.setAttribute(Qt.WA_DeleteOnClose)
        tdir = os.path.dirname(os.path.realpath(__file__))
        uif = os.path.join(tdir, "ui", "ui_rivergis.ui")
        self.ui = uic.loadUi(uif, self)
        self.conn = None
        self.curConnName = None
        self.schema = None
        self.passwd = None
        self.rdb = None
        self.iface = iface
        # self.mapRegistry = QgsMapLayerRegistry.instance()
        self.rivergisPath = os.path.dirname(__file__)
        self.dtms = []
        # restore settings
        self.readSettings()
        self.menus = self.ui.menubar.findChildren(QMenu)
        self.toolbars = self.findChildren(QToolBar)

        # MENU Actions

        # DB
        self.ui.actionRefreshConnections.triggered.connect(self.connChanged)
        self.ui.actionCreateNewSchema.triggered.connect(self.dbCreateSchema)
        self.ui.actionDeleteSchema.triggered.connect(self.dbDeleteSchema)
        self.ui.actionRASCreateRdbTables.triggered.connect(self.rasCreateRdbTables)
        self.ui.actionRASLoadRdbTablesIntoQGIS.triggered.connect(self.rasLoadRdbTablesIntoQGIS)
        self.ui.actionRASImportLayersIntoRdbTables.triggered.connect(self.rasImportLayersIntoRdbTables)
        # Settings
        self.ui.actionOptions.triggered.connect(self.options)
        self.ui.actionRestoreDefaultOptions.triggered.connect(lambda: self.readSettings(defaults=True))
        # RAS Geometry
        # 1D
        self.ui.actionRASTopology1D.triggered.connect(lambda: r1d.ras1dStreamCenterlineTopology(self))
        self.ui.actionRASLengthsStations.triggered.connect(lambda: r1d.ras1dStreamCenterlineLengthsStations(self))
        self.ui.actionCopyStreamCenterlines2Flowpaths.triggered.connect(lambda: r1d.ras1dStreamCenterlines2Flowpaths(self))
        self.ui.actionRASStreamCenterlineAll.triggered.connect(lambda: r1d.ras1dStreamCenterlineAll(self))
        self.ui.actionRASXSRiverReachNames.triggered.connect(lambda: r1d.ras1dXSRiverReachNames(self))
        self.ui.actionRASXSStationing.triggered.connect(lambda: r1d.ras1dXSStationing(self))
        self.ui.actionRASXSBankStations.triggered.connect(lambda: r1d.ras1dXSBankStations(self))
        self.ui.actionRASXSDownstreamReachLengths.triggered.connect(lambda: r1d.ras1dXSDownstreamLengths(self))
        self.ui.actionRASXSElevations.triggered.connect(lambda: r1d.ras1dXSElevations(self))
        self.ui.actionRASXSAll.triggered.connect(lambda: r1d.ras1dXSAll(self))
        self.ui.actionRASHealLanduseGeometries.triggered.connect(lambda: r1d.ras1dHealLanduseGeoms(self))
        self.ui.actionRASManningsNValues.triggered.connect(lambda: r1d.ras1dXSExtractMannings(self))
        self.ui.actionRASLevees.triggered.connect(lambda: r1d.ras1dLevees(self))
        self.ui.actionRASIneffectiveFlowAreas.triggered.connect(lambda: r1d.ras1dIneffective(self))
        self.ui.actionRASBlockedObstructions.triggered.connect(lambda: r1d.ras1dObstructions(self))
        self.ui.actionRASXSUpdateInsertMeasuredPoints.triggered.connect(lambda: r1d.ras1dXSUpdateInsertMeasuredPts(self))
        self.ui.actionRASBRRiverReachNames.triggered.connect(lambda: r1d.ras1dBRRiverReachNames(self))
        self.ui.actionRASBRStationing.triggered.connect(lambda: r1d.ras1dBRStationing(self))
        self.ui.actionRASBRElevations.triggered.connect(lambda: r1d.ras1dBRElevations(self))
        self.ui.actionRASBRAll.triggered.connect(lambda: r1d.ras1dRASBRAll(self))
        self.ui.actionRASInlRiverReachNames.triggered.connect(lambda: r1d.ras1dISRiverReachNames(self))
        self.ui.actionRASInlStationing.triggered.connect(lambda: r1d.ras1dISStationing(self))
        self.ui.actionRASInlElevations.triggered.connect(lambda: r1d.ras1dISElevations(self))
        self.ui.actionRASInlAll.triggered.connect(lambda: r1d.ras1dISAll(self))
        self.ui.actionRASLatRiverReachNames.triggered.connect(lambda: r1d.ras1dLatRiverReachNames(self))
        self.ui.actionRASLatStationing.triggered.connect(lambda: r1d.ras1dLatStationing(self))
        self.ui.actionRASLatElevations.triggered.connect(lambda: r1d.ras1dLatElevations(self))
        self.ui.actionRASLatAll.triggered.connect(lambda: r1d.ras1dLatAll(self))
        self.ui.actionRASSAElevationVolumeData.triggered.connect(lambda: r1d.ras1dSAVolumeData(self))
        self.ui.actionRASSATerrainPointExtraction.triggered.connect(lambda: r1d.ras1dSAElevations(self))
        self.ui.actionRASSAAll.triggered.connect(lambda: r1d.ras1dSAAll(self))
        self.ui.actionRASSacAssignNearestSA.triggered.connect(lambda: r1d.ras1dSACAssignNearestSA(self))
        self.ui.actionRASSacElevations.triggered.connect(lambda: r1d.ras1dSACElevations(self))
        self.ui.actionRASSacAll.triggered.connect(lambda: r1d.ras1dSACAll(self))
        self.ui.actionRASCreateRASGISImport.triggered.connect(lambda: r1d.ras1dCreateRasGisImportFile(self))
        # 2D
        self.ui.actionRASCreate2dAreaPoints.triggered.connect(lambda: r2d.ras2dCreate2dPoints(self))
        self.ui.actionRASPreview2DMesh.triggered.connect(lambda: r2d.ras2dPreviewMesh(self))
        self.ui.actionRASSave2DPointsToHECRASGeometry.triggered.connect(lambda: r2d.ras2dSaveMeshPtsToGeometry(self))
        # HELP
        self.ui.actionHelpContents.triggered.connect(self.showRGisHelp)
        self.ui.actionWebsite.triggered.connect(self.showWebsite)
        self.ui.actionAbout.triggered.connect(self.about)
        # combos
        self.ui.crsWidget.crsChanged.connect(self.updateDefaultCrs)
        self.ui.connsCbo.activated.connect(self.connChanged)
        self.ui.schemasCbo.activated.connect(self.schemaChanged)

        # Welcome message
        self.ui.textEdit.append('<b>Welcome to RiverGIS!</b><br><br>Start building your model with 3 simple steps:<br>1. <b>Choose a connection</b> to PostGIS database<br>2. choose or create database <b>schema</b> (schema = model container or folder)<br>3. select a <b>projection</b> for the river database objects (projection = Coordinate Reference System, CRS).')
        self.ui.textEdit.append('<br>If you can\'t see any connection, please, create a new one from menu Layer > Add layer > Add PostGIS layers... <br>')
        self.ui.textEdit.append('----------------------------------------------------------------------------')

        # restore the window state
        s = QSettings()
        self.restoreGeometry(s.value("/rivergis/mainWindow/geometry", QByteArray(), type=QByteArray))
        self.restoreState(s.value("/rivergis/mainWindow/windowState", QByteArray(), type=QByteArray))

        # get PostGIS connections details and populate connections' combo
        self.connChanged()

        # restore settings
        self.readSettings()

        # set QGIS projection CRS as a default for RiverGIS
        self.ui.crsWidget.setCrs(self.iface.mapCanvas().mapSettings().destinationCrs())
        self.updateDefaultCrs()

        # check if we should connect to previously used RDB
        if self.open_last_conn:
            try:
                self.connChanged(conn_name=self.opts['rdb']['last_conn'],
                             schema_name=self.opts['rdb']['last_schema'])
            except:
                pass

        # disable some actions until a connection to river database is established
        if not self.rdb:
            self.disableActions()
Beispiel #28
0
    def __init__(self, plugin):
        QMainWindow.__init__(self, plugin.iface.mainWindow())
        self.setupUi(self)

        self.btnSearch.setIcon(GuiUtils.get_icon('search.png'))
        self.btnClearSearch.setIcon(GuiUtils.get_icon('reset.png'))

        self._plugin = plugin

        self.search_done = False
        # self.tbPropertyPreview.set_iface(self._plugin.iface)
        QTimer.singleShot(
            100, lambda: self.tbPropertyPreview.set_iface(self._plugin.iface))

        self.curr_profile = current_profile()

        self.spatial_units = self.curr_profile.social_tenure.spatial_units
        # Center me
        self.move(QDesktopWidget().availableGeometry().center() -
                  self.frameGeometry().center())
        self.sp_unit_manager = SpatialUnitManagerDockWidget(
            self._plugin.iface, self._plugin)
        self.geom_cols = []
        for spatial_unit in self.spatial_units:
            each_geom_col = self.sp_unit_manager.geom_columns(spatial_unit)
            self.geom_cols.extend(each_geom_col)

        # Configure notification bar
        self._notif_search_config = NotificationBar(self.vl_notification)

        # set whether currently logged in user has
        # permissions to edit existing STR records
        self._can_edit = self._plugin.STRCntGroup.canUpdate()
        self._can_delete = self._plugin.STRCntGroup.canDelete()
        self._can_create = self._plugin.STRCntGroup.canCreate()
        # Variable used to store a reference to the
        # currently selected social tenure relationship
        # when displaying documents in the supporting documents tab window.
        # This ensures that there are no duplicates
        # when the same item is selected over and over again.

        self._strID = None
        self.removed_docs = None
        # Used to store the root hash of the currently selected node.
        self._curr_rootnode_hash = ""

        self.str_model, self.str_doc_model = entity_model(
            self.curr_profile.social_tenure, False, True)

        self._source_doc_manager = SourceDocumentManager(
            self.curr_profile.social_tenure.supporting_doc, self.str_doc_model,
            self)

        self._source_doc_manager.documentRemoved.connect(
            self.onSourceDocumentRemoved)

        self._source_doc_manager.setEditPermissions(False)

        self.initGui()
        self.add_spatial_unit_layer()
        self.details_tree_view = DetailsTreeView(iface, self._plugin, self)
        # else:
        #     self.details_tree_view = self._plugin.details_tree_view
        self.details_tree_view.activate_feature_details(True)
        self.details_tree_view.add_tree_view()
        self.details_tree_view.model.clear()

        count = pg_table_count(self.curr_profile.social_tenure.name)
        self.setWindowTitle(
            self.tr('{}{}'.format(self.windowTitle(),
                                  '- ' + str(count) + ' rows')))

        self.active_spu_id = -1

        self.toolBox.setStyleSheet('''
            QToolBox::tab {
                background: qlineargradient(
                    x1: 0, y1: 0, x2: 0, y2: 1,
                    stop: 0 #EDEDED, stop: 0.4 #EDEDED,
                    stop: 0.5 #EDEDED, stop: 1.0 #D3D3D3
                );
                border-radius: 2px;
                border-style: outset;
                border-width: 2px;
                height: 100px;
                border-color: #C3C3C3;
            }

            QToolBox::tab:selected {
                font: italic;
            }
            ''')

        self.details_tree_view.view.setStyleSheet('''
            QTreeView:!active {
                selection-background-color: #72a6d9;
            }
            ''')
Beispiel #29
0
from qgis.core import *
from qgis.gui import *
from qgis.core.contextmanagers import qgisapp
from qgis.PyQt.QtCore import *
from qgis.PyQt.QtGui import *
from qgis.PyQt.QtWidgets import QMainWindow, QDockWidget, QPushButton

from moduls.QvLlegenda import QvLlegenda
from moduls.QvAtributs import QvAtributs
from moduls.QvCanvas import QvCanvas

projecteInicial = 'MapesOffline/qVista default map.qgs'

with qgisapp() as app:
    win = QMainWindow()

    # canvas = QvCanvas(llistaBotons=llistaBotons, posicioBotonera = 'SE', botoneraHoritzontal = True)
    canvas = QgsMapCanvas()
    win.setCentralWidget(canvas)
    project = QgsProject.instance()
    root = project.layerTreeRoot()
    bridge = QgsLayerTreeMapCanvasBridge(root, canvas)

    tablaAtributos = QvAtributs(canvas)
    # leyenda = QvLlegenda(canvas, tablaAtributos)
    boton = QPushButton('Botón de prueba')
    dw = QDockWidget("Dock Widget de prueba ", win)
    dw.setWidget(boton)
    win.addDockWidget(Qt.LeftDockWidgetArea, dw)
    win.show()
    project.read(projecteInicial)
Beispiel #30
0
    def __init__(self):
        QMainWindow.__init__(self)
        #self.setWindowFlags(Qt.CustomizeWindowHint)
        #self.setWindowFlags(Qt.WindowMinMaxButtonsHint)
        
        # creating map canvas, which draws the maplayers
        # setting up features like canvas color
        self.canvas = QgsMapCanvas()
        self.canvas.setMinimumSize(550, 700)
        self.canvas.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.canvas.setCanvasColor(Qt.white)
        self.canvas.setSelectionColor(QColor(255,255,26,200))
        self.canvas.enableAntiAliasing(True)
        self.canvas.setParallelRenderingEnabled(True)

        # empty list for selected polygons
        self.selected_features = []
        
        # setting up label settings: object below houses all of them
        self.label_settings = QgsPalLayerSettings()
        
        # object for text settings
        text_format = QgsTextFormat()
        
        text_format.setFont(QFont("Helvetica", 12))
        text_format.setSize(7)
        
        # setting up a white buffer around the labels
        buffer_settings = QgsTextBufferSettings()
        buffer_settings.setEnabled(True)
        buffer_settings.setSize(0.65)
        buffer_settings.setColor(Qt.white)
        text_format.setBuffer(buffer_settings)
        
        # label settings:
        # fieldName = which field is shown as the label (currently Finnish name)
        # placement = labels can be placed differently in relation to one another
        #              - see documentation for details
        self.label_settings.setFormat(text_format)
        self.label_settings.fieldName = "namefin"
        self.label_settings.placement = 0
        self.label_settings.enabled = True
        
        # Qmainwindow requires a central widget. Canvas is placed
        self.setCentralWidget(self.canvas)
        
        # creating each desired action
        self.actionGet = QAction("Return selected and close", self)
        self.actionPan = QAction("Pan tool", self)
        self.actionSelect = QAction("Select tool", self)
        self.actionClear = QAction("Clear selection", self)
        self.actionCancel = QAction("Cancel and close", self)
        
        # these two function as on/off. the rest are clickable
        self.actionPan.setCheckable(True)
        self.actionSelect.setCheckable(True)
        
        # when actions are clicked, do corresponding function
        self.actionPan.triggered.connect(self.pan)
        self.actionSelect.triggered.connect(self.select)
        self.actionClear.triggered.connect(self.clearSelection)
        self.actionGet.triggered.connect(self.finishedSelection)
        self.actionCancel.triggered.connect(self.cancel)
        
        # toolbar at the top of the screen: houses actions as buttons
        # change order here to change their placement on window
        self.toolbar = self.addToolBar("Canvas actions")
        self.toolbar.setContextMenuPolicy(Qt.PreventContextMenu)
        self.toolbar.setMovable(False)
        self.toolbar.addAction(self.actionGet)
        self.toolbar.addAction(self.actionPan)
        self.toolbar.addAction(self.actionSelect)
        self.toolbar.addAction(self.actionClear)
        self.toolbar.addAction(self.actionCancel)

        # link actions to premade map tools
        self.toolPan = QgsMapToolPan(self.canvas)
        self.toolPan.setAction(self.actionPan)
        self.toolSelect = QgsMapToolIdentifyFeature(self.canvas)
        self.toolSelect.setAction(self.actionSelect)
        self.toolSelect.featureIdentified.connect(self.selectFeature)
        
        self.blocks_flag = False
        
        self.selection_rectangle = False
        
        # set select tool as default
        self.select()
Beispiel #31
0
        bridge = QgsLayerTreeMapCanvasBridge(root, canvas)

        # llegim un projecte de demo
        project.read(projecteInicial)

        # Instanciem la classe QvUbicacions
        ubicacions = QvUbicacions(canvas)
        """
        Amb aquesta linia:
        ubicacions.show()
        es veuria el widget suelto, separat del canvas.

        Les següents línies mostren com integrar el widget 'ubicacions' com a dockWidget.
        """

        windowTest = QMainWindow()

        # Posem el canvas com a element central
        windowTest.setCentralWidget(canvas)

        # Creem un dockWdget i definim les característiques
        dwUbicacions = QDockWidget("Ubicacions", windowTest)
        dwUbicacions.setContextMenuPolicy(Qt.PreventContextMenu)
        dwUbicacions.setAllowedAreas(Qt.RightDockWidgetArea
                                     | Qt.LeftDockWidgetArea)
        dwUbicacions.setContentsMargins(1, 1, 1, 1)

        # Afegim el widget ubicacions al dockWidget
        dwUbicacions.setWidget(ubicacions)

        # Coloquem el dockWidget al costat esquerra de la finestra
Beispiel #32
0
            if checkbox_str in texts:
                checkbox.setChecked(True)

    def resetSelection(self):
        if self.mono:
            return super().setCurrentIndex(-1)
        for i in range(self.RESERVED_IDXS_COUNT, self.mlist.count()):
            checkbox = self.mlist.itemWidget(self.mlist.item(i))
            checkbox.setChecked(False)


if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)

    win = QMainWindow()
    wdg = QWidget()
    wdg.setLayout(QVBoxLayout())
    win.setCentralWidget(wdg)
    mscb = MultiSelectComboBox(wdg)
    mscb.addItem("ITA")
    mscb.addItem("FRA")
    mscb.addItem("GER")
    mscb.addItems(["Rlz_%2d" % rlz for rlz in range(1, 100)])
    mscbmono = MultiSelectComboBox(wdg, mono=True)
    mscbmono.addItems(mscb.get_unselected_items())
    wdg.layout().addWidget(mscb)
    wdg.layout().addWidget(mscbmono)
    win.show()
    app.exec_()