2025年2月1日 星期六

Python GUI - - PyQt6 (Ubuntu 24) 學習筆記(二)

 Python GUI - - PyQt6 (Ubuntu 24) 學習筆記(二) 


 感覺在 Windows 10 環境使用太辛苦了,Windows Defender 一直擋,一直發生錯誤! 

 想在 Ubuntu 環境試試 ...  


** Ubuntu 24.04 

https://ubuntu.com/desktop



Ubuntu 22.04.3 新酷音中文輸入法 安裝 紀錄

https://hackmd.io/@uoStF0JnQ2KW_h7HNvalFA/ryTtdp9pn


Angry IP Scanner - Download for Windows, Mac or Linux

https://angryip.org/download/#google_vignette


Download VNC Viewer for Linux by RealVNC

https://www.realvnc.com/en/connect/download/viewer/linux/



Python GUI - - PyQt6 

** 書本範例

https://github.com/oxxostudio/book-code/blob/master/pyqt/ch01/code01.py



** 下載並安裝 Anaconda  

安裝 Anaconda – 如何在 Ubuntu 上安裝 Anaconda







** Ubunut 中使用Anaconda Navigator GUI界面  

https://www.nmking.io/index.php/2023/05/20/1230/

開啟其實很簡單,利用命令

source ~/.bashrc
anaconda-navigator

也可以寫成.sh以後直接執行即可





使用 Anaconda Jupyter ( 選用 )   

Jupyter Notebook 完整介紹、安裝及使用說明

https://medium.com/ai-for-k12/jupyter-notebook-%E5%AE%8C%E6%95%B4%E4%BB%8B%E7%B4%B9-%E5%AE%89%E8%A3%9D%E5%8F%8A%E4%BD%BF%E7%94%A8%E8%AA%AA%E6%98%8E-846b5432f044






在終端模式(Mac/Linux) or 命令提示模式(Windows)執行下列命令,同樣可以使用Jupyter Notebook了。

jupyter notebook

您就可以開啟Jupyter Notebook





使用 Anaconda spyder ( 選用 )   






** 安裝 pycharm-community App ( 選用 )  







**  執行書上的範例, 發現 Anaconda jupyter, 與 Anaconda spyder 常常會跑不出結果..

感覺 PyCharm-Community 常常正確執行





** 安裝 Qt Designer 6 ( for Ubuntu 24 )  


This got me a working designer. Then if you create ~/.local/share/application/desginer.desktop with this contents:

[Desktop Entry]
Version=1.0
Name=Qt Designer 6
Comment=Qt Designer 6
Exec=/usr/lib/qt6/bin/designer
Icon=/home/larry/.local/share/applications/qt_designer.ico
Terminal=false
Type=Application
Categories=Utility;Application;

then:

chmod 755 designer.desktop

Now it will appear with your other applicatiions




UI 界面設計好之後, 要執行 指令:

pyuic6 -x ch04-1.ui -o ch04-1.py

可以將 *.ui 檔 轉換成 *.py 檔






** 試用結果 使用  pycharm-community 最順  

範例程式 ch07 / code09.py 讀取 *.txt 檔 , 顯示文字內容於視窗內


成功


修改 範例程式 ch07 / code09.py 為 readTXT.py 讀取 *.txt 檔,顯示文字內容 於較大的視窗內



範例程式 ch09 / code02.py 是個 計時器





安裝 pyinstaller 將 python 程式 製作成 windows 執行檔   

安裝

  • pip install pyinstaller

執行

  • pyinstaller --onefile test.py  


個人 在執行 pyinstaller 過程遇到多個錯誤,

pathlib 錯誤

objdump 錯誤

按照提示 逐一修正錯誤,重開機之後,就成功了

執行檔 輸出會放在 dist 子目錄

( 回到 win10 執行程式檔,並不能執行! )



** 安裝 py2exe 將 python 程式 製作成 windows 執行檔   

原則上,這是用一個視窗來執行 pyinstaller

You can install this project using PyPI:

$ pip install auto-py-to-exe

Then to run it, execute the following in the terminal:

$ auto-py-to-exe






執行檔 輸出會放在 ~/output 子目錄

( 回到 win10 執行程式檔,並不能執行! )



** 安裝 cx_Freeze 將 python 程式 製作成 windows 執行檔   

Installation

In a virtual environment, install by issuing the command:

pip install --upgrade cx_Freeze

To install the latest development build:

pip uninstall cx_Freeze
pip install --extra-index-url https://test.pypi.org/simple/ cx_Freeze --pre --no-cache

Please check the installation for more information and how to install in other environments.






2025-01-25

2025-01-26

2025-02-02



沒有留言:

張貼留言

Dr. Shaw YC Shiau PhD 蕭醫師 蕭博士 蕭同學 首頁 置頂文 標籤 分類搜尋

There will be Advertisement  (personalized)   inserts in Google Blog. Sorry!  谷歌 的 部落格 會有 置入廣告 (個人化的) ,請見諒!    Information Service  b...