I am attempting to add a background image to a label in pyqt5 using the background image.
label.setStyleSheet("background-image : url(https://www.tutorialkart.com/sample_image.jpg);")
but for some reason it won't load any images from web, and instead I get this error:
Could not create pixmap from https:\\www.tutorialkart.com\sample_image_small.jpg
I have tried different image types and the only thing that I tried that got it to work was using local files from my computer, which won't be a good fix for what I need it for.
Then I tried using the python Pixmap and setting it through the python code directly, but there was the same issue.
Anyone know a potential fix for this?
Related
I'm trying to create a script that would automate a workflow with Python, I'm using PyAutoGui to find a image on screen and it locates and clicks on it.
The problem is that it will work with machines with my display settings (1920x1080, 100% scale), and will fail to locate when the scaling is changed (resolution can change, and it will work fine though). There's a good answer explaining how it works here: Running Pyautogui on a different computer with different resolution.
If the problem is with scaling, how can I programmatically do this step-by-step, that would work with any kind of display settings? I couldn't find any definitive answers so far:
Something that could do this with Python:
Start the program, get and save current scaling to variable
Change scaling to 100%
..... Code
Change scaling back to how it was and end the program
I am working in a PyQt5 project in which at the end of the process, the user has rearranged a set of images (MovablePixmapItem(QtGui.QPixmap)) in a canvas (QGraphicsScene) to their proper positions. Once at that point, the main idea is that the resulting QGraphicsScene should be exported as a whole image. I have searched the web looking for a way to solve this without much success.
Please any help with regards to this problem would be appreciated.
Windows 7/Python 2.6
I am trying to take full browser screenshots and then use pillow to compare the images. I have started to use Ghost for the screenshots because i couldn't seem to get Selenium/PhantomJS to take full browser screenshots in headless mode. When i take a screenshot using Ghost the resolution of the images are like 780x8000 even thought i set the viewport size to 1920x680 (just testing resolution sizes while getting use to pillow). Sadly i can't share the screenshots but here is just is a snippet of code.
from ghost import Ghost
self.ghost = Ghost(viewport_size=(1920,680))
self.ghost.open('someurl')
self.ghost.capture_to('somedir')
After taking the screenshot the image is showing all the items in the webpage, but at the 1000px wide breakpoint for the layout.
Can someone either explain how to get the desired results of getting screenshots at 1920x"PageHeight" using either ghost or possible some other python package?
I have found the fix and it is to not set the viewport size in the constructor but using the set_viewport_size(x,y) method.
You should be able to take headless screenshots w/ selenium+phantomjs if you call
driver.set_window_size(x, y)
and then
driver.get_screenshot_as_file( "/path/to/img.png" )
Does anyone know a simple way to load a .gif image into python using pygame? I tried loading a .gif image using 'pygame.image.load(path)' which worked although only the first frame loaded.Ever since I had to use a loop to display multiple images at once.
Simply put, you cannot display multi-frame GIFs in Pygame, unless you use an extra library. Instead, explode your GIF. You will have to do everything manually, as Pygame does not control flow time, etc, which is necessary for animated GIFs.
I have a Python script that displays images fullscreen on a BeagleBoard with the GUI disabled. The script is started when the board boots. For this I use PyGame which works perfectly fine. Except for some reason the image qwality is scaled down. Because the images are stored in HQ I assume that PyGame resamples the image. I was unable to find out where this can be changed so I decided to replace PyGame, it also seems a bit much to "just" display an image.
I have the code below to display the image. According to documentation the default image viewer will show the image. (Which is supposed to be XV). But as soon as I run the code below where image is a filepath I get "sh: xv: not found".
from PIL import Image
im = Image.open(image)
im.show()
So I tried to install the XV package but can't find how to install it for Angstrom.
My question could either be "How to display images fullscreen with Python?" (To which the answer was supposed to be the code above). Or the question is "How can I get XV installed on Angstrom?" (What is the package name for opkg install)
I did search, but haven't found something that works...
Image.show() in PIL is more intended for debugging than actual, production use. It is hardcoded to call xv <temp-image-file-pil-creates>. You can hack around this (make a symbolic link called xv that will call some other image viewer), but it's still a rather bad way to go about it.
I don't know enough about the BeagleBoard to tell you the best/canonical way to display an image fullscreen, but if you got halfway there with PyGame, perhaps you can post your code and the community can help you fix the quality problem.
If the image is getting downscaled to fit the screen, you might look into using transform.smoothscale to scale the image manually (to avoid losing quality).