1899 views|11 replies

3386

Posts

0

Resources
The OP
 

[Hua Diao Experience] 06 Building a Xingkong board development environment - Thonny programming [Copy link]

 
 
This post was last edited by eagler8 on 2022-6-17 08:56

1. Thonny is a lightweight Python editor that is easy to use and suitable for Python IDE beginners.

Just download and install it from the official website: https://thonny.org/.

[Hua Diao Experience] 01 Getting started with Xingkong Board
https://en.eeworld.com/bbs/thread-1206624-1-1.html
[Hua Diao Experience] 02 Simple use of Xingkong Board
https://en.eeworld.com/bbs/thread-1206649-1-1.html
[Hua Diao Experience] 03 Building the development environment of Xingkong Board Mind+
https://en.eeworld.com/bbs/thread-1206665-1-1.html
[Hua Diao Experience] 04 Testing the common functions of Xingkong Board

https://en.eeworld.com/bbs/thread-1206842-1-1.html
[Hua Diao Experience] 05 Building a development environment for Xingkong board: SSH connection and Jupyter programming

https://en.eeworld.com/bbs/thread-1207265-1-1.html
[Hua Diao Experience] 06 Building a Xingkong board development environment for Thonny programming

https://en.eeworld.com/bbs/thread-1207286-1-1.html
[Hua Diao Experience] 07 Building a Xingkong board development environment for VSCode programming

 
 

3386

Posts

0

Resources
2
 

2. Thonny Features


(1) Easy to get started. Thonny comes with Python 3.7 built in, so with just a simple installer, you can start learning programming. (You can also use a separate Python installation if necessary.) The initial user interface is stripped of all features that might distract beginners.

(2) Initial layout, easy variables. After completing hello-worlds, select "View → Variables" and see how programs and shell commands affect Python variables.

(3) Variable table, simple debugger. Just press Ctrl+F5 instead of F5 to run the program step by step without breakpoints. Press F6 for a large step and F7 for a small step. Steps follow the program structure, not just lines of code.

(4) Step through the statements and evaluate the expression step by step. If you use small steps, then you can even see how Python evaluates your expression. You can imagine this light blue box as a piece of paper, and Python replaces the sub-expressions one by one with their values.

(5) Visualization of expression evaluation, faithful representation of function calls. Stepping into a function call will open a new window with a separate local variable table and code pointer. Fully understanding how function calls work is particularly important for understanding recursion.

(6) Visualization of call frames, with syntax errors highlighted. Unclosed quotes and parentheses are the most common syntax errors made by beginners. Thonny's edit makes these easy to spot.

(7) Visualization of syntax errors, explaining scope. Highlighting variable instances reminds you that the same name does not always mean the same variable and helps spot typos. Local variables are visually distinguished from global variables.

(8) Local and global names are visually distinguished to explain the pattern of references. Variables are initially displayed according to a simplified model (name → value), but you can switch to a more realistic model (name → address/id → value).

(9) Variable table and value table, code completion. Students can explore the API with the help of code completion.

(10) Code completion, beginner-friendly system shell. Select "Tools" → "Open system shell" to install additional packages or learn to handle Python on the command line. PATH and conflicts with other Python interpreters are handled by Thonny.

(11) System shell for Python commands, simple and clean pip GUI. Select "Tools" → "Manage Packages" to install third-party packages more easily.

 
 
 

3386

Posts

0

Resources
3
 

3. Try to set up Thonny
(1) Check Shell and File in the View menu to facilitate writing programs and viewing files in the line blank board.

 
 
 

3386

Posts

0

Resources
4
 
This post was last edited by eagler8 on 2022-6-17 10:05

(2) Open Run, select the interpreter as Remote Python 3 (SSH), enter the host of the blank board (IP: 10.1.2.3), username (user name: root), and click OK to proceed to the next step.

 
 
 

3386

Posts

0

Resources
5
 

(3) If the board is connected normally, you will be prompted to enter a password. Enter the default password dfrobot and check Save password.

 
 
 

3386

Posts

0

Resources
6
 

(4) After the connection is successful (here connect to WIFI), the files in the board are displayed in the file view on the left, and the factory demonstration program is opened in the code editing area

 
 
 

3386

Posts

0

Resources
7
 

4. Use Thonny
(1) to run the test program

#【花雕体验】06 搭建行空板开发环境之Thonny编程
#测试程序:屏幕显示“你好,行空板”

#  -*- coding: UTF-8 -*-
from unihiker import GUI
import time

gui = GUI()
#unihiker库文字显示
gui.draw_text(text="花雕体验",origin="center",x=115,y=100,color="#0066CC")
gui.draw_text(text="你好,行空板",origin="center",x=120,y=150,color="#0066CC")
gui.draw_text(text="这里尝试搭建Thonny环境",origin="center",x=120,y=190,color="#0066CC")

while True:
    #保持程序运行
    time.sleep(1)

 
 
 

3386

Posts

0

Resources
8
 

(2) Save the program to the blank board

 
 
 

3386

Posts

0

Resources
9
 

(3) Test scene graph

 
 
 

3386

Posts

0

Resources
10
 

(4) Simplest procedure

 
 
 

3386

Posts

0

Resources
11
 

(5) File exchange. Right-click on a file to upload the file from your computer to the Xingkong board or download the file from the Xingkong board to your computer.

 
 
 

3386

Posts

0

Resources
12
 

(6) Python library management. After connecting to the upstream Xingkong board, you can manage the Python package of the Xingkong board in Thonny's management package menu (install, uninstall, switch versions)

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list