Shi
WFH stuff
Published in
1 min readApr 29, 2020

--

Lesson 1: draw a rectangle with turtle

material:

https://realpython.com/beginners-guide-python-turtle/

environment:

Host: windows
Lab: windows subsystem Linux (Ubuntu 18.04)
version: python 3.6

Lab:

# install Ubuntu as WSL (Windows Subsystem Linux)

# tried to import turtle and get Pen;
# oh, crap, missing some tk stuff.
# install tk for python3;
>>sudo apt install python3-tk
# crap, there is NO xwin!
# install xserver on windows (https://sourceforge.net/projects/xming/)
>>export DISPLAY=:0
>>python3
>>>import turtle
>>>c=turtle.Pen()
# move forward by 100 pixels and turn left by 90 degrees; 4 times
>>>c.fd(100);c.lt(90)
>>>c.fd(100);c.lt(90)
>>>c.fd(100);c.lt(90)
>>>c.fd(100);c.lt(90)
# hide turtle
>>>c.hideturtle()
gotchas:
-- if you call up(), then your turtle moves ahead without trace.
-- fd() = forward()
-- lt() = left()

ref:

https://docs.microsoft.com/en-us/windows/wsl/install-win10https://www.howtogeek.com/261575/how-to-run-graphical-linux-desktop-applications-from-windows-10s-bash-shell/

--

--

Shi
WFH stuff

I am a coder/engineer/application security specialist. I like to play around with language and tools; I have strong interest in efficiency improvement.