I am trying to run a program with Python PyQt5 where I take ip's of 2 camera's and stream them live on my screen, but the stream is coming like so (check the 1st picture) like the one in the given picture both the steams are coming in the first half but What I really want them is to come in separate halves(check 2nd picture for better understanding) of the top layout of the code which is in horizontal layout, not together in just the 1st Half of the screen (also i am getting these black borders which I am not able to remove if anyone knows how it can be removed please do tell)
And after the video streams are in the top layout in the bottom layout I am trying to get a Graph and an empty widget which I could edit for later use.
Thanks in Advance
Click here to see my desired output(what i am actually trying to get)
#this is my main window code#
import sys
import vlc
import subprocess
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5 import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import*
from PyQt5.QtWebEngineWidgets import*
from PyQt5.QtPrintSupport import*
class Window(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Final App")
self.setGeometry(350,150,400,400)
self.UI()
#calling the UI fucntion which contains the layouts
def UI(self):
self.mainLayout=QVBoxLayout()#main layout is in Vertical Layout
self.topLayout=QHBoxLayout()#top layout is in Horizontal layout
self.bottomLayout=QHBoxLayout()#btm layout is in also in horizontal layout
self.topLayout.setContentsMargins(0, 0, 0, 0)
#self.topLayout.setSpacing(0)
#adding the top and bottom layout inside main layout
self.mainLayout.addLayout(self.topLayout)
self.mainLayout.addLayout(self.bottomLayout)
#assigning variables to different widgets that can be added later
self.videoFrame1 = QFrame()
self.videoFrame2 = QFrame()
#code here to add graph#
#graphcode=graph#
self.text=QLabel("A widget that I can Edit LATER ")
########################################################video player 1###################################################################################
self.videoFrame1 = QFrame()
#QWidget.setGeometry (self,100, 200, 1000, 500)
self.videoFrame1.setGeometry(QtCore.QRect(100, 100, 100, 200))
self.topLayout.addWidget(self.videoFrame1)
self.vlcInstance = vlc.Instance(['--video-on-top'])
self.videoPlayer = self.vlcInstance.media_player_new()
self.videoPlayer = self.vlcInstance.media_player_new()
self.videoPlayer.video_set_mouse_input(False)
self.videoPlayer.video_set_key_input(False)
#self.videoPlayer.set_mrl("rtsp://admin:admin123#192.168.1.250:554/cam/realmonitor?channel=1&subtype=0", "network-caching=300")
self.videoPlayer.set_mrl("rtsp://admin:admin123#192.168.1.251:554/cam/realmonitor?channel=1&subtype=0", "network-caching=200")
self.videoPlayer.audio_set_mute(True)
if sys.platform.startswith('linux'): # for Linux using the X Server
self.videoPlayer.set_xwindow(self.videoFrame1.winId())
elif sys.platform == "win32": # for Windows
self.videoPlayer.set_hwnd(self.videoFrame1.winId())
elif sys.platform == "darwin": # for MacOS
self.videoPlayer.set_nsobject(int(self.videoFrame1.winId()))
self.videoPlayer.play()
#########################################video player 2############################################################################################
#frame2
self.videoFrame2 = QFrame()
self.topLayout.addWidget(self.videoFrame2)
self.vlcInstance1 = vlc.Instance(['--video-on-top'])
self.videoPlayer1 = self.vlcInstance1.media_player_new()
self.videoPlayer1 = self.vlcInstance1.media_player_new()
self.videoPlayer1.video_set_mouse_input(False)
self.videoPlayer1.video_set_key_input(False)
#self.videoPlayer1.set_mrl("rtsp://admin:admin123#192.168.1.251:554/cam/realmonitor?channel=1&subtype=0", "network-caching=300")
self.videoPlayer1.set_mrl("rtsp://admin:admin123#192.168.1.250:554/cam/realmonitor?channel=1&subtype=0", "network-caching=200")
self.videoPlayer1.audio_set_mute(True)
if sys.platform.startswith('linux'): # for Linux using the X Server
self.videoPlayer1.set_xwindow(self.videoFrame2.winId())
elif sys.platform == "win32": # for Windows
self.videoPlayer1.set_hwnd(self.videoFrame2.winId())
elif sys.platform == "darwin": # for MacOS
self.videoPlayer1.set_nsobject(int(self.videoFrame2.winId()))
self.videoPlayer1.play()
###########################################################################################################
#calling top layout
self.toplayout()
#calling bottom layout
self.bottomlayout()
#setting main layout
self.setLayout(self.mainLayout)
self.show()
def toplayout(self):
self.topLayout.setContentsMargins(10,10,20,20)
self.topLayout.addWidget(self.
videoFrame1)
self.topLayout.addWidget(self.videoFrame2)
def bottomlayout(self):
self.bottomLayout.setContentsMargins(150,40,100,80)
self.bottomLayout.addWidget(self.raddar)
self.bottomLayout.addWidget(self.button2)
def main():
App= QApplication(sys.argv)
window=Window()
sys.exit(App.exec())
if __name__ == '__main__':
main()
this is my other folder having a matplotlib code:---
#this is another folder having my garph which i want to call in my main window#
import matplotlib.pyplot as plt
def UI():
plt.figure()
# Set x-axis range
plt.xlim((-4,4))
# Set y-axis range
plt.ylim((0,8))
#setting background color
ax = plt.axes()
ax.set_facecolor('black')
# Draw lines to split quadrants
plt.plot([0,0],[0,8], linewidth=3, color='blue' )
plt.plot([-4,4],[4,4], linewidth=3, color='blue' )
plt.title('Quadrant plot')
plt.show()
UI()
hey so I was able to work something out with the code that I already had so I am going to stream the videos on pyqt only and use subprocess to call the .exe file which I made using MATLAB so here you go do have a look.(here I haven't called the Subprocess right now)
import sys
import vlc
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtPrintSupport import *
class MainWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
#this sets the size Maximum for the main Q Frame
self.setWindowState(QtCore.Qt.WindowMaximized)
#this removes the title bar of the window
self.setWindowFlag(Qt.FramelessWindowHint)
self.move(0,0)
#Main Q frame defined where the HBox layout is defined
self.mainFrame = QFrame()
#means defining it in central widget
self.setCentralWidget(self.mainFrame)
#HBox Layout
t_lay_parent = QHBoxLayout()
#used to move the frames inside to go more up down, right,left
t_lay_parent.setContentsMargins(0, 0, 0, 315)
#removes the spacing between the frames and makes it looks like that its just 1 stream
t_lay_parent.setSpacing(0)
#########################################################Camera Frame 1###################################################################
self.videoFrame = QFrame()
QWidget.setGeometry (self, 100, 200, 1500, 1500)
t_lay_parent.addWidget(self.videoFrame)
self.vlcInstance = vlc.Instance(['--video-on-top'])
self.videoPlayer = self.vlcInstance.media_player_new()
self.videoPlayer = self.vlcInstance.media_player_new()
self.videoPlayer.video_set_mouse_input(False)
self.videoPlayer.video_set_key_input(False)
#self.videoPlayer.set_mrl("rtsp://admin:admin123#192.168.1.250:554/cam/realmonitor?channel=1&subtype=0", "network-caching=300")
self.videoPlayer.set_mrl("rtsp://admin:admin123#192.168.1.251:554/cam/realmonitor?channel=1&subtype=0", "network-caching=200")
self.videoPlayer.audio_set_mute(True)
if sys.platform.startswith('linux'): # for Linux using the X Server
self.videoPlayer.set_xwindow(self.videoFrame.winId())
elif sys.platform == "win32": # for Windows
self.videoPlayer.set_hwnd(self.videoFrame.winId())
elif sys.platform == "darwin": # for MacOS
self.videoPlayer.set_nsobject(int(self.videoFrame.winId()))
self.videoPlayer.play()
##########################################################Camera Frame 2#################################################################
#frame2
self.videoFrame1 = QFrame()
t_lay_parent.addWidget(self.videoFrame1)
self.vlcInstance1 = vlc.Instance(['--video-on-top'])
self.videoPlayer1 = self.vlcInstance1.media_player_new()
self.videoPlayer1 = self.vlcInstance1.media_player_new()
self.videoPlayer1.video_set_mouse_input(False)
self.videoPlayer1.video_set_key_input(False)
#self.videoPlayer1.set_mrl("rtsp://admin:admin123#192.168.1.251:554/cam/realmonitor?channel=1&subtype=0", "network-caching=300")
self.videoPlayer1.set_mrl("rtsp://admin:admin123#192.168.1.250:554/cam/realmonitor?channel=1&subtype=0", "network-caching=200")
self.videoPlayer1.audio_set_mute(True)
if sys.platform.startswith('linux'): # for Linux using the X Server
self.videoPlayer1.set_xwindow(self.videoFrame1.winId())
elif sys.platform == "win32": # for Windows
self.videoPlayer1.set_hwnd(self.videoFrame1.winId())
elif sys.platform == "darwin": # for MacOS
self.videoPlayer1.set_nsobject(int(self.videoFrame1.winId()))
self.videoPlayer1.play()
##########################################################################################################################################
#adding layout inside Main Frame
self.mainFrame.setLayout(t_lay_parent)
#shows the Pyqt frame
self.show()
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setApplicationName("VLC Test")
window = MainWindow()
window.show()
app.exec_()
Related
I'd like to make a very simple PyQt5 panel, something a little like a very simple version of the MATE panel. In order for it to work as a panel, other windows of the desktop environment must not go under or above the panel, and when a window is maximised, it enlarges to the edge of the panel window, but does not overlap and go on top of the panel. How might this behaviour be implemented, or how might the window manager be directed to treat the panel appropriately?
In the LXPanel application preferences, one can see properties like these specified. What is happening in the background here and how can it be replicated by PyQt?
For the purposes of this question, let us assume that the panel is a window at the left edge of a display. Minimal working example code follows:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import (
QApplication,
QPushButton,
QToolTip,
QWidget,
)
def main():
app = QApplication(sys.argv)
interface = Interface()
sys.exit(app.exec_())
class Interface(QWidget):
def __init__(self):
super().__init__()
self.setWindowFlags(Qt.WindowStaysOnTopHint)
self.setWindowFlags(Qt.FramelessWindowHint)
QToolTip.setFont(QFont('SansSerif', 10))
self.setToolTip('This is a <b>QWidget</b> widget.')
button_1 = QPushButton('Button 1', self)
button_1.setToolTip('This is a <b>QPushButton</b> widget')
button_1.resize(button_1.sizeHint())
button_1.move(40, 50) # button width: 80
button_2 = QPushButton('Button 2', self)
button_2.setToolTip('This is a <b>QPushButton</b> widget')
button_2.resize(button_2.sizeHint())
button_2.move(40, 80) # button width: 80
button_quit = QPushButton('Quit', self)
button_quit.setToolTip('Quit the application.')
button_quit.resize(button_quit.sizeHint())
button_quit.move(40, 110) # button width: 80
button_quit.clicked.connect(self.closeEvent)
self.resize(160, 600)
self.setWindowTitle('Panel')
self.show()
def closeEvent(self, event):
sys.exit(0)
if __name__ == '__main__':
main()
EDIT: With Python XLib, I appear to be a little closer to the answer. I appear to be reserving space of the right size, but with the window of the launcher appearing to the side of that reserved space. The updated code, this time including new XLib code, is shown below. Note that in order to run the example, both PyQt 5 and Python XLib are required:
sudo apt install python3-pyqt5 python3-xlib
The new minimal working example follows:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import (
QApplication,
QPushButton,
QToolTip,
QWidget,
)
from Xlib.display import Display
def main():
app = QApplication(sys.argv)
interface = Interface()
sys.exit(app.exec_())
class Interface(QWidget):
def __init__(self):
super().__init__()
self.setWindowFlags(Qt.WindowStaysOnTopHint)
self.setWindowFlags(Qt.FramelessWindowHint)
QToolTip.setFont(QFont('SansSerif', 10))
self.setToolTip('This is a <b>QWidget</b> widget.')
button_1 = QPushButton('Button 1', self)
button_1.setToolTip('This is a <b>QPushButton</b> widget')
button_1.resize(button_1.sizeHint())
button_1.move(40, 50) # button width: 80
button_2 = QPushButton('Button 2', self)
button_2.setToolTip('This is a <b>QPushButton</b> widget')
button_2.resize(button_2.sizeHint())
button_2.move(40, 80) # button width: 80
button_quit = QPushButton('Quit', self)
button_quit.setToolTip('Quit the application.')
button_quit.resize(button_quit.sizeHint())
button_quit.move(40, 110) # button width: 80
button_quit.clicked.connect(self.closeEvent)
self.resize(160, 600)
self.setWindowTitle('Panel')
window_identification = self.winId().__int__()
window_height = self.height()
window_width = self.width()
print(f'window identification: {window_identification}')
print(f'window height: {window_height}, window width: {window_width}')
window = Window(window_identification)
window.reserve_space(window_width, 0, 0, 0)
self.show()
def closeEvent(self, event):
sys.exit(0)
class Window(object):
def __init__(self, window_ID):
self._display = Display()
self._window = self._display.create_resource_object('window', window_ID)
def reserve_space(self, left=0, right=0, top=0, bottom=0):
LEFT = int(left)
RIGHT = int(right)
TOP = int(top)
BOTTOM = int(bottom)
print([LEFT, RIGHT, TOP, BOTTOM])
self._window.change_property(
self._display.intern_atom('_NET_WM_STRUT'),
self._display.intern_atom('CARDINAL'),
32,
[LEFT, RIGHT, TOP, BOTTOM])
self._display.sync()
if __name__ == '__main__':
main()
I want to make the label item of a plot clickable, that is, I can click the bottom or left label of a plot to call a menu.
My attempt:
The most obvious way is to rewrite the LabelItem class and overwrite the mousePressEvent() function, however, I did not see any methods in docs to add a LabelItem to a PlotItem at correct position. Code:
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
import pyqtgraph as pg
import sys
class ClickableLabelItem(pg.LabelItem):
def __init__(self, text='No Data'):
super(ClickableLabelItem, self).__init__()
self.setText(text, justify='left')
def mousePressEvent(self, ev):
print('clicked')
class AbstractPlot(pg.GraphicsLayoutWidget):
def __init__(self):
super(AbstractPlot, self).__init__()
self.pl = pg.PlotItem()
self.addItem(self.pl)
left_label = ClickableLabelItem()
self.pl.addItem(left_label)
# "Clicked" is printed but the label
# appears at wrong position
if __name__ == "__main__":
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
app = QApplication([])
win = QMainWindow()
plot = AbstractPlot()
win.setCentralWidget(plot)
win.show()
if (sys.flags.interactive != 1) or not hasattr(Qt.QtCore, 'PYQT_VERSION'):
QApplication.instance().exec_()
Label appears at wrong position
If you want to detect in the label associated with the axis then you can override the mousePressEvent method of GraphicsLayoutWidget and compare the item associated with the point pressed by the mouse.
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QMainWindow
import pyqtgraph as pg
class AbstractPlot(pg.GraphicsLayoutWidget):
def __init__(self):
super(AbstractPlot, self).__init__()
self.p1 = self.addPlot(title="Plot 1")
self.p1.setLabel("left", "Value", units="V")
self.p1.setLabel("bottom", "Time", units="s")
def mousePressEvent(self, event):
super().mousePressEvent(event)
item = self.itemAt(event.pos())
if item is self.p1.getAxis("left").label:
print("clicked left")
elif item is self.p1.getAxis("bottom").label:
print("clicked bottom")
if __name__ == "__main__":
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
app = QApplication([])
win = QMainWindow()
plot = AbstractPlot()
win.setCentralWidget(plot)
win.show()
if (sys.flags.interactive != 1) or not hasattr(Qt.QtCore, "PYQT_VERSION"):
QApplication.instance().exec_()
I've created a gui using PyQt5 in PyCharm and I've managed to get one QLabel with an image in it (Picture1.png) showing up, however, when I try to add a second QLabel with a second image (named Shutter1.png) on the same window, it seems to remove both labels and nothing shows up on the gui. I'm not sure where I'm going wrong and any help would be greatly appreciated, I'm a novice! NB I've doublechecked the filepath for both imagePath and imagePath_1 are correct. See below for attached code:
from PyQt5 import uic, QtWidgets, QtGui, QtCore
import sys
import pkg_resources
import functions.initialisation as inits
import functions.Sig2Open as S2O
import functions.Sig2Close as S2C
class Ui(QtWidgets.QMainWindow):
def __init__(self):
super(Ui, self).__init__()
self.gui = uic.loadUi('Shuttergui.ui', self)
# Creates the path of the image
self.imagePath = "C:/........../Picture1.png"
self.label = QtWidgets.QLabel(self.gui)
self.image = QtGui.QImage(self.imagePath)
self.pixmapImage = QtGui.QPixmap.fromImage(self.image)
self.label.setPixmap(self.pixmapImage)
self.label.resize(self.width(), self.height())
self.label.move(60, 170)
self.imagePath = "C:/....../Shutter1.png"
# Create label that holds the image in imagePath
self.label_1 = QtWidgets.QLabel(self.gui)
self.image_1 = QtGui.QImage(self.imagePath)
self.pixmapImage_1 = QtGui.QPixmap.fromImage(self.image_1)
self.label_1.setPixmap(self.pixmapImage_1)
self.label_1.resize(self.width(), self.height())
self.label_1.move(60, 170)
self.gui.showMaximized()
# redirect closeevent func to main self rather than inside gui
self.gui.closeEvent = self.closeEvent
# Initialise shutter functions
inits.ardopenup(self)
inits.ardshutup(self)
self.gui.show()
def closeEvent(self, event):
import time
time.sleep(0.1)
print("main thread quitting")
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
app.setStyleSheet(pkg_resources.resource_stream(__name__, '/css/darktheme/style.css').read().decode())
window = Ui()
sys.exit(app.exec_())
I would like to ask how do I go about including a folium map into PyQt 5 window application such that the map does not take up the whole window. I have found a similar post on StackOverflow "How to show Folium map inside a PyQt5 GUI?", however, the solution code provided shown the folium map takes up the whole of the PyQt 5 window application.
So my question is how do I include the folium map but only takes up a portion of the PyQt 5 window application? As shown below, I am trying to include the map into the rectangle area. *The rectangle black box is drawn on paint for reference purposes.
FYI I have tried out the solution code from the StackOverflow post but I can't seem to be able to resize the map.
WANTED OUTPUT
CURRENT CODE FOR REFERENCE
from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton
from PyQt5 import QtWebEngineWidgets
import sys
from PyQt5 import QtGui
from PyQt5.QtCore import QRect
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.title = "MAP PROJECT"
self.left = 200
self.top = 100
self.width = 1500
self.height = 800
self.initWindow()
def initWindow(self):
# set window title
self.setWindowTitle(self.title)
# set window geometry
# self.setGeometry(self.left, self.top, self.width, self.height)
# Disable PyQt 5 application from resizing
self.setFixedSize(self.width, self.height)
self.buttonUI()
self.show()
def buttonUI(self):
shortPathButton = QPushButton("Find shortest path", self)
# (set button location (x, x) set button size (y, y)
shortPathButton.setGeometry(QRect(30, 300, 120, 50))
button2 = QPushButton("Another path", self)
# (set button location (x, x) set button size (y, y)
button2.setGeometry(QRect(30, 370, 120, 50))
button3 = QPushButton("Another path", self)
# (set button location (x, x) set button size (y, y)
button3.setGeometry(QRect(30, 440, 120, 50))
# Below code is to connect the button to the function
# button.clicked.connect(self.ClickMe)
# Create function for shortest path (A* algorithm)
"""def ClickMe(self):
print("Hello World")"""
if __name__ == "__main__":
App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec())
The problem has nothing to do with a QWebEngineView or folium but how to place widgets inside the window, if so, then a solution is to use layouts in this case I will use the following structure: First a central widget is established, inside this one QHBoxLayout , and in the QHBoxLayout a QWidget is added as a container to the left side where a QVBoxLayout will be placed where the buttons will be, and to the right side the QWebEngineView:
import io
import sys
import folium
from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets
class Window(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.initWindow()
def initWindow(self):
self.setWindowTitle(self.tr("MAP PROJECT"))
self.setFixedSize(1500, 800)
self.buttonUI()
def buttonUI(self):
shortPathButton = QtWidgets.QPushButton(self.tr("Find shortest path"))
button2 = QtWidgets.QPushButton(self.tr("Another path"))
button3 = QtWidgets.QPushButton(self.tr("Another path"))
shortPathButton.setFixedSize(120, 50)
button2.setFixedSize(120, 50)
button3.setFixedSize(120, 50)
self.view = QtWebEngineWidgets.QWebEngineView()
self.view.setContentsMargins(50, 50, 50, 50)
central_widget = QtWidgets.QWidget()
self.setCentralWidget(central_widget)
lay = QtWidgets.QHBoxLayout(central_widget)
button_container = QtWidgets.QWidget()
vlay = QtWidgets.QVBoxLayout(button_container)
vlay.setSpacing(20)
vlay.addStretch()
vlay.addWidget(shortPathButton)
vlay.addWidget(button2)
vlay.addWidget(button3)
vlay.addStretch()
lay.addWidget(button_container)
lay.addWidget(self.view, stretch=1)
m = folium.Map(
location=[45.5236, -122.6750], tiles="Stamen Toner", zoom_start=13
)
data = io.BytesIO()
m.save(data, close_file=False)
self.view.setHtml(data.getvalue().decode())
if __name__ == "__main__":
App = QtWidgets.QApplication(sys.argv)
window = Window()
window.show()
sys.exit(App.exec())
I have this code as follows:
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
if __name__ == "__main__":
app = QApplication(sys.argv)
w = QWidget()
eff = QGraphicsOpacityEffect(w)
anim = QPropertyAnimation(eff, b"opacity")
btn = QPushButton("Button", w)
btn.clicked.connect(w.close)
eff.setOpacity(0)
w.setAutoFillBackground(True)
w.setGraphicsEffect(eff)
w.show()
anim.setDuration(10000)
anim.setStartValue(0)
anim.setEndValue(1)
anim.start()
sys.exit(app.exec_())
It works fine (fade in effect). However, when I resize the window, the animation restarts, causing the window to blink/flicker during resize. If I remove the call to animate after the call to show, no more blink (but no more fade in).
Moreover, after some time, resizing to a much bigger size causes a white rectangle over a black background to be displayed.
Is there something I am missing?
UPDATE
This is the behavior I am looking for (background remains white, i.e. opacity=1, after the animation run once). Works with the following code but does not look like best practice to do it like this.
import sys, time
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class MyWidget(QWidget):
def __init__(self):
super().__init__()
self.w = QWidget()
self.w.setMinimumSize(400,400)
self.w.resizeEvent = self.selfOnResize # added this
def animate(self):
self.eff = QGraphicsOpacityEffect(self.w)
self.anim = QPropertyAnimation(self.eff, b"opacity")
self.btn = QPushButton("Button", self.w)
self.btn.clicked.connect(self.w.close)
self.eff.setOpacity(0)
self.w.setAutoFillBackground(True)
self.w.setGraphicsEffect(self.eff)
self.w.show()
self.anim.setDuration(100000)
self.anim.setStartValue(0)
self.anim.setEndValue(1)
self.anim.start()
# this fixes the issue but looks like a dirty hack
def selfOnResize(self, event):
self.eff.setOpacity(1)
# print(event)
if __name__ == "__main__":
app = QApplication(sys.argv)
w = MyWidget()
w.animate()
sys.exit(app.exec_())