How to make non-square edges in Tkinter? - python

In order to make one of my programs more aesthetically pleasing I'm using images to create the boarders, however I want to create a non square boarder so the program looks kinda like this
___________
/ /
/__________/
How should I go about this?
This is on windows 7, btw.
Edit:
A tried to make a pseudo-edge using transparency however it doesn't come out transparent. For some reason it cam out as a dark grey. I want the red to be the "edge".

The concept you are after is called a "shapped window". Search for "tk shaped window" with your favorite search engine. There is a tk extension that claims to support this, though I haven't personally tried it. I presume since it works with tcl/tk it can be made to work with Tkinter since Tkinter uses tcl/tk under the hood.

I'm not familiar with Tkinker, but you could make an image with transparency where you don't want the border, which would make pseudo-slanted edges. There is no way for a window to be non-square however (For a good reason too).

Related

2d graphics in Python Kivy, advice is needed

I still have been studying world of Kivy and I have encountered with question. I am designing an interface. it has to have an appearance of analog device with arrow and curved scale like old voltmeters were. Just to display a data on the screen. I've tried to use canvas, but I stacked with resizing of window properties. Built canvas object was either connected to specific size in px, or changed location on the screen in wrong way. So, I am curious, maybe here are some others ways to embed objects which were built in another 2d graphics library, I am aware of existence of 3d module vpython and turtle. Maybe we have some more?
Can anybody give me a hint? I would be very grateful
kivy, canvas
view of my prototype
You can use Image widgets combined with Button Behavior or ToggleButton Behavior to make buttons that look like almost any kind of button that you like. And you can make a curved scale as described in this question.

how to change the color of our pixels using tkinder?

i want to control every pixel of my tkinter program but when i search how, i just found out that the only solution is to use 'canvas' and even if it allows us to draw lines, i think i didnt find out how to change for exemple the color of the pixel (x=200, y=478)
and i m also afraid that when i use my code on a really big size of pixels, the program becomes slow with tkinter.. i m still a beginner for those who havent noticed it yet.. so i m curious to know if there is no tool in tinker that actually is used like it takes the x, y of the pixel and the color you wanna apply! i guess it should be possible bcs how either tkinter is supposed to be programmed.. (i m still a beginner ^^) anyways if this tool exists pls tell me about it and if it is supposed to be as slow as canvas i can actually just try a better code..
so i m curious to know if there is no tool in tinker that actually is used like it takes the x, y of the pixel and the color you wanna apply!
There is no such tool. Tkinter simply isn't designed to do this. If you need to control individual pixels in a GUI, tkinter is the wrong tool to use.

How to change color of pixel on screen with python 3.9

How could I make something simple like for example crosshair for FPS game (not actually going to do that, just took this as an example). Or how can I set color for some pixels on screen, or something similar. What would be the best way to approach this problem?
You can use OpenCV, that is one of the most useful Computer Vision libraries for Python. You can do whatever you want with images, screencaptures, videos, etc.
But I believe that some prior experience with NumPy library is needed, since OpenCV is heavily dependent on it.

Creating a "Fill" command in tk inter

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.

Drawing graphics for LCDs

Im not sure if this is the correct place to ask this but as its more programming related than electronics I am posting here.
I have recently purchased a small LCD to experiment with. Its just one colour. Im using python to control it over serial.
My question is when it comes to the actual drawing. This whole area is completely new to me so I don't know if I am thinking the right way / going down the right path.
I want to be able to draw things on the LCD such as progress bars, animations (such as volume meters etc) and other simple - non text - based things. Just anything really.
In my mind the way I imagine doing this is by using python to draw a complete image of what I want on the LCD. Using PIL / Pillow for example and constantly redrawing and resending to the LCD.
So in the case of the progress bar, everything that's static is the same but then the progress bar rectangle for example would have its width altered each redraw.
I dont know if this it the correct way or if there are better ways or even if there are specific tools / modules for this kind of thing.

Categories