Liberty0 / strategy_find

technical analysis and evaluate strategy with historical prices
0 stars 0 forks source link

UI design #17

Closed Liberty0 closed 3 years ago

Liberty0 commented 3 years ago

安裝pyqt pip install pyqt5 at Anaconda prompt

ERROR: spyder 3.3.6 has requirement pyqt5<5.13; python_version >= "3", but you'll have pyqt5 5.13.0 which is incompatible. Spyder require lower version PyQt pip install pyqt5==5.11.3 pip install pyqtwebengine

無法啟動spyder ↓ 在安裝Anaconda時,已經連Qt一起安裝了 路徑C:\Users\User\anaconda3\Library\bin\designer.exe

Liberty0 commented 3 years ago

建立 module

main.py mainForm | __init__.py ui | UI design.ui (PyQt 存檔)


what's in main.py

from PyQt5 import QtWidgets
from mainForm import MainUi   # 讀入Main Window
import sys

if __name__ == "__main__":
    def run_app():
        app = QtWidgets.QApplication(sys.argv)
        window = MainUi()
        window.show()
        app.exec_()
    run_app()

what's in __init__.py

from PyQt5 import QtWidgets, uic
import os

path = os.getcwd()
qtCreatorFile = path + os.sep + "ui" + os.sep + "UI design.ui"  # 設計好的ui檔案路徑
Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)   # 讀入用Qt Designer設計的GUI layout

class MainUi(QtWidgets.QMainWindow, Ui_MainWindow):  # Python的多重繼承 MainUi 繼承自兩個類別
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setupUi(self)

ref

http://elmer-storage.blogspot.com/2018/04/pyqt.html

Liberty0 commented 3 years ago

ca07a4ad099d731ad7797b52d205e69a80c7b04f gui with plot aixs built in testing2 ui_import.py mplwidget.py iu | mainwindow.ui

note - promote widget in designer

image image image

ref: https://yapayzekalabs.blogspot.com/2018/11/pyqt5-gui-qt-designer-matplotlib.html

Liberty0 commented 3 years ago

read input and print output text

def __init__(self,*args,**kwargs):
  self.textEdit.textChanged.connect(self.varinput)
def varinput(self):
  self.label.setText(self.textEdit.toPlainText())

97e4ba338158b5a72f2ce28b5203a38608dcaeee

Liberty0 commented 3 years ago

library links

search for properties (function, signals, ...) of the widgets of PyQt here Modules others than widget at here

Liberty0 commented 3 years ago

53273bb10fcf9759740e654797647b4d90ab7529