顯示具有 python 標籤的文章。 顯示所有文章
顯示具有 python 標籤的文章。 顯示所有文章

2020年2月14日

py compile pyc

 https://medium.com/pyladies-taiwan/python-%E5%B0%87python%E6%89%93%E5%8C%85%E6%88%90exe%E6%AA%94-32a4bacbe351


sudo pip3 install pyinstaller
 
windows 
pyinstaller -F .\hello.py
  
linux 
python3 -m compileall file.py


常用參數介紹

1. pyinstaller -h 來查看參數
2. -F 打包成一個exe文件
3. --icon=圖標路徑
4. -w 使用視窗,無控制台
5. -c 使用控制台,無視窗
6. -D 創建一個目錄,包含exe以及其他一些依賴性文件

2020年1月28日

qt5程式設計師

安裝
sudo apt-get install qt5-default
sudo apt-get install qttools5-dev-tools
sudo pip3 install pyqt5
 
存檔為.ui
ui轉py
pyuic5 UI.ui -o UI.py
pyuic5 MyUI.ui > myui.py 

執行秀UI,編輯另一個py檔內容如下
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from myui import Ui_Form #myui 是你的.py檔案名字

class AppWindow(QDialog):
    def __init__(self):
         super().__init__()
    self.ui = Ui_Dialog()  #Ui_Dialog是myui.py裡面的class名稱
    self.ui.setupUi(self)
    self.show()

app = QApplication(sys.argv)
w = AppWindow()
w.show()
sys.exit(app.exec_())
 

2019年11月17日

python arduino 記事

https://pypi.org/project/pyFirmata/
韌體要燒入範例檔standfirmata

install pyfirmata

git clone https://github.com/tino/pyFirmata
cd pyFirmata
sudo python3 setup.py install
 
sudo pip3 install pyfirmata


python3
//載入
from pyfirmata import Arduino, util

board = Arduino('/dev/ttyUSB0')
//讀取類比信號A0
it = util.Iterator(board)
it.start()
board.analog[0].enable_reporting()
board.analog[0].read()
 
//寫入數位信號D13
board.digital[13].write(1)