I found the icon of QPushButon is blurry when DPI scaling is enabled. Even if replaced by SVG, the icon is still blurred. Is there any way to make the icon clearer?
Here is the code:
# coding:utf-8
import os
import sys
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QPushButton, QWidget
class Demo(QWidget):
def __init__(self):
super().__init__(parent=None)
self.button = QPushButton(' Shuffle all', self)
imagePath = "app/resource/images/random_play_all/Shuffle_normal.png"
self.button.setIcon(QIcon(imagePath))
self.button.move(self.width()//2-self.button.width() //
2, self.height()//2-self.button.height()//2)
if __name__ == '__main__':
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"
os.environ["QT_SCALE_FACTOR"] = '1.25'
app = QApplication(sys.argv)
demo = Demo()
demo.show()
app.exec_()
The running result is shown in the figure below
I solved this problem by rewriting QIconEngine and setting Qt.AA_UseHighDpiPixmaps flag.
# coding:utf-8
import os
import sys
from PyQt5.QtCore import QPoint, QRect, QSize, Qt
from PyQt5.QtGui import QIcon, QIconEngine, QImage, QPainter, QPixmap
from PyQt5.QtWidgets import QApplication, QPushButton, QWidget
class PixmapIconEngine(QIconEngine):
""" Pixmap icon engine """
def __init__(self, iconPath: str):
self.iconPath = iconPath
super().__init__()
def paint(self, painter: QPainter, rect: QRect, mode: QIcon.Mode, state: QIcon.State):
painter.setRenderHints(QPainter.Antialiasing |
QPainter.SmoothPixmapTransform)
painter.drawImage(rect, QImage(self.iconPath))
def pixmap(self, size: QSize, mode: QIcon.Mode, state: QIcon.State) -> QPixmap:
pixmap = QPixmap(size)
pixmap.fill(Qt.transparent)
self.paint(QPainter(pixmap), QRect(QPoint(0, 0), size), mode, state)
return pixmap
class Icon(QIcon):
def __init__(self, iconPath: str):
self.iconPath = iconPath
super().__init__(PixmapIconEngine(iconPath))
class Demo(QWidget):
def __init__(self):
super().__init__(parent=None)
self.button = QPushButton(' Shuffle all', self)
imagePath = "resource/images/random_play_all/Shuffle_normal.png"
self.button.setIcon(Icon(imagePath))
self.button.move(self.width()//2-self.button.width() //
2, self.height()//2-self.button.height()//2)
if __name__ == '__main__':
os.environ["QT_ENABLE_HIGHDPI_SCALING"] = "0"
os.environ["QT_SCALE_FACTOR"] = '1.25'
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv)
demo = Demo()
demo.show()
app.exec_()
Here is the result
Related
Keep gif running while GUI starts. Is that possible? I have read many reporitys but none with the true and understandable answer.
I have prepared a code example that shows the problem.
import sys
from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget
from PyQt5 import QtWidgets
from PyQt5.QtGui import QMovie
from PyQt5.QtCore import QSize, QThread
class Main_Window(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setMinimumSize(QSize(500, 500))
self.setWindowTitle("Main Window")
centralWidget = QWidget(self)
self.setCentralWidget(centralWidget)
gridLayout = QGridLayout(self)
centralWidget.setLayout(gridLayout)
gif = QLabel(self)
gif.setGeometry(0,0,500,500)
self.movie = QMovie(r"C:\Users\...\Pictures\Icon_LOAD.gif")
gif.setMovie(self.movie)
self.movie.start()
# #Call event handler to process the queue, but it is shocking, dirty and unsuitable
#app.processEvents()
self.show()
for i in range(0,1000000):
print(i)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
MainWin = Main_Window()
sys.exit(app.exec_())
Now it works smooth
import sys
from PyQt5.QtWidgets import QMainWindow, QLabel, QGridLayout, QWidget
from PyQt5 import QtWidgets
from PyQt5.QtGui import QMovie
from PyQt5.QtCore import QSize
from threading import Thread
class Main_Window(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setMinimumSize(QSize(500, 500))
self.setWindowTitle("Main Window")
centralWidget = QWidget(self)
self.setCentralWidget(centralWidget)
gridLayout = QGridLayout(self)
centralWidget.setLayout(gridLayout)
gif = QLabel(self)
gif.setGeometry(0,0,500,500)
self.movie = QMovie(r"gif.gif")
gif.setMovie(self.movie)
self.movie.start()
self.show()
Thread(target=self.function_on_thread).start()
def function_on_thread(self):
for i in range(0,1000000):
print(i)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
MainWin = Main_Window()
sys.exit(app.exec_())
i would like to embed the glb file to pyqt gui with vtk python library. I wrote pieces of code but it does not embed the sketch to the pyqt gui. Everytime there have been placing in the second windows form. Here is the example:
And here is the my source code that i am trying to embed it to gui:
import sys
import vtk
try:
from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication
from PyQt5.QtWidgets import QWidget, QSizePolicy, QPushButton, QVBoxLayout, QFrame
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import Qt, pyqtSignal, QTimer, QObject, QSize, QEvent
except ImportError:
raise ImportError("Cannot load either PyQt5")
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
class Menu(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
importer = vtk.vtkGLTFImporter()
importer.SetFileName("uydu.glb")
importer.Read()
global vtk_render_window
vtk_renderer = importer.GetRenderer()
vtk_render_window = importer.GetRenderWindow()
self.setGeometry(190, 300, 300, 200)
self.setWindowTitle('Simple menu')
self.show()
self.frame = QFrame()
self.vl = QVBoxLayout()
vtk_render_window_interactor = QVTKRenderWindowInteractor(self.frame)
vtk_render_window_interactor.SetRenderWindow(vtk_render_window)
colors = vtk.vtkNamedColors()
vtk_renderer.SetBackground(colors.GetColor3d('White'))
actor = vtk.vtkActor()
actor.GetProperty().SetDiffuse(0.8)
actor.GetProperty().SetDiffuseColor(colors.GetColor3d('Black'))
actor.GetProperty().SetSpecular(0.3)
actor.GetProperty().SetSpecularPower(60.0)
vtk_render_window.SetSize(600, 600)
vtk_render_window.SetWindowName('3D Visualizer')
vtk_render_window_interactor.Initialize()
# Add callback for getting data from Arduino
#vtk_render_window_interactor.CreateRepeatingTimer(1000)
#vtk_render_window_interactor.AddObserver("TimerEvent", information_callback)
global vtk_actors
vtk_actors = vtk_renderer.GetActors
self.vl.addWidget(vtk_render_window_interactor)
self.renderer = vtk.vtkRenderer()
self.renderer.SetBackground(.3, .4, .5 )
self.renwin = vtk_render_window_interactor.GetRenderWindow()
self.renwin.AddRenderer(self.renderer)
# An interactor
self.inter = self.renwin.GetInteractor()
# add the custom style
self.style = MouseInteractorHighLightActor()
self.style.SetDefaultRenderer(self.renderer)
vtk_render_window_interactor.GetRenderWindow().AddRenderer(self.renderer)
#self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
self.inter.SetInteractorStyle(self.style)
#self.iren.SetInteractorStyle(self.inter)
#self.iren = self.vtkWidget.GetRenderWindow().SetInteractor(self.inter)
self.renderer.ResetCamera()
self.frame.setLayout(self.vl)
self.setCentralWidget(self.frame)
self.show()
self.inter.Initialize()
self.inter.Start()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Menu()
sys.exit(app.exec_())
You have to pass the renderWindow of vtkGLTFImporter as rw parameter to the QVTKRenderWindowInteractor widget:
import sys
import vtk
try:
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5.QtWidgets import QWidget, QVBoxLayout
except ImportError:
raise ImportError("Cannot load either PyQt5")
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
class Menu(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setGeometry(190, 300, 300, 200)
self.setWindowTitle("Simple menu")
self.container = QWidget()
vl = QVBoxLayout(self.container)
self.setCentralWidget(self.container)
self.resize(640, 480)
importer = vtk.vtkGLTFImporter()
importer.SetFileName("uydu.glb")
importer.Read()
renderer = importer.GetRenderer()
render_window = importer.GetRenderWindow()
vtk_widget = QVTKRenderWindowInteractor(rw=render_window)
vl.addWidget(vtk_widget)
vtk_widget.Initialize()
vtk_widget.Start()
colors = vtk.vtkNamedColors()
renderer.SetBackground(colors.GetColor3d("White"))
renderer.ResetCamera()
if __name__ == "__main__":
app = QApplication(sys.argv)
ex = Menu()
ex.show()
sys.exit(app.exec_())
I am trying to display an image from a URL in pyside6, but can't get anything to work.
def getIcon(data):
iconID = data['weather'][0]['icon']
icon = QPixmap("http://openweathermap.org/img/w/" + iconID + ".png");
return icon
And
self.temperatureIcon = QtWidgets.QLabel(self).setPixmap(getIcon(self.weatherData))
is the code I have.
QPixmap does not download the image from a url so you must download it for example using QNetworkAccessManager:
import sys
from functools import cached_property
from PySide6.QtCore import Signal, QObject, Qt, QUrl
from PySide6.QtGui import QImage, QPixmap
from PySide6.QtNetwork import QNetworkAccessManager, QNetworkReply, QNetworkRequest
from PySide6.QtWidgets import (
QApplication,
QGridLayout,
QLabel,
QLineEdit,
QPushButton,
QWidget,
)
class ImageDownloader(QObject):
finished = Signal(QImage)
def __init__(self, parent=None):
super().__init__(parent)
self.manager.finished.connect(self.handle_finished)
#cached_property
def manager(self):
return QNetworkAccessManager()
def start_download(self, url):
self.manager.get(QNetworkRequest(url))
def handle_finished(self, reply):
if reply.error() != QNetworkReply.NoError:
print("error: ", reply.errorString())
return
image = QImage()
image.loadFromData(reply.readAll())
self.finished.emit(image)
class Widget(QWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.lineedit = QLineEdit()
self.button = QPushButton("Start")
self.label = QLabel(alignment=Qt.AlignCenter)
lay = QGridLayout(self)
lay.addWidget(self.lineedit, 0, 0)
lay.addWidget(self.button, 0, 1)
lay.addWidget(self.label, 1, 0, 1, 2)
self.downloader = ImageDownloader()
self.downloader.finished.connect(self.handle_finished)
self.button.clicked.connect(self.handle_clicked)
self.lineedit.setText("http://openweathermap.org/img/wn/01d#2x.png")
self.resize(640, 480)
def handle_finished(self, image):
pixmap = QPixmap.fromImage(image)
self.label.setPixmap(pixmap)
def handle_clicked(self):
url = QUrl.fromUserInput(self.lineedit.text())
self.downloader.start_download(url)
def main():
app = QApplication(sys.argv)
w = Widget()
w.show()
sys.exit(app.exec())
if __name__ == "__main__":
main()
Here's another simple solution\example:
import sys
import requests
from PySide6.QtGui import QPixmap, QScreen
from PySide6.QtWidgets import QApplication, QWidget, QLabel
URL = 'https://upload.wikimedia.org/wikipedia/en/7/7d/Lenna_(test_image).png'
class App(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setWindowTitle('getAndSetImageFromURL()')
self.label = QLabel(self)
self.pixmap = QPixmap()
self.getAndSetImageFromURL(URL)
self.resize(self.pixmap.width(),self.pixmap.height())
screenSize = QScreen.availableGeometry(QApplication.primaryScreen())
frmX = (screenSize.width () - self.width ())/2
frmY = (screenSize.height() - self.height())/2
self.move(frmX, frmY)
self.show()
def getAndSetImageFromURL(self,imageURL):
request = requests.get(imageURL)
self.pixmap.loadFromData(request.content)
self.label.setPixmap(self.pixmap)
#QApplication.processEvents() # uncoment if executed on loop
if __name__ == '__main__':
app = QApplication(sys.argv)
gui = App()
sys.exit(app.exec())
which outputs:
import sys
import requests
import PySide6
from PySide6.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply
from PySide6.QtWidgets import QTableView, QWidget, QApplication, QGridLayout, QHeaderView
from PySide6.QtCore import Qt, QAbstractTableModel, QObject, Signal, QUrl
from PySide6.QtGui import QColor, QIcon, QPixmap, QImage
from datetime import datetime
class MagicIcon():
def __init__(self, link):
self.link = link
self.icon = QIcon()
try:
response = requests.get(self.link)
pixmap = QPixmap()
pixmap.loadFromData(response.content)
self.icon = QIcon(pixmap)
except:
pass
class MainWindow(QWidget):
def __init__():
super().__init__()
self.setWindowIcon(MagicIcon(
"https://img.icons8.com/external-flatarticons-blue-flatarticons/65/000000/external-analysis-digital-marketing-flatarticons-blue-flatarticons-1.png"
).icon)
if __name__ == "__main__":
app = QApplication(sys.argv)
wid = MainWindow()
wid.show()
sys.exit(app.exec())
Use requests module to fetch image and store them.
I have 2 QGraphicsView and one QWebEngineView widget on the form and I need to * (on the click of the button1)* make a screenshot of the content inside this QWebEngineView with some defined setback from the original QWebEngineView borders and save that screenshot as an image, and at the same time keep it as an object and paste this object to the first QGraphicsView and * (on the click of button2)* insert saved image into the second QGraphicsView.
Edit:
(I'd like to make a screenshot of the area inside the QtWebEngineWidgets and keep this area as an object. and a second problem I need to know how to paste this area in to the QGraphicsView in 2 different ways: (from the file) and display it as an object without saving. 2 QGraphicsView are just for the studying purpose it could be just one QGraphicsView and by hitting on button1 screenshot is making and pasting as an object to the QGraphicsView and by hitting on button2 -screenshot is making (saving as an png and loading to the QGraphicsView))
Here is the code I have:
import sys, os
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QBrush, QPen, QScreen, QPixmap
from PyQt5.QtWidgets import QApplication, QStyleFactory, QMainWindow, QWidget, QVBoxLayout, QLabel
from PyQt5.QtWidgets import QGraphicsScene, QGraphicsView, QGraphicsItem, QPushButton
from pyqtgraph.Qt import QtCore, QtGui
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import QApplication, QDialog
class Geometry(QGraphicsView):
def __init__(self):
QGraphicsView.__init__(self)
class CentralPanel(QWidget):
def __init__(self):
QWidget.__init__(self)
self.lblCoords = QLabel('MAP SELECTOR (object image): ')
self.lblCoords2 = QLabel('MAP SELECTOR (loaded from file image): ')
self.gvwShapes = Geometry()
self.gvwShapes2 = Geometry()
vbxDsply = QVBoxLayout()
vbxDsply.addWidget(self.lblCoords) # Capture coordinates of drawn line at window 1
vbxDsply.addWidget(self.gvwShapes) # add QGraphicsView #1
vbxDsply.addWidget(self.lblCoords2) # Capture coordinates of drawn line at window 2
vbxDsply.addWidget(self.gvwShapes2) # add QGraphicsView #2
self.webEngineView = QWebEngineView() # Add Google maps web window
self.webEngineView.load(QtCore.QUrl("https://www.google.com/maps/#36.797966,-97.1413048,3464a,35y,0.92h/data=!3m1!1e3"))
vbxDsply.addWidget(self.webEngineView)
self.Button1 = QPushButton('Do screenshot of webEngineView save it and paste it into QGraphicsView2', self) # Button to load image to graphics view
vbxDsply.addWidget(self.Button1)
self.Button1.clicked.connect(self.button_screenshot)
self.Button2 = QPushButton('Do screenshot of webEngineView and paste it into QGraphicsView1 ', self)
vbxDsply.addWidget(self.Button2)
self.Button2.clicked.connect(self.button_load_image)
self.setLayout(vbxDsply)
self.filename = "image.jpg"
def button_screenshot(self):
print('Screenshot is taken and saved as an image, Image loaded and inserted into the gvwShapes QGraphicsView1 ')
app = QApplication(sys.argv)
QScreen.grabWindow(app.primaryScreen(), QApplication.desktop().winId()).save(self.filename, 'png')
def button_load_image(self):
print('Screenshot is taken and inserted into the gvwShapes2 QGraphicsView2')
# pix = QPixmap()
# pix.load(self.filename)
# pix = QPixmap(self.filename)
# item = QGraphicsPixmapItem(pix)
# scene = QGraphicsScence(self)
# scene.addItem(item)
# self.graphicsView.setScene(scene)
scene = QtWidgets.QGraphicsScene(self)
pixmap = QPixmap(self.filename)
item = QtWidgets.QGraphicsPixmapItem(pixmap)
scene.addItem(item)
self.gvwShapes.setScene(scene)
# scene = self.gvwShapes
# self.image = QtGui.QPixmap(self.filename)
# self.gvwShapes.add
# scene.addItem(QtGui.QGraphicsPixmapItem(self.image))
# self.view = self.QGraphicsView
# self.view.setScene(self.image)
# self.view.show()
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.setGeometry(200, 50, 700, 900)
self.setWindowTitle('MAP Selector REV01')
self.setStyle(QStyleFactory.create('Cleanlooks'))
self.CenterPane = CentralPanel()
self.setCentralWidget(self.CenterPane)
# Catching exceptions and running a main loop
#
import traceback
def except_hook(exc_type, exc_value, exc_tb):
tb = "".join(traceback.format_exception(exc_type, exc_value, exc_tb))
print("error cached")
print("error message:\n", tb)
if __name__ == "__main__":
MainEventThred = QApplication([])
os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--enable-logging --log-level=3"
sys.excepthook = except_hook
MainApp = MainWindow()
MainApp.show()
MainEventThred.exec()
Crop image in QWebEngineView
If you want to implement the crop of the QWebEngineView screenshot then you must use a QRubberBand that is on the focusProxy () of the QWebEngineView (it is the widget where the web page is rendered and receives the mouse event that is created after displaying the view)
from functools import cached_property
import sys
from PyQt5.QtCore import pyqtSignal, QEvent, QObject, QPoint, QRect, QSize, QUrl
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication, QLabel, QRubberBand
from PyQt5.QtWebEngineWidgets import QWebEngineView
class RubberBandManager(QObject):
pixmap_changed = pyqtSignal(QPixmap, name="pixmapChanged")
def __init__(self, widget):
super().__init__(widget)
self._origin = QPoint()
self._widget = widget
self.widget.installEventFilter(self)
#property
def widget(self):
return self._widget
#cached_property
def rubberband(self):
return QRubberBand(QRubberBand.Rectangle, self.widget)
def eventFilter(self, source, event):
if self.widget is source:
if event.type() == QEvent.MouseButtonPress:
self._origin = event.pos()
self.rubberband.setGeometry(QRect(self._origin, QSize()))
self.rubberband.show()
elif event.type() == QEvent.MouseMove:
self.rubberband.setGeometry(
QRect(self._origin, event.pos()).normalized()
)
elif event.type() == QEvent.MouseButtonRelease:
rect = self.rubberband.geometry()
pixmap = self.widget.grab(rect)
self.pixmap_changed.emit(pixmap)
self.rubberband.hide()
return super().eventFilter(source, event)
if __name__ == "__main__":
app = QApplication(sys.argv)
view = QWebEngineView()
view.load(
QUrl(
"https://www.google.com/maps/#36.797966,-97.1413048,3464a,35y,0.92h/data=!3m1!1e3"
)
)
view.show()
rubberband_manager = RubberBandManager(view.focusProxy())
label = QLabel()
label.hide()
def on_pixmap_changed(pixmap):
label.setPixmap(pixmap)
label.adjustSize()
label.show()
rubberband_manager.pixmap_changed.connect(on_pixmap_changed)
ret = app.exec()
sys.exit(ret)
Show an Image in QGraphicsView
To display an image then you must use a QGraphicsPixmapItem where you load a QPixmap.
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QPixmap, QPainter, QPalette
from PyQt5.QtWidgets import (
QApplication,
QGraphicsView,
QGraphicsScene,
QGraphicsPixmapItem,
)
class ImageViewer(QGraphicsView):
def __init__(self, parent=None):
super().__init__(parent)
self.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
self.setAlignment(Qt.AlignCenter)
self.setBackgroundRole(QPalette.Dark)
scene = QGraphicsScene()
self.setScene(scene)
self._pixmap_item = QGraphicsPixmapItem()
scene.addItem(self._pixmap_item)
def load_pixmap(self, pixmap):
self._pixmap_item.setPixmap(pixmap)
self.fitToWindow()
def fitToWindow(self):
self.fitInView(self.sceneRect(), Qt.KeepAspectRatio)
def resizeEvent(self, event):
super().resizeEvent(event)
self.fitToWindow()
if __name__ == "__main__":
app = QApplication(sys.argv)
view = ImageViewer()
view.resize(640, 480)
view.show()
pixmap = QPixmap("image.jpg")
view.load_pixmap(pixmap)
ret = app.exec()
sys.exit(ret)
The previous widget is used to load an image from a file: pixmap = QPixmap("/path/of/image") or use the QPixmap provided by pixmap_changed signal of RubberBandManager.
Set a scene for your QGraphicsViews.
self.gvwShapes = Geometry()
self.gvwShapes2 = Geometry()
self.gvwShapes.setScene(QGraphicsScene())
self.gvwShapes2.setScene(QGraphicsScene())
Use QWidget.grab() to render it into a QPixmap and QGraphicsScene.addPixmap() to add it to the scene. You can specify the area with a QRect.
def button_screenshot(self):
pixmap = self.webEngineView.grab(QRect(180, 100, 300, 280))
pixmap.save(self.filename)
self.gvwShapes2.scene().addPixmap(pixmap)
def button_load_image(self):
self.gvwShapes.scene().addPixmap(QPixmap(self.filename))
how can i set Qicon from a url in PYQT , can you give me an example?
a basic example would be:
from PyQt4.QtGui import *
from PyQt4.QtCore import QUrl
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest
app = QApplication([])
url = "http://www.google.com/favicon.ico"
lbl = QLabel("loading...")
nam = QNetworkAccessManager()
def finishRequest(reply):
img = QImage()
img.loadFromData(reply.readAll())
lbl.setPixmap(QPixmap(img))
nam.finished.connect(finishRequest)
nam.get(QNetworkRequest(QUrl(url)))
lbl.show()
app.exec_()
use requests.get method to download the image and create a QIcon from it.
import sys
import requests
import PySide6
from PySide6.QtWidgets import QTableView, QWidget, QApplication, QGridLayout, QHeaderView
from PySide6.QtCore import Qt, QAbstractTableModel
from PySide6.QtGui import QColor, QIcon, QPixmap
from datetime import datetime
class MagicIcon():
def __init__(self, link):
self.link = link
self.icon = QIcon()
try:
response = requests.get(self.link)
pixmap = QPixmap()
pixmap.loadFromData(response.content)
self.icon = QIcon(pixmap)
except:
pass
class MainWindow(QWidget):
def __init__():
super().__init__()
self.setWindowIcon(MagicIcon(
"https://img.icons8.com/external-flatarticons-blue-flatarticons/65/000000/external-analysis-digital-marketing-flatarticons-blue-flatarticons-1.png"
).icon)
if __name__ == "__main__":
app = QApplication(sys.argv)
wid = MainWindow()
wid.show()
sys.exit(app.exec())