I'm trying to make a frame in wxPython using a wx.grid as a table and with a background image behind the cells.
I already tried placing the grid in a table and lowering the frame opacity with frame.SetTransparent(), which might work, but the frame just refuses to display if I give the parent a background with StaticBitmap. I couldn't find an alternative way to use an image as a background or a way to fix that problem.
There's also the wx.grid.SetDefaultCellBackgroundColour function, but the function only accepts RGB values with no alpha. I tried messing around with internal values but no luck there either.
Bonus points if the image doesn't overlap with the headers but at this point I'll take what I can get.
Related
Looking for a way to be able to find the color data of a pixel(s) on a Canvas. I'm sort of a beginner to coding, just gauging if this is possible/how to go about this. This is for a project I've been working on, and for part of it, it's necessary to compare the color data of a Canvas to an Image. I know how to find the per pixel color data of an Image, but I haven't found anything for a canvas. I'm using a Tkinter Canvas at the moment, but if it's not possible on that library, I'm open to switching to another library. Any ideas? Thanks guys!
Looking for a way to be able to find the color data of a pixel(s) on a Canvas.
Tkinter doesn't provide the ability to do this.
I am pretty new to Python and coding in general. I have been working on a program that is similar in nature to ms paint. So far, I've added the capabilities to create multi-colored rectangles, lines, ovals, and really any polygon.
I've been using the tkinter GUI. I've been wanting to add a fill command, but I'm kind of stuck as to how to start it. My idea for how it would work would be that it would check the color of the pixel the user is currently hovering over, then check up, down, left, and right for the same color in pixels. If it found that, it would change the color of those pixels (I guess by creating a really small rectangle object?). This would theoretically be able to fill an area. But, I really can't find anything on how to access the color of a pixel in tkinter.
I know the location is event.x and event.y for a specific event, but I can't find anything about pixel color. I don't really have any code written for it yet because I am unsure that tkinter can even access the color of a pixel and not just object colors.
Unfortunately, this isn't possible. I did some searching around, and found several other similar questions, but the general idea is that Tkinter does not support such a feature. It makes sense, considering that Tkinter is a GUI library.
I saw a suggestion somewhere, where an idea was proposed to create 1x1 rectangles using the Tkinter Canvas to basically mimic pixels. However, this method eventually leads into performance issues and lagging, so it's not really recommended either.
You may want to try exploring some other libraries to work together with Tkinter. You can keep the Tkinter GUI, but use an image manipulation library or something similar which integrates well with Tkinter, for the actual pixel drawing.
My objective is to make a small widget that changes shape considering a single value (bottom bar).
I made this shape variation with a drawPoligon inside a paintEvent:
https://i.gyazo.com/ecbe701c15c24f069101bbe17a6bbf93.mp4
This widget will act like a color picker:
(example)
however I still have some limitations I don't know how to pass through yet.
My question kinda boils around these 2 points:
1- Previously I used CSS Style sheets on my QtDesigner UI made widget to paint the background-color, however I need to:
mask color sections of the widget
make it "unclickable" outside that area
paint the area with a polygonal shape that I can adjust the points.
2- I have used self.setMask() but it does not seem to affect the style sheet background color. if it does I do not know how to set it up properly. I also did attempts with clip_path and background-clip with poor or no results.
I have tryed with the drawPolygon shape I made but It creates a issue with the alpha of the SVG cursor I have. leaving a trail on the drawn Polygon until I update it again. if this is the way I would need a way to handle this issue to go around it.
I made a custom polygon that does the weird behavior on the video this is just a sample one on the example.
What I got so far:
background-color: rgb(85, 170, 127);
clip-path:polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
Thank you for any help in advance.
I'm trying to make a my main window have a background image. The problem I'm running into is that the background is comprised of 2 separate images. the top image is placed in the center above the bottom image. I can't find any references on how to accomplish this. I'm thinking I might be able to utilize these two methods to do it, but I'm not sure if I'm heading in the right direction or not.
QGraphicsScene.BackgroundLayer
QGraphicsScene.ForegroundLayer
I'm using python3 with pyqt5. Any help pointing me in the right direction would be greatly appreciated. I wasn't able to find much of anything on this so far.
Thanks in advance.
-edit: In case there is confusion, I have to use 2 images because the background is generated from 2 pictures that are scraped from the web during run time. Maybe someone knows of a way to dynamically merge the 2 images together with specific x,y coordinates with a library, then just use the new image as a background?
I figured it out. The easiest way to accomplish what I'm trying to do is to make 2 labels. 1 that covers the entirety of the window, and another that covers the area where the second picture is supposed to go. Then use Pixmap on each label to cast an image to each label. Figure out the x,y offset required to line up the inner image, adjust the label placement, done.
Someone know if it's possible to change the color of a pixel in a canvas without using un object, so without using something like canvas.create_oval or canvas.create_rectangle ?
There is no way to color a pixel other than to create a 1x1 pixel object of some sort. And yes, at some point you will experience performance problems. The canvas simply wasn't designed to be used this way.
If you're really needing to create a large area in which you can manage individual pixels, you can create a canvas with a single image that is the same size as the canvas. You can then set the color of individual pixels on the image through the photo image interface.
Within tkinter itself, it's impossible.
Even if you manage to change a pixel on canvas window (which is possible with X11 and Windows APIs in a platform-dependent way), you'd have to ensure it's repainted properly.
You can, of course, place a frame of size 1x1 over the canvas, with a background color you want. This way, pixel is "changed" and no canvas object is created. If there's a real (though strange) problem behind a question, this trick could be a solution.