2018년 10월 26일 금요일

[QGIS3] 컨텍스트 메뉴 비활성화

iface.layerTreeView().setContextMenuPolicy(0)
iface.mainWindow().setContextMenuPolicy(0)

[QGIS3] SHP -> PostgreSQL

 l = iface.activeLayer()
type(l)
<class 'qgis._core.QgsVectorLayer'>

for _f in l.fields():
    type(l)

for _cnt, i in enumerate(l.getFeatures()):
    print(_cnt, i, i.gemetry())

g = QgsGeometry()
g.asWkb()

2018년 10월 25일 목요일

[PyQt5] QToolButton example

#!/usr/bin/env python# -*- coding:utf-8 -*-import sys

from PyQt5 import uic
from PyQt5.QtWidgets import QMainWindow, QApplication, QWidgetAction, QAction, QToolButton

FORM_CLASS, _ = uic.loadUiType('./ui/main.ui')


class MainForm(QMainWindow, FORM_CLASS):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setupUi(self)
        self.toolbar = self.addToolBar(u'툴바')

        self._ac1 = QAction(u'액숀1', self)
        self._ac1.triggered.connect(self._action_01)

        self._ac2 = QAction(u'액숀2', self)
        self._ac2.triggered.connect(self._action_02)

        self._tb1 = QToolButton(self)

        self._tb1.addAction(self._ac1)
        self._tb1.addAction(self._ac2)

        self._tb1.setPopupMode(QToolButton.InstantPopup)
        self._tb1.setDefaultAction(self._ac1)

        self.toolbar.addWidget(self._tb1)

    def _action_01(self):
        self._tb1.setDefaultAction(self._ac1)

    def _action_02(self):
        self._tb1.setDefaultAction(self._ac2)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = MainForm()
    w.show()
    sys.exit(app.exec())

2018년 10월 17일 수요일

[QGIS3] geom to geometry

g = QgsGeometry()
wkb = bytes.fromhex("010100000000000000000045400000000000001440")
g.fromWkb(wkb)
g.get().x()
42.0
g.get().y()
5.0

2018년 10월 16일 화요일

[QGIS3] 모든 레이어 조회

for _temp in QgsProject.instance().layerTreeRoot().children():
    _layer = _temp.layer()

[python] subprocess

proc.py import asyncio from argparse import ArgumentParser from asyncio import sleep async def process_function(user, file_path):     if use...