Adding some colours

I've made a bit of progress with my app; most of my effort went into trying to understand unicode and generally getting confused by the various encodings (specifically, UTF-8 and unicode). The upshot is that the app can now save lists of hanzi and handles text much better, not breaking when given text with English words, numbers or punctuation. In fact, the app can now handle punctuation and formatting much better, so doesn’t, for example, attempt to look up punctuation in the dictionary, and colours it differently (see image).

I worked out how to colour characters different, so I can keep track of which hanzi I know (whatever 'know' means). Currently, I can save a new list of words by clicking on hanzi and then on the ‘Add to list’ button. Once added to the list, all incidences of the hanzi change from red to blue. The pinyin and meaning boxes are now TKinter Entry widgets, which means I can edit the pinyin and meaning before adding the hanzi to the list. I can also click and drag on the canvas to select multiple hanzi (which will be searched for in the dictionary), and then add this compound to my list. I could, if I so wished, also select an entire sentence, write its pinyin and meaning, then add this to the list.

Reader v1.03

However there are a few problems. Because text is selected by clicking and dragging to create an invisible rectangle, sentences that span more than one line can't be selected properly. Moreover, it is possible to select to the first hanzi of every line, in which case they will be concatenated into a single meaningless string. Also, colouring hanzi currently only works when single hanzi are added to the dictionary, not compounds or sentences. I’m still pondering how to handle single hanzi, compounds and sentences. Finally, I would like the app to load saved word lists when starting, and use this as a dictionary before tries the main cedict-based one.

Incidentally, the text in the image is from Ellie’s Secret Diary, which I got as a dual text from the excellent children’s section of Oxford’s public library. I’m slowly building up my own library of texts for my app to use. I’d like to further improve the way the app deals with formatting, so things such as titles can be displayed differently and I’d also like to create multiple pages for different chapters. I’ve added a scrollbar for the text, but it seems to confuse the app’s ability to locate text on the page, so mousing-over one character displays another. Finally, I need to think of a good way to efficiently work out how high the canvas should be. So quite a bit more still to be done.

Post new comment

The content of this field is kept private and will not be shown publicly.