Using python for graphics projection? - python

If this is not the best place to ask this, please advise me on an alternative exchange.
I'm trying to create a matrix (N x N) and project it onto a wall using a projector. Each cell of the matrix will have the option to be color-coded or lit. So, given a matrix and a cell, the program will be able to colorize it.
Right now I can achieve this using the graphics.py library and Tkinter. However, when I connect my projector to my laptop via VGA, I have to drag the Tkinter window over and position it on the extended projector screen. It's a manual drag and re-positioning and this should be all automatic.
Are there any other methods (preferably in Python) of achieving this or something similar?
Thanks!

Set your laptop to mirror its screen instead of using the projector as an extended desktop. Then you won't have to drag Tkinter over. This is an OS / videocard setting and has nothing to do with Python.

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.

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.

matlab's imshow3d mouse scrolling image visualization in python

Currently, I am trying to build a User Interface with python to visualize MRI images (in numpy) in 'tkinter' Graphic User Interface.
The feature of mouse scrolling from Matlab's imshow3d is essential but I was not able to find anything like this on web (ex.https://www.mathworks.com/matlabcentral/mlcdownloads/downloads/submissions/47463/versions/3/screenshot.jpg).
Does anyone have any idea how I can implement the mouse based slice browsing with tkinter?
or are there any other gui that I could use to build what I want.

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.

How to make non-square edges in Tkinter?

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).

Categories