codeword success
February 19, 2013 Leave a comment
It only took a screenshot of my project in action to put myself back on the right path, and a very pleasant afternoon was spent adding the last piece of functionality to it – as a reminder, it’s a program that allows me to enter the settings for a codeword grid, which is a puzzle that looks like a crossword but with number standing for letters. The user tries out a letter in place of a number and eventually solves the whole puzzle, with each number representing a different letter. My program does not create or provide puzzles, but instead you can use it as a tool to help solve commercially available puzzles, to save scrubbing out incorrect guesses.
I had got it to the point where it would display the grid in the console and accept changes via direct entry in the console, so what was left to do was to provide a list of what letters had been used already and to not allow the same letter to be used for two different numbers.
Writing code for the list proved to be straightforward – rather than delving into different data types and debating which was best, I opted for a simple list, with the first entry at index 0 set to “*” and the rest of the entries set to ” ” (space). Adding a letter for a specific number then involved setting the list at that index to the letter, and resetting involved setting the entry back to a space.
I could then call these list functions as part of the setting and resetting a letter, and check whether a letter had been used already before allowing it to be entered into the grid.
My code at the moment has very little help for the user (hence part of my problems yesterday!) and it has very little error checking for input, but neither of these is a real issue as the intention is to put a GUI on the front of the code, to handle display and entries.
And here I hit the next issues: issue one is how to create a GUI in python and issue two is which editor to use to create it.
The book I’ve been working from suggests pythoncard, but I have not been able to install this successfully. I’ve managed to establish that Tkinter is already available as part of the python standard library, but it carries a warning that it will not run with the basic python IDLE, as that does not handle events properly, so that then leaves me looking around for an editor that will do the job.
I enjoy working with the IDLE, as it’s incredibly straightforward, and I object to using more time figuring out how to use an editor than I spend actually coding. I’ve got Eclipse that I’ve used for Java, and I’m currently looking into using that with a pydev plugin, but I’m starting to get frustrated by all these different options, which all seem designed to provide high levels of support with very complex projects and make life very complicated for the casual user who just wants to create a simple project.
The other IDE that I’m trying out is Geany, which I recognise as the software that originally came on my raspberry pi, and so I have used already for python. I’ve got it running with my codeword software, but when it gets to the end of the program, which goes as far as creating the grid, the program then seems to terminate without allowing me to enter further commands via the console. If I can put a GUI onto the program, then the console won’t be needed anyway, but it’s just another frustrating step.
I think with fondness of the days when I learnt programming, when we used C++ with an IDE that allowed us to design a GUI and attach code to it really easily. Even the Java editor we used back in those days seemed far more straightforward, even though I never did really get the hang of the different containers that you could use for java layouts.
Surely these things should be getting easier, not more complex?
Incidentally I’m now running a log of my project, with notes for each version change on what I’m attempting to do. Each feature is being developed piece by piece, with constant resaves as different versions – all versions ending in 4X are the basic version, while 5X added in the list and 6X used the list to check whether the letter was available before using it. I’ve also included screenshots of the project in action and a first sketch of what the interface might look like.
Hopefully if I end up leaving the project again for an extended period (for example while I build up my GUI skills) this log will make it much easier next time to pick it up and catch up with progress. I can’t say I understand every line of the code I’ve written or could duplicate it easily, but at least I know enough to know what it does and how to use it, and which functions are available.