I'm making a Minesweeper in pygame but when I set the icon it changes the color. The icon that I get is bluer than the expected icon and I don't understand why. Here's the code that I use:
Actual Icon
Expected Icon
import pygame as pg
pg.init()
window = pg.display.set_mode(size)
icon = pg.image.load("icon.png")
pg.display.set_icon(icon)
pg.display.set_caption("Minesweeper")
I tried to use icon = pg.image.load("icon.png").convert() and icon = pg.image.load("icon.png").convert_alpha() but it doesn't work.
Do you know why it does this and how to fix it?
It looks like your PNG file has some embedded information or formatting that is causing this distortion. I saved the image as a bitmap using paint.net and it displays without modification:
Perhaps some conversion commands could transform your image as desired, but it's probably easier to do the image manipulation outside of pygame.
Related
Every time I open a pygame window with pygame.display.set_mode, it shows the default pygame icon and title on the window.
I use pygame.display.set_caption() to change it, but for 2 seconds when opening the window it shows the default title. I want to make a quality game, but think that this is not too good for it.
Is there a way to edit the pygame package file to show my game's title instead of the default one?
Opening the window
After opening the window
ALl you have to do is make sure the command to change the window icon and title is one of the first commands issued in the source pygame files.
I am working on some sort of animation maker with tkinter but I have run into a problem, i would want to save the current application window or canvas widget to a .png file for later use, is this possible? Thanks in advance.
import pyautogui
myScreenshot = pyautogui.screenshot()
myScreenshot.save(r'Path to save screenshot\filename.png')
And there it is ! ^^
And if you don't want everything else on your screen, you can try to crop it with pil
How to crop an image using PIL?
I'm working on a project right now, and I need to get a black mouse cursor like this:
I've used root.config(cursor="arrow black black"), but it doesnt want to change the color of the cursor. I'm using windows, and if this helps, Windows has the black cursor installed by default.
Can anyone help me on this?
Edit:
how to change the mouse pointer color tkinter? does not work for me.
I can change how the cursor looks, but not the color.
On Windows systems, the arrow pointer is mapped to native IDC_ARROW pointer, the color of which you can't control within tkinter.
Of course, Windows does have a black mouse pointer, but appearance of the pointer in use depends on the current color scheme (Control panel - Mouse - Pointer), so you wouldn't see it unless you'd changed the scheme.
Applications should not touch it, since it's strictly a user preference.
However, the black pointer file lives at %windir%\Cursors\arrow_r.cur, so we can use it directly when needed:
import tkinter as tk
import os
root = tk.Tk()
path = '#%s' % os.path.join(os.environ['WINDIR'], 'Cursors/arrow_r.cur').replace('\\', '/')
root.configure(cursor=path)
root.mainloop()
It's also worth to notice, that the black pointer has a medium and a large variants - arrow_rm.cur and arrow_rl.cur respectively.
I'd like to create a Gtk.StatusIcon with custom text. Ideally I'd like to append this to an existing image, but text-only is ok, too. How can I achieve this?
I've seen some posts about getting a Gtk.Label's pixbuf but those methods seem to be removed from Gtk3 (pixbuf_get_from_drawable)
I don't think that is possible. The status icon is not a widget and the icon is going to be scaled by the window manager. Even if you used Cairo or PIL to generate an image on the fly to use as the icon pixbuf, it wouldn't have the effect of an embedded label in the system tray. It would instead be tiny, unreadable text smushed into the size of the other icons.
I am a beginner at programming at can't seem to figure out how to use bgpic('photo.gif') in turtle.
I have enclosed the 'photo.gif' in the same folder as the script. Every time I execute the program with bgpic, the turtle window crashes. Do I have to resize the picture? Change its format?
bgpic only accepts gif images.
You should convert your image to gif format with photoshop or another similar tool or alternatively use for example python PIL to make the conversion programmatically