First image:
Second image:
The first image shows what I'm getting at this moment.
But I just want to make it as the 2nd image which is looking transparent for all widgets. Apparently tkinter widgets does not support transparency. How can I make my GUI like second image?
Any help would be appreciated.
I know question is asked long ago, but I(and probably still many beginners like myself) was bothered with same thing and I came up with some kind of solution.
I've just cut part of background of exact place where button is placed with exact measurements and I achieved something similar to transparency by placing that cropped image as background of a button, label....
Not a "coded" solution but worked for me.
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 want a floating round button (no window-frame + no title bar + transparency) in my Python-project. For this I created a round button in GIMP (with transparency around the button). I am a beginner in GUI-programming therefore I will explain you all the steps I already tried so far:
First try: I tried to use Tkinter with this attributes:
self.configure(background='black')
self.wm_attributes("-topmost", 1)
self.wm_attributes('-transparentcolor', 'black')
This was a little success for me but I didn't like the jagged edges around:
the jagged edges were best visible on white backgrounds:
Second try: This time I used PyQt5 and at first glance everything was perfect and I used these settings:
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
But a closer look gave me this:
partly transparent grey/white background:
Now I need advice from an expert because I could not find any helpful tutorial or documentation for this problem.
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.
I'm trying to make a programm with python to take screenshots out of a rectangle you draw on your screen, but first, I'd prefer to determine the dimensions. How can I do that? How can I draw a rectangle and then get the size of it? I'm trying to use pyautogui or PILLOW, but I still need practice. I also thought about using tkinter to make a transparent window and then doing it from there, but I can't figure out how to do it on Lubuntu 18.04.
And if you have any other recommendations or advice about the screenshot part, It's welcome!
Hope the problem it's clear, thank you in advance! ;)
The last couple of days I have tried to find a working solution to overlay a Phonon.VideoWidget with a simple QLabel. Sadly I wasn't able to find a working solution.
Here is what I have tried:
Parenting. I tried the "normal" parenting stuff addressing the QLabel to the VideoWidget. Result: The label does not show up at all.
QStackedLayout. As suggested here: http://www.qtcentre.org/threads/31490-Overlaying-Widgets-on-top-of-VideoWidget. Result: Label is shown but always behind the video
GraphicsView. I tried a lot here as it looked like the most promising, but at the end the CPU load was just too high so the video did not play back. Setting the view's viewport to QGLWidget did not solve it. Result: Overlay works but video does not play caused by high CPU load.
Subclassing the VideoWidget. As mentioned here: https://wiki.qt.io/Overlay_widget_for_Phonon_VideoWidget. I took the same approach to create the overlay. This works just fine after all, except for the moveEvent. It does not look nice if the label is realigned after moving the widget has finished. Is there a way to update this already when moving VideoWidget?
I really hope someone can help me here (I use PySide but examples in C++ should work as well) or give me a pointer on where to look. Please let me know if I should share some code snippet to reproduce.
The best you can do is creating a new window that floats above your video widget. For example create a parentless QLabel and make sure that it moves in sync with your main window.
label = new QLabel();
label->setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint);
In your QMainWindow subclass, override moveEvent and resizeEvent and do something like:
label->move(mapToGlobal(QPoint(0, height() - label->height())));
This keeps the label in the bottom-left corner, change it to fit your needs.