Reflection of class on Nov 29th
At the beginning of
this chapter 5, there is a similar interface of drawing app which I have
created in last class, but the difference is that a line of various buttons is
added below the bottom of the original surface. So what are these buttons used
for?
As the basic instructions of this chapter says,
these buttons can change the line color and line thickness by attaching
functions to them instead of key presses, and the size of these buttons can be
adjusted easily as well. So how to do that?
In order to save
time, I downloaded the source code from the dedicated coding website and copied
them to the new text editing interface, what I need to do is adding relative
codes to the preset blanks which were highlighted by red color and run the
whole procedure to see what will happen on the app canvas. Absolutely, I need try
to change some codes to customize my own app canvas.
I defined some new functions about line colors
and bind them with relative keys by implementing ‘window.bind’ statement just
like the last chapter. Then, following to the steps of the example, I added buttons
to my application by typing codes of loading images for buttons and attached
functions which include necessary variables to buttons.
I didn’t understand
completely why I need to remove ‘event’ from between the brackets of pen color
functions so that the procedure could work normally, but I found that I couldn’t
change the pen color by pressing preset keys anymore when I run the program. Actually,
I found the solution for this item from the later content of this chapter, all
I need to do was removing these useless codes from the procedure because their
functions were already replaced by codes of buttons. Well, I got a feel suddenly
that the author was a fantastic magician who could read my mind and predict my
behavior. Just for fun.
At last, I did the
same operation as color button to plus and minus button to change line size and
try to change the value of side from LEFT to RIGHT of ‘Button’ function to see
what could be changed when I run it as the idea 1 said. Well, all things are
correct except the position of buttons. These buttons were arranged from the
right side of the bottom of the canvas. What’s more, I added another button to
choose a random color which I preset before by implementing random import and ‘random.randint’
command.
All is well! Now I can draw more fabulous
images by my new drawing application!