Create a menu home screen for piTFT using pygame - python

I would like to create a home screen(menu) for my project using pygame(?).
I have a piTFT 2.8" Capactive display from adafruit.
I have design the whole display menu. Take a look on this demo screen for example:
Now I would like to built this on my pi. is there any easy way to position each element as can be seen on the attached image?
The display is 320 x 240, and I think if I try position the elements blindly it will take a lot of time which in this case, I dont really have spare time to waste.
Have you got any other suggestions about the use of pygame? Would you suggest me something different?

This answer may be a bit general, but what I do to find each position is go to paint or some paint program and then I add markers where positions are, then I can select rectangles and find there positions. It would be hard to find the positions by itself just from that image. Do you have a mac, windows, linux?'
just paste your menu, into the paint program and draw rectangles around certain icons, after that just go to the top left of the rect and it will tell you the position, so you will get both the width, height, and position.

Related

How to set a background drawing area for cairo with other items on top

I have tried a bunch of stuff over the last few months to only find the best way is as per the attached image which is to use a fixed container in the window to then carry on as per normal but it then makes it hard to have everything else resize properly.
Just curious if there would happen to be a better way to have the drawing area behind everything else to draw on with out having to use a "fixed" container.
In trying over the last few months if I use say a table then put a drawing area in it fills on of the boxes which is not how i feel it should work for what i am trying to do.
I have found it hard as if i try to resize the window I then have to resize the "fixed" container which is ok but if I try to make the window smaller by the bottom right corner it will not resize, I got round this by hard coding a window size and linking this to a button to "minimize" the window correctly.
If anyone has any pointers to information or has any help to offer that would be great.
If nothing comes up I guess I will keep trying to make it happen as I have worked out so far and have a minimum window size and maximum window size with maybe a x/y input box to customize the window size if required.

Getting coordinate of elements on my laptop screen

I am making a fun python program to automate couple clicks for me. I want to use pyAutoGui library provided by python to make this program. I am struggled to find the coordinates of elements that I want to click. Are there any ways that I can find coordinates of my elements?
You can use pyautogui.mouseInfo().
MouseInfo is an application to display the XY position and RGB color information of the pixel currently under the mouse. Works on Python 2 and 3. This is useful for GUI automation planning.
The full documentation is at https://mouseinfo.readthedocs.io/en/latest/
Point Position (for Windows) is a simple tool that lets you pick the coordinates for any point on your screen (using X,Y axis). Simply point one of the four corner arrows at the spot on your screen that you want to define and click the button to display the X/Y coordinates.

Finding Sprites in pygame

I am attempting to make a 2D game in Pygame. Later I will convert it to kivy to deploy to mobile devices. I have searched many tutorials to get started, and I understand the basics of sprites/physics. However, I cannot find a tutorial that tells me HOW to find the location of a sprite from a sprite sheet. For example, a tutorial mentioned that I could use a drawing program to find the location of a sprite, but it didn't go into detail as to HOW you would find the location of a sprite on a large sheet of sprites.
Basically I have to find the x, y location of a sprite on a .png or .jpg spritesheet file.
For example, if I want to get the location of sonic running from a spritesheet in order to use that image my code would look like this:
sonic_running = (589, 500, 80, 80)
The first two numbers in the tuple would be the x and y location of sonic in the spritesheet, and the last two numbers in the tuple would be the height and width of that sprite. But I have no idea how to find the x and y position of the sprite in the spritesheet, or the height and width of the sprite. If anyone has worked with pygame, or game creation i'd really appreciate the help. I hope that the question was detailed enough because I am still just starting out.
PyGame doesn't have any sprite sheet auto-detection functionality. I think the tutorial you were reading simply meant you'd have to find it by hand. For example, in MSPaint on Windows, the coordinates of the cursor are in the status bar at the bottom of the window. There isn't really any more magic than that.
If you're using sprites from an existing sheet you found, this may be tedious. If you're creating sprite sheets, I would imagine there are probably some tools to do this that export both an image and a text file with metadata. However I have not used these personally.

How to draw onscreen controls in panda 3d?

I want to make a game in panda3d with support for touch because I want it to be playable on my windows tablet also without attaching a keyboard.
What I want to do is, find a way to draw 2d shapes that don't change when the camera is rotated. I want to add a dynamic analog pad so I must be able to animate it when the d-pad is used with mouse/touch.
Any help will be appreciated
Make those objects children of base.render2d, base.aspect2d or base.pixel2d. For proper GUI elements take a look at DirectGUI, for "I just want to throw these images up on the screen" at CardMaker.

Drawing pixels on top of Gstreamer

I'm trying to build an application in Python that can draw things on top of video. I have not found a way to do this using gstreamer + Tkinter; I don't think tk lets you do transparent Canvases. So I've looked at using gtk instead, but I'm a bit lost- I would like to be able to just drop some sort of transparent overlay on top and push pixels, but I don't think there's such a thing as a transparent DrawingArea, either. So I need a way to edit the contents of a DrawingArea after each frame of video is in it but before it's shown to the screen. I tried using expose-event but that hasn't worked.
Any suggestions on where to go from here? I want my final product to be a little interface to let the user draw lines and polygons on top of a video as well as drawing pixels programatically- and, if possible, save the result to frames and/or video. So a direction that is more likely to make that possible would be preferred.
Edit: Tried using the "handoff" signal but it flickers madly. PiTiVi has a custom Pipeline that has a state-changed signal which they use to draw lines and circles with Cairo. So this is totally doable...
Edit 2: Right, okay. PiTiVi only draws when the video is paused; I guess I can deal with that. That's what it was using the state changed signal for- you can watch for state change messages and emulate a signal. I can deal with that, but it would be really nice to draw over every frame.

Categories

Resources