-
Notifications
You must be signed in to change notification settings - Fork 15
Grid Layout has no contains param #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@DJDevon3 first of all, That's looking awesome 🎉 Nice Job! I think there are a few different ways this could work. Typically the Theoretically a new kind of Label could be created that has a contains method (or contains() added to existing ones) and then your code could call contains on each label within the Grid to find out which one matches the coordinates. Another option that wouldn't require any library modifications could be to use Buttons instead of Labels inside of your Grid cells. That way they will have a contains() function that you could call on each Button to determine which one matches the coordinates. I think you could set up the Buttons with transparent or black background and white label color so that they'll end up looking the same as a Label would visually. With all of that being said I do think there is an opportunity for GridLayout to have a function that helps make this easier to achieve. I would opt for a name other than specifically |
I can add a ton of spritebuttons but they weren't my first choice for RAM reasons. There woiuld be about 100 of them plus 100 labels. While it would look nice, I fear the 1000+ other lines for displaying sensor data, weather API, MQTT, etc.. it wold be too much to handle. Another method I thought about was a BMP background of a keyboard and adding touchpoint coordinates layered on top of the bmp. After considering those options, I figured the best scenario would be to have every grid be touch capable. Unsure if a touch keyboard is an edge case, the solution would likely be intensive no matter the approach. This is the first time I've used grid layout to this extent. I thought something like You know these libraries the most intimately so I trust you to come up with a solution that benefits everyone and not just my use case. A touch keyboard would in my opinion be a worthy inclusion to the grid layout library. |
@DJDevon3 Sorry, I did not mean to use Buttons instead of GridLayout, but rather Buttons with the GridLayout. Essentially using Button's inside of each cell of the Grid rather than a Label. Anyhow, while I do think that route is possible. I do think there's opportunity for a GridLayout enhancement to make an easier way to do it and not require the Buttons. I've copied out your keyboard layout code to use for developing a proof of concept of the functionality. I'm intending to work on that during Deep Dive tonight if you're interested in watching along. |
@FoamyGuy I've been up all night trying different things with no progress and might not be awake to watch the stream. :( Wouldn't buttons inside the grid layout create just as many labels or is it 1 button reused per cell? That would definitely be more efficient! Wish I knew you'd be covering this already took some sleeping pills. Hope you use the whole feather weather script so you can see how much work I've put into it... and perhaps some ways to improve it? I'm particularly proud of getting the RSSI scan to work properly. The plan is to make SSID's s electable to change networks like a mobie phone does. It's a work in progress. Hope you'd get a chuckle out of my use of literal uppercase SHOUTY named variables, did that just for you. :P |
In that other approach, it would need to be 1 Button per cell, they could not be re-used. And indeed each button contains a Label so in the end it will use just as many Labels in total. But the benefit would be that on those buttons you could call their contains method to test touch points and determine if they were on that item. I cannot use the full script right now because I don't have the right hardware for everything that' sin your project. I'm using a PyPortal Titano which has the same screen size as the Featherwing you're project uses. But it doesn't have native wifi, and I don't have the the other componenets to connect to it, nor the openweather / mqtt infrastructure set up at the moment. I'll try to get the full thing put together at some point to give it a go, but for now I must work wit only the Grid. |
Sounds good. I'm drinking coffee and will be awake. Sugar, lots of sugar. Cant' wait to see what you come up with. One of the nice advantages of grid layout is it easily divides screen.wdith or screen.height. With SpriteButtons you must place the x,y exactly and that gets very tedious for something that needs 60+ buttons |
Running your example but I'm getting multiple key presses where as you seem to get single presses. Unsure if that's a difference within the other libraries I'm using. I used it in my full script and didn't try for the minimal version you made. Will try your softkbd version by itself next. Was able to get it to work somewhat with my full script though. I like the name soft kbd name you came up with too. You did more in a single session than I could do in weeks. Thank you for the feature addition! I'm also running into layer issues with my full script. Apparently hidden=True doesn't mean the button is gone. So my popout menu is still touchable even though it's hidden. Have a lot of groups and layers to fix. That's a me problem though. Works as intended in 8.2.7 using your .py to override the .mpy 👍 |
This was resolved by #92 and resulted in https://github.com/FoamyGuy/CircuitPython_SoftKeyboard |
On my path of creating a touch keyboard for the TFT Featherwing after laying out the keyboard saw there's no .contains param like there are for widgets and buttons. Requesting contains add to grid layout or some advice on completing this with touch capability.
I have it drilled down to being able to work with the individual cells to print out the keyboard letters needed with hardcoded statements but not touch yet.
That's the gist of it. Full code can be viewed on my Github which I've been working on daily.
Having grid layout the capability for touch contains would have made this much easier. I'm all ears for ideas if there's a better way.
The text was updated successfully, but these errors were encountered: