-
Book Overview & Buying
-
Table Of Contents
Raspberry Pi Projects for Kids (Second Edition)
By :
It would be useful if whenever we clicked on the map, along with adding a circular marker, we could also add a few words to describe what we're marking.
Getting some text from the program's user is going to be slightly complex, so let's create a simple version first to make sure we have the right code structure. Add the following two lines of code right at the end inside the canvasclick function:
label = getlabelname()
widget.create_text(x, y+2*size, text=label)The first line of code gets some text from a function that we haven't written yet called getlabelname. This function will eventually ask the user to type some text into a small pop-up window, but for now, it will just give us a default message. The second line of code draws our text at a particular position just underneath the circle. As with widget.create_oval earlier, widget.create_text allows the text color to be set using the extra arguments of fill="colour" and activefill="colour".
Here is our most...
Change the font size
Change margin width
Change background colour