Showing posts with label GUI. Show all posts
Showing posts with label GUI. Show all posts
Wednesday, February 26, 2014
SGC GUI Example Showing Data Written to File
My son developed a new GUI example with SGC during today's lesson. He built the application from start to finish in about an hour.
This version writes the selected data to a file.
The code is here.
Monday, February 17, 2014
Using the Android Keyboard with Pygame
I modified the GUI example I posted on GitHub yesterday to include an example of using the Android software keyboard for text input.
I had to build my own text box input since I couldn't get it to work with SGC. There's still a few glitches with the keyboard and I don't suggest you use the code in a production application, but it should be suitable for my son's next class.
I'm sure there's an easier way to handle the text from the keyboard and I would love to see another person's code. However, since the whole purpose of my project is to teach my son programming, it should be useful to teach him to build a text input box with the Android keyboard.
This only works with individual keys right now and it won't work with Swype.
On the pgs4a forum, there was some question as to whether or not the soft keyboard actually worked. I thought I would create a quick example to show that it does work.
Sunday, February 16, 2014
Best Python GUI for Pygame, pgs4a, Android Phones
![]() |
| Simple Game Code and Pygame |
Three weeks ago, I wrote about testing PGU with Pygame. After evaluating it yesterday, I gave up trying to get PGU to work on Android and moved to Sam Bull's Simple Game Code (SGC). It may be possible, to get PGU to work, but I wasn't able to find anyone using it on Android when I searched through the pgs4a forums.
Sam Bull's code is nice and easy to use and I was able to get several nice menu widgets running on my test LG Optimus S Android phone within an hour. There's extensive documentation the widgets drop right into a standard pygame code structure.
![]() |
| Radio buttons, switch, slider, and drop down |
It's easy to connect the buttons to code to run things in your games. For example, in the example above, the "Start" button will change the game level, which will run a different set of code. The "Quit" button will exit the game. The drop down menu and radio button work fine.
![]() |
| Easy to use text on Pygame surfaces |
![]() |
| Running on LG Optimus S Android phone |
If you end up using SGC on Android, I would be interested in hearing about it and seeing some code examples.
Everyone asks what the "best" library to use is. It's going to be a matter of taste. SGC on Android is the best for me and I thought I would share my opinion. If you have a different opinion, I would like to learn about other GUI toolkits for Python/Android.
Update February 17, 2014
The blog Possibly Wrong has a description of getting PGU working with pgs4a.
I am having problems getting the software keyboard working with SGC InputBox. I can't get the text to display properly inside of the text input box. At this point, I'm still planning on using SGC unless I learn something more about PGU to make it worth digging into.
Thursday, January 23, 2014
Phyiscal Maps and PGU GUI for Pygame
Classes are going slowly at the start of the year. My son has been working on a program to manipulate a map of Palo Alto, based on the city's bicycle routes. In the first class, he got the map to display, navigate, bounds checking, and jump to a specific location. In the second class he started to build the menu for the touchscreen.
Since he's building basic widgets such as buttons on a regular basis, I looked at what type of pre-built widgets are out there. The lead GUI toolkit for Pygame appears to be PGU. I downloaded it, but did not develop any applications with it yet.
We blew through half the class last night trying to figure out how to get the background transparency working on a sprite sheet. We finally got it working with Surface.subsurface(rect). I should have realized this earlier since I wrote this blog post last month about slicing algorithms using subsurface.
Since he's building basic widgets such as buttons on a regular basis, I looked at what type of pre-built widgets are out there. The lead GUI toolkit for Pygame appears to be PGU. I downloaded it, but did not develop any applications with it yet.
We blew through half the class last night trying to figure out how to get the background transparency working on a sprite sheet. We finally got it working with Surface.subsurface(rect). I should have realized this earlier since I wrote this blog post last month about slicing algorithms using subsurface.
Subscribe to:
Posts (Atom)






