有人說, Leo 編輯器是程式開發歷程上的一項創新, 也有人說, 一旦用上手, 就再也回不去了.
但是, 這樣一套看似程式開發與資料編輯管理的神器級工具, 為何如此冷門, 好像受歡迎程式不如預期?
經過整理歸納, 理由如下:
- Leo Editor 歷經 Python2 與 Tkinter 的年代, 到目前採 Python3 與 PyQt5 的架構後, 網路上仍然留存許多幾年前甚或十年前的舊導引資料, 初學者很難掌握正確的資訊, 因此無法輕易導入.
- Leo Editor 雖然全部使用 Python 編寫, 但是在同時支援 Python2 與 Python3 的情況下, 程式碼中仍留存許多老舊的設計與秘笈指令, 即使是使用 Leo Editor 多年的老手都很不容易通盤掌握, 更遑論新手.
- Leo Editor 的開發群面對龐大的程式碼, 雖然不斷積極在思考改良, 但是真正能夠動手貢獻新功能或參與計劃的人數, 卻非常少, 因此進展的速度與靈活度並非很高.
總之, Leo Editor 並非是一套能夠輕易上手的工具, 但也正因為如此, 才需要有更多人能夠面對上述三項問題, 努力提供更多的實用導引資料, 介紹比較常用的功能, 而且協助 Leo Editor 開發群, 讓這套工具可以由更多新手接棒, 持續更新改進.
以下, 我們將從系統的安裝開始, 逐步介紹 Leo Editor 的相關功能.
安裝 Leo Editor
Leo Editor 在 5.1 版時推出 @clean 節點指令功能, 這項新功能改進了先前 @auto 指令在內容置入 Leo Editor 特有標註的問題, 因此大家若要安裝, 記得一定要使用 5.1 以上的版本.
至於什麼是"節點指令功能", 什麼又是"Leo Editor 特有標註", 我們隨後再來了解.
Leo Editor 推廣上的另外一個問題, 上面已經提過, 門檻高導致冷門, 參與人數少則導致 Ubuntu 目前的 apt-get install leo, 仍然會安裝舊的 Leo Editor 5.0 版, 因此初學者必須非常細心, 努力收集資料, 綜合判讀, 才能走上一條正確的學習之路.
好了, 我們先從 Windows 操作系統的安裝看起.
因為 Leo Editor 5.1 版可以在 Python3 環境下開啟, 而 Leo Editor 5.1 版採用 PyQt 作為圖形介面, 因此 Leo Editor 5.1 版的安裝 , 就必須從 Python3 與 PyQt 的安裝開始.
在 Windows 環境下安裝 Python3 非常簡單, 但是安裝 PyQt 則相對比較困難, 主要原因在於 Windows 環境下 PyQt 的安裝, 牽涉到程式碼的編譯, 而通常網路上現成的簡易 PyQt 安裝套件會牽涉到版本, 假如 Python3 與 PyQt 版本沒有正確搭配, 簡易 PyQt 安裝套件就無法完成安裝.
以下在 Windows 環境中的 Python3 與 PyQt 安裝, 又分為固定式安裝與可攜式安裝, 而所謂的可攜式安裝 ,其實就是在固定式安裝之後, 透過額外的啟動及卸載設定, 讓安裝套件可以在不同的 Windows 操作系統中使用.
Windows 環境 Python3 安裝
- 安裝 Python 3.4, 選擇不安裝 pip
- 利用 python get-pip.py, 安裝 pip
- 安裝 PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x64.exe https://www.riverbankcomputing.com/software/pyqt/download5
- 下載 Leo Editor 原始碼, https://github.com/leo-editor/leo-editor/releases/tag/broke-abbrev 利用 pip install broke-abbrev.zip 安裝 Leo Editor
可攜 Python3.4 設定
建立 data 目錄, 並在 data 目錄中建立 home, tmp, apps, Python34, SciTE 等子目錄, 其中 Python34 來自 C:\Python34, SciTE 也是安裝後直接複製到 data 目錄中.
將 lanuchLeo.py 存到 data/apps 目錄中, 用來啟動 Leo Editor
1 2 3 4 5 6 | """ Leo launcher script A minimal script to launch leo. """ import leo.core.runLeo leo.core.runLeo.run() |
啟動與關閉可攜系統的 start.bat 與 stop.bat 設定碼如下:
start.bat 設定
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | @echo off REM 設定 V 硬碟代號與 data 目錄對應 set Disk=y subst %Disk%: "data" REM 設定 leo 相關對應 Home 位置 set HomePath=%Disk%:\home set HomeDrive=%Disk%:\home set Home=%Disk%:\home REM 設定 Leo 所用的編輯器 set LEO_EDITOR=%Disk%:\SciTE\SciTE.exe REM 將後續的指令執行, 以 %Disk% 為主 %Disk%: REM 設定 PYTHONPATH set PYTHONPATH=%Disk%:\Python34 REM Jupyter 設定 set JUPYTER_CONFIG_DIR=%Disk%:\home\.jupyter\profile_nbserver REM 設定 Jre 路徑, 特別注意 CLASSPATH 後的分號, 一定要有 set JAVA_HOME=%Disk%:\Java\jre1.8.0_51 set CLASSPATH=.; REM 設定 node.js 相關路徑 set NODE_PATH=%Disk%:\nodejs\node_modules\npm\node_modules;%Disk%:\nodejs\node_modules\npm set path1=%PATH%;%Disk%:\Python34;%Disk%:\Anaconda3\Scripts;%JAVA_HOME%\bin;%Disk%:\nodejs; set path2=%Disk%:\apps\Git\bin;%Disk%:\apps\pandoc;%Disk%:\apps\portableLatex\MiKTeX\texmf\miktex\bin; path=%path1%;%path2%; REM 啟動 SciTE start /MIN %Disk%:\SciTE\SciTE.exe REM 取 IPV4 IP address for /f "delims=[] tokens=2" %%a in ('ping -4 %computername% -n 1 ^| findstr "["') do (set thisip=%%a) REM echo %thisip% REM 取 IPV6 IP address REM for /f "delims=[] tokens=2" %%a in ('ping %computername% -n 1 ^| findstr "["') do (set thisip=%%a) REM echo %thisip% REM 啟動 Jupyter cd %Disk%:\tmp start %Disk%:\Python34\python.exe "%Disk%:\Python34\Scripts\jupyter-script.py" notebook --ip=%thisip% --certfile=%Disk%:\home\ssl_cert.pem --profile=nbserver cd .. REM 啟動 VMEmulator REM start %Disk%:\apps\nand2tetris\tools\VMEmulator.bat REM 啟動 Assembler REM start %Disk%:\apps\nand2tetris\tools\Assembler.bat REM 啟動 CPUEmulator REM start %Disk%:\apps\nand2tetris\tools\CPUEmulator.bat REM 啟動 HardwareSimulator REM start %Disk%:\apps\nand2tetris\tools\HardwareSimulator.bat REM 啟動 JackCompiler REM start %Disk%:\apps\nand2tetris\tools\JackCompiler.bat REM 啟動 TextComparer REM start %Disk%:\apps\nand2tetris\tools\TextComparer.bat REM 啟動 node.js REM 啟動 node.js REM start /MIN cmd.exe /k "%Disk%:\nodejs\nodejsvars.bat" REM start %Disk%:\nodejs\node.exe start /MIN cmd.exe start /MIN cmd.exe start /MIN cmd.exe REM 啟動 node.js REM start %Disk%:\IDE\nodejs\node.exe REM C:\WINDOWS\system32\cmd.exe /k %Disk%:\IDE\nodejs\nodejsvars.bat REM 啟動 Leo 編輯器 python.exe %Disk%:\apps\launchLeo.py Exit |
stop.bat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | @echo off set Disk=y REM 關閉 nginx REM taskkill /IM nginx.exe /F REM 關閉 SciTE taskkill /IM SciTE.exe /F REM 關閉 python taskkill /IM python.exe /F REM 清除 log 資料 path=%PATH%; REM del /Q /F Y:\tmp\*.* REM copy Y:\www\cmsimplexh_20130809\cmsimple\log_clean.txt V:\www\cmsimpleSpring2013\cmsimple\log.txt REM del /Q /F Y:\tmp\*.* REM 終止虛擬硬碟與目錄的對應 subst %Disk%: /D REM 關閉 cmd 指令視窗 taskkill /IM cmd.exe /F EXIT |
當然也可以直接下載以 Python 3.3 建立的 Windows 可攜式 Leo Editor: https://github.com/chiamingyen/portable_leoeditor
Comments
comments powered by Disqus