hope someone of you can help me. I have a QGraphicsView, that is displaying a jpeg. The jpeg is much bigger than the QGraphicsView, so you can drag the jpeg (with the mouse). Over that jpeg I want to add a QPixmap. But this QPixmap needs to be static. If I move the jpeg, the QPixmap needs to always on the same position. With a QLabel that has only text, it isn't a problem. But if I set a QPixmap to the QLabel, it isn't displayed. How can I solve my problem?
Does anyone have an idea?
Best,
Oli
You may try to subclass QGraphicsScene and reimplement drawBackground method to display your static QPixmap.
Related
I am trying to capture a part of my screen with PIL.ImageGrab and then converting it to an numpy.array as you can see below.
np.array(ImageGrab.grab(bbox=(0, 0, 720, 480)))
What I can't figure out is, how to get this data into a Kivy window or a widget?
All my Widgets are in separate classes so I would like to have one Screen class with all the code necessary for this part of my Window.
I have already tried methods like this one, but I don't know how to implement it since Kivy confuses me a lot sometimes.
If my idea just isn't realizable, I guess you could save each captured frame as .jpg format and then load it into Kivy. But I imagine this is not the most efficient way.
Thanks a lot in advance! Dominik
IMAGE
when I click file>>save as png...
It will save as png to that penguin. Is it possible?
It is possible but the image must be a tkinter PhotoImage.
The picture of your program suggests that it's not a photoimage. However; google "tkinter PhotoImage" and you will find information on how to build one pixel by pixel or however you want. Once you have a photoimage, saving it is easy:
image.write('some_name.png', format='png')
I am making a game, and I want it to be fullscreen. However, the pygame fullscreen is strange, creating a screen too large. So I referred to this: Pygame FULLSCREEN Display Flag Creates A Game Screen That Is Too Large For The Screen. However, when I followed these instructions
import ctypes
ctypes.windll.user32.SetProcessDPIAware()
true_res = (ctypes.windll.user32.GetSystemMetrics(0), ctypes.windll.user32.GetSystemMetrics(1))
pygame.display.set_mode(true_res,pygame.FULLSCREEN)
from an answer (but instead using pywin32 instead of ctypes, like this: win32api.GetSystemMetric(0)).
I used this, and while it does create a fullscreen, it also creates a black border around my screen and enlarges everything a slight bit, including my cursor. How can I get rid of this black border and get all shapes to normal size? Or is there a better way to create a good fullscreen?
If it helps, I use Windows 10.
Thanks in advance!
I think the problem of enlarging everything arose with the use of ctypes module as because the ctypes module makes use of a function named as GetSystemMetrics() whose work is to get the size of the screen of your system.
And might be the import pygame is loading some dll that is not compatible with a dll that windll needs.
So I suggest either you update the ctype library or pygame library or update both libraries or you can enlarge screen size by providing custom width and height values according to the resolution supported by your system.
Hope this helps !!
I'm trying with QWebView.mask() in PyQt4 or PySide or PySide2, for convert the transparent pixels of a transparent QWebView into a window mask, like a frameless window with custom shape, but not work, the window is translucent.
webview = QtWebKit.QWebView()
mask = webview.mask()
webview.setMask(mask)
Why this not work, what alternatives exist and how i can solve this?
note: I'm trying with QWidget too, and still not works.
widget = QtGui.QWidget()
mask = widget.mask()
widget.setMask(mask)
Something like this: Using an alpha transparent mask on a QWidget?
but for PyQt4, not for Qt, because im working on scripting...
Maybe this?
webview.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents)
widget.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents)
This is applicable for BOTH, i hope this help you...
How come this happens to my QPixmap painted in a QGraphicsView?
It has 0.8 opacity added by code.
It´s a PNG image. The original looks like this:
I see this kind of strange flickering that stays the same depending on the height of the QMainWindow. When i resize it, some of the pixmaps get disorted.