I want to make a program that will perform different functions depending on which part of an image I click on. I'd be ok with cutting up the image into different parts and placing them together, but they are in the shape of a circle, so I'm not sure how well I'd even be able to cut it since i'm just using Paint, nor how accurately I could place those images back together.
I'll include the image I'm using below.
Is there a way to make a single image have multiple buttons associated with it using python? I've mostly been looking at tkinter and could not figure out a way to do it.
If not, is there a good method I can use to put the image back together after cutting it up and making each image a button?
I think I could do this using Reactjs, but I'd rather do it all in python in possible because of other parts of the program.
I can make one image a button, or a bunch of different images into a bunch of buttons, but I haven't yet figured out how to make one image a lot of buttons, or place all of those buttons properly togther without their blank spaces overlapping, so I'd rather it all be one whole image if possible.
Related
As my code is quite long and with a lot of nested layouts I won't put it in here but I essentially have a QHBoxLayout which I want to have a different background colour as the others. I First thought about changing the stylesheet but I quickly learned that the layout is not affected by that as it apparently is not a visual element. Hence my Question: How do I create simple (geometric) elements? Is it even possible to just have a colored box in the background and some lables and pictures in the foreground?
I tried just using a big QTextEdit block and colouring this with the StyleSheet but this didn't get me the results I hoped for as It'd be hard to align the text the way I want it to be and add pictures.
I am writing a kicad plugin, and I need to create a GUI for this plugin. Because kicad uses wxpython, that is what I am using.
I have already figured out that placing my ui items using the layout sizers just isn't gonna give me the control I need to create the window I want. I know I can set the position of elements, and have been using that to create the ui I need.
The problem however, is that my window gets bigger than what would be reasonable (in some situations). Therefore I want to make it scrollable.
I have been playing around with wxformbuilder, and I found the wxScrolledWindow. That got me this far:
This is roughly what I want, except, when you want to place stuff within the scrolledWindow, you have to place one of the "sizers" in it (as far as I can tell at least), in which you place your buttons. The problem with that is, that, to my knowledge, setting the position of buttons in any of the sizers just has no effect at all.
So, my question is: how do I achieve this effect? and, is this even possible?
edit:
As an example of what I am trying to put within the scrolledwindow, this is a rough version of the ui I want to create (and want to be scrollable). (I want to eventually have, probably an icon button above each of the checkbox columns to indicate what they are for).
The final result would need to look something like this (the white squares being small images / buttons, also, in reality being not on the window bar,but in its own not scrolling section):
An example of something I wasn't able to achieve using sizers is, getting those checkboxes so close together, without making them appear off center. Different widgets seem to have different sizes, and checkboxes without border are especially small, so they end up appearing off center, example:
Also, those images above each column of checkboxes, which don't scroll, need to line up with the X coordinates of those scrolling checkboxes, which also seems very non trivial. Though also really hard to get right if I could give everything exact coords, so I might need to give up on that specific idea of making those not scrollable.
Goal: I have one large, interactive image, depicting several different buttons/symbols. Depending on which symbol it is, I want my program to click on the right one.
My attempt so far: Using cv2.matchTemplate() in Python, I could successfully identify everything that I needed to, as well as create copies that framed the right template with rectangles. No problems with the detection itself, the symbols are quite simple.
So far so good, but how do I proceed from there to interact with the original image on which I want to perform the clicks? I know that there are several modules to control mouse events, but the problem I have is that all the detection is based on the copy, and not the interactive original.
I'm using ffmpeg to work on some videos. I'm resizing each video down to a smaller size, padding it, and overlaying a static image overlaying the padding. Right now the static image has one textbox that says some information about the video. That was simple enough. I want to also add more information to the static image, though. I want to add information about the order of videos, with the current video being a different color. For example, I want text that looks like the following:
Video1→Video2→Video→VIDEO4→Video5→Video6
Where VIDEO4 is a different color, so we can easily see where we are in the order. It doesn't seem to be that easily done with ffmpeg:
I don't believe I could do multiple colors using one "drawtext" filter
If I have multiple textboxes (one for previous videos in the list, one for the current video in the list, and one for the videos-to-come), they don't line up very well horizontally, as the actual names of the video have varying lengths of text. It's a bit of a nightmare.
I can't use ASS scripts/subtitles because it's being put on static image, not a video
Is there any other solution to this other than just attempting to guess at the X value of these drawtext filters? Could I actually use some sort of subtitle script on an image? Am I able to reference other textboxes? If so, I could at least calculate the width of the textbox and position the next one accordingly. Everything I've seen so far has had some sort of timestamp beginning and end, and I just want it there for the whole video.
I'm using python and the ffmpeg-python library to interface with ffmpeg. This allows me to use a configuration file so I can dynamically add/remove videos to be created.
Just for more information, here's a snippit of how I'm making the videos:
overlay_input = ffmpeg.input(overlay_image)\
.drawtext(text="blahblahblah",
... text options...)
video_input = ffmpeg.input(video, re=None)\
.video\
.filter("scale",
...scaling options...)\
.filter("pad",
...padding options...)\
.overlay(overlay_input)
Any information would be very appreciated!
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.