Skip to content

Instantly share code, notes, and snippets.

View eyllanesc's full-sized avatar
:octocat:
I may be slow to respond.

Edwin Yllanes eyllanesc

:octocat:
I may be slow to respond.
View GitHub Profile
@eyllanesc
eyllanesc / asyncprovider.py
Last active June 2, 2024 09:40
Examples of QtMultimedia in Qt6
import asyncio
from functools import cached_property, partial
from PyQt6.QtCore import (
pyqtSlot as Slot,
)
from utils import FrameProvider
import cv2
@eyllanesc
eyllanesc / main.py
Created August 4, 2021 17:32
PDF Viewer with QtWebEngine
import sys
from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets
def main():
print(
f"PyQt5 version: {QtCore.PYQT_VERSION_STR}, Qt version: {QtCore.QT_VERSION_STR}"
)
@eyllanesc
eyllanesc / main.py
Last active September 13, 2022 16:59
Load geojson that weigh more than 2MB in QtWebEngine
import os.path
from PyQt5.QtWidgets import QApplication, QVBoxLayout, QWidget
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWebEngineCore import QWebEngineUrlRequestInterceptor
import folium
from qfolium import FoliumApplication
@eyllanesc
eyllanesc / builder.py
Created October 19, 2019 21:41
Qt.py patch
def _patch():
import os
import sys
import importlib.util
module_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)), "QtSiteConfig.py"
)
spec = importlib.util.spec_from_file_location("QtSiteConfig", module_path)
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys
from math import sqrt
class LogObject(QObject):
hovered = pyqtSignal()
notHovered = pyqtSignal()
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="es">
<context>
<name>Form</name>
<message>
<location filename="main_ui.py" line="31"/>
<source>Form</source>
<translation>Formulario</translation>
</message>
<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script>L_PREFER_CANVAS=false; L_NO_TOUCH=false; L_DISABLE_3D=false;</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>
from PySide2 import QtCore, QtGui, QtWidgets
class InfoBox(QtWidgets.QGraphicsItem):
Type = QtWidgets.QGraphicsItem.UserType + 1
def __init__(self, parent=None):
super(InfoBox, self).__init__(parent)
self.setZValue(4)
proxy = QtWidgets.QGraphicsProxyWidget(self)
widget = QtWidgets.QLabel("TEST!")
from PyQt5 import QtCore, QtWidgets
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self._gv = QtWidgets.QGraphicsView()
self.setCentralWidget(self._gv)
self._gv.viewport().installEventFilter(self)
def eventFilter(self, obj, event):
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
def copy_widget(w):
if isinstance(w, QtWidgets.QWidget):
new_w = type(w)()
if isinstance(w, QtWidgets.QComboBox):
vals = [w.itemText(ix) for ix in range(w.count())]
new_w.addItems(vals)
return new_w