This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class mMapTool(QgsMapTool): | |
def __init__(self, mainLayer, canvas): | |
self.mlayer = mainLayer | |
self.canvas = canvas | |
QgsMapTool.__init__(self, self.canvas) | |
self.rubberBand = QgsRubberBand(self.canvas, Qgis.GeometryType.Polygon) | |
mFillColor = QColor(0, 0, 0, 88); | |
self.rubberBand.setColor(mFillColor) | |
# initialise a class attribute to store the offsets between the feature vertices and the mouse position |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Concurrent read-process-write example""" | |
import concurrent.futures | |
from itertools import islice | |
from time import sleep | |
import rasterio | |
CHUNK = 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
# ------------------------------------------------------------------------------- | |
# - | |
# Python dual-logging setup (console and log file), - | |
# supporting different log levels and colorized output - | |
# - | |
# Created by Fonic <https://github.com/fonic> - | |
# Date: 04/05/20 - 02/07/23 - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Pool | |
import time | |
from tqdm import tqdm | |
def _foo(my_number): | |
square = my_number * my_number | |
time.sleep(1) | |
return square |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from qgis.core import QgsApplication, QgsProject, QgsRasterLayer, QgsLayerTreeModel | |
from qgis.gui import QgsMapCanvas, QgsLayerTreeMapCanvasBridge, QgsLayerTreeView | |
from PyQt5.QtWidgets import QApplication, QMainWindow, QDockWidget | |
from PyQt5.QtCore import Qt | |
class myWindow(QMainWindow): | |
def __init__(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from qgis.core import QgsApplication, QgsProject, QgsRasterLayer | |
from qgis.gui import QgsMapCanvas, QgsLayerTreeMapCanvasBridge | |
from PyQt5.QtWidgets import QApplication, QMainWindow | |
class myWindow(QMainWindow): | |
def __init__(self, path, layer_name): | |
QMainWindow.__init__(self) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# refer to: https://www.pythonguis.com/faq/built-in-qicons-pyqt/ | |
import sys | |
from PyQt5.QtWidgets import QApplication, QGridLayout, QPushButton, QStyle, QWidget | |
class Window(QWidget): | |
def __init__(self): | |
super(Window, self).__init__() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# refer to: https://stackoverflow.com/a/52690011/1561540 | |
from PyQt5 import QtCore, QtWidgets | |
class Slider(QtWidgets.QSlider): | |
def mousePressEvent(self, event): | |
super(Slider, self).mousePressEvent(event) | |
if event.button() == QtCore.Qt.LeftButton: | |
val = self.pixelPosToRangeValue(event.pos()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt5.QtWidgets import QApplication, QTreeWidget, QTreeWidgetItem | |
# Subclass QMainWindow to customize your application's main window | |
class MainWindow(QMainWindow): | |
def __init__(self): | |
super().__init__() | |
data = {"Project A": ["file_a.py", "file_a.txt", "something.xls"], | |
"Project B": ["file_b.csv", "photo.jpg"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt5.QtGui import * | |
from PyQt5.QtWidgets import * | |
from PyQt5.QtCore import * | |
import time | |
import traceback, sys | |
class WorkerSignals(QObject): | |
''' |
NewerOlder