'''
12/2/24
HMPy_EventObject
'''
# QT Designer interface
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow,QMessageBox,QDialog
from PyQt5.uic import loadUi
from PyQt5.QtCore import QTimer
#...threading
import threading
from threading import Event
from threading import Thread
import queue #FIFO Lib
import sys
import datetime
import time
from time import sleep
class MainUIxy(QMainWindow):
def __init__(self):
super(MainUIxy, self).__init__()
loadUi("myTestQt5.ui", self) # Load the UI file
#self.pushButtonXHome.clicked.connect(qt1XHomeAxis)
self.XJOG_PB.clicked.connect(qt2XJOGAxis)
#self.ThreadON_PB.clicked.connect(qt3Thread_ON)
self.ThreadOFF_PB.clicked.connect(qt4Thread_OFF)
#self.PBStartTimer.clicked.connect(qt5StarTimerCallBack)
self.QtLabel1.setText("hello")
def qt1XHomeAxis():
print("1XHomeAxis\n")
def qt2XJOGAxis(): #
print("2XJOG-test reqested \n")
def qt3Thread_ON():
print("3thread requested\n")
def qt4Thread_OFF():
print("4thread OFF\n")
def qt5StarTimerCallBack():
print("5StatTimerCallBack")
# Runnning app
if __name__ == "__main__":
# initializing the event object
print("running main")
event_object = threading.Event()
app = QApplication(sys.argv)
ui = MainUIxy()
ui.show()
app.exec_()
HMPy_Qt5_1.py
date 12/1/24
Ref. https://www.youtube.com/watch?v=RxGlB9U64fg
'''
#Test if pqyt5 is actually installed
#Create a new file, example.py, and enter the following code.
import sys
from PyQt5.uic import loadUi
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow,QMessageBox
class WelcomeScreen(QMainWindow):
def __init__(self):
super(WelcomeScreen,self).__init__()
loadUi("Welcomescree.ui",self)
if __name__ == "__main__":
app = QApplication(sys.argv) # create an App application and pass arg
ui = WelcomeScreen() # create an object from the class
ui.show()
app.exec_()
REFERENCE
12/2/2024
../
search <pyuic5> and add this path variables
C:\Users\hmill\PycharmProjects\HM_python0927-1\venv\Scripts
C:\Users\hmill\PycharmProjects\HM_python0927-1\venv\Scripts
pyuic5
https://sites.google.com/d/1M1BZQJjx3a6PMw3bR6nwpyiQuwGTdPkp/p/1SPoLCAkjrsX1HA3Q2oBnjHb2NVFSslH1/edit
../
self.error.setText("try it again")
self.QtLabel1.setText("hello")
../
PyQt5.wic
../
PyQt5 FULL Modern Gui Tutorial #1 - Welcome Screen [for beginners]
https://www.youtube.com/watch?v=RxGlB9U64fg
12/1/24
HMPy_Qt5_1.py
C:\Users\hmill\PycharmProjects\HM_python0927-1
../
../
https://pypi.org/project/PyQt5Designer/
pip install PyQt5Designer-5.14.1-py3-none-win_amd64.whl
./
PyQt5 Tutorial - Setup and a Basic GUI Application
https://www.youtube.com/watch?v=Vde5SH8e1OQ&list=PLzMcBGfZo4-lB8MZfHPLTEHO9zJDDLpYj
PyQt5Designer
../
Talentedcommunity.org@gmail.com
'''
HMPy_Qt5_1.py
date 12/1/24
'''
#Test if pqyt5 is actually installed
#Create a new file, example.py, and enter the following code.
import sys
from PyQt5.uic import loadUi
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow,QMessageBox
class WelcomeScreen(QMainWindow):
def __init__(self):
super(WelcomeScreen,self).__init__()
loadUi("Welcomescree.ui",self)
if __name__ == "__main__":
app = QApplication(sys.argv)
ui = WelcomeScreen()
ui.show()
app.exec_()
es from qt designer
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow
from PyQt5.uic import loadUi
import sys
class MainUI(QMainWindow):
def __init__(self):
super(MainUI,self).__init__()
loadUi("test1.ui",self)
if __name__ == "__main__":
app = QApplication(sys.argv)
ui = MainUI()
ui.show()
app.exec_()
../
https://www.youtube.com/watch?v=FVpho_UiDAY&list=PLzMcBGfZo4-lB8MZfHPLTEHO9zJDDLpYj&index=3
../
work dir
C:\Users\hmill\PycharmProjects\HM_python0927-1
file QtHM_Test120124.ui
1.
install tools
>pip install pyqt5-tools
pip.exe install pyqt5-tools~=5.15
2. search for site-packages
ppqt5-tools
C:\Users\hmill\PycharmProjects\HM_python0927-1\venv\Lib\site-packages
make short cut for qt designer
C:\Users\hmill\PycharmProjects\HM_python0927-1\venv\Lib\site-packages\QtDesigner
3.
C:\Users\hmill\PycharmProjects\HM_python0927-1>pyuic5
'pyuic5' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\hmill\PycharmProjects\HM_python0927-1>pip list | grep PyQt5
'grep' is not recognized as an internal or external command,
operable program or batch file.
pyuic5 -x your_ui_file.ui -o your_output_file.py
-x flag tells pyuic5 to generate an executable Python file.
your_ui_file.ui is the path to your Qt Designer UI file.
-o flag specifies the output Python file.
..//
../
../
https://www.youtube.com/watch?v=Vde5SH8e1OQ&list=PLzMcBGfZo4-lB8MZfHPLTEHO9zJDDLpYj&index=1
../
QtDesigner tutorial for Complete Beginners - Overview of PyQt5 QtDesigner + 3 Ways to Load UI Files..
16:55 Method 2 - Load UI file into Python using loadUi
https://www.youtube.com/watch?v=tJQdfwAohlw&t=95s
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow
import sys
def window():
app = QApplication(sys.argv)
win =QMainWindow()
win.setGeometry(1200,400,500,500)
win.setWindowTitle('July25,2024')
label =QtWidgets.QLabel(win)
label.setText('first label')
label.move(50,50)
win.show()
sys.exit(app.exec_())
window()
@author: admin
"""
import sys
#from PyQt5.QtGui import *
#from PyQt5.QtCore import *
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow,QMessageBox
def window():
app = QApplication(sys.argv)
w = QMainWindow()
b = QtWidgets.QPushButton(w)
b.setText("Show message!")
b.move(50,50)
b.clicked.connect(showdialog)
w.setWindowTitle("PyQt Dialog demo")
w.show()
sys.exit(app.exec_())
def showdialog():
msg = QtWidgets.QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setText("This is a message box")
msg.setInformativeText("This is additional information")
msg.setWindowTitle("MessageBox demo")
msg.setDetailedText("The details are as follows:")
msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
msg.buttonClicked.connect(msgbtn)
retval = msg.exec_()
#print("value of pressed message box button:", retval)
def msgbtn(i):
print("Button pressed is:",i.text())
if __name__ == '__main__':
window()
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow,QMessageBox
from PyQt5.uic import loadUi
import sys
def AlphaClick(self):
msgBox = QMessageBox()
msgBox.setStandardButtons(QMessageBox.Close)
restartBtn = msgBox.addButton('play again', QMessageBox.ActionRole)
changeBtn = msgBox.addButton('change cards', QMessageBox.ActionRole)
ret = msgBox.exec()
class MainUI(QMainWindow):
def __init__(self):
super(MainUI,self).__init__()
loadUi("test1.ui",self)
self.Button1.clicked.connect(AlphaClick)
if __name__ == "__main__":
app = QApplication(sys.argv)
ui = MainUI()
ui.show()
app.exec_()
#self.Button1.clicked.connect(self.AlphaClick)
#self.pushButton_2.clicked.connect(Lambda:self.sayit((self.textEdit.toPlainText())
self.pushButton.clicked.connect(self.AlphaClick)
self.pushButton_2.clicked.connect(Lambda:self.sayit((self.textEdit.toPlainText())
def AlphaClick(self):
print("hello")
message =QMessageBox()
message.setText("hello HM")
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow
import sys
def window():
app = QApplication(sys.argv)
win =QMainWindow()
win.setGeometry(1200,400,500,500)
win.setWindowTitle('July25,2024')
label =QtWidgets.QLabel(win)
label.setText('first label')
label.move(50,50)
win.show()
sys.exit(app.exec_())
window()
''
# HMPython071724.py
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow
import sys
def window():
app = QApplication(sys.argv)
win =QMainWindow()
win.setGeometry(1200,400,500,500)
win.setWindowTitle('July25,2024')
label =QtWidgets.QLabel(win)
label.setText('first label')
label.move(50,50)
win.show()
sys.exit(app.exec_())
window()
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 5 17:02:22 2024
HMPython0805-2024_QMessageBox
@author: admin
"""
import sys
#from PyQt5.QtGui import *
#from PyQt5.QtCore import *
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow,QMessageBox
def window():
app = QApplication(sys.argv)
w = QMainWindow()
b = QtWidgets.QPushButton(w)
b.setText("Show message!")
b.move(50,50)
b.clicked.connect(showdialog)
w.setWindowTitle("PyQt Dialog demo")
w.show()
sys.exit(app.exec_())
def showdialog():
msg = QtWidgets.QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setText("This is a message box")
msg.setInformativeText("This is additional information")
msg.setWindowTitle("MessageBox demo")
msg.setDetailedText("The details are as follows:")
msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
msg.buttonClicked.connect(msgbtn)
retval = msg.exec_()
#print("value of pressed message box button:", retval)
def msgbtn(i):
print("Button pressed is:",i.text())
if __name__ == '__main__':
window()
../
QtDesigner tutorial for Complete Beginners -
Overview of PyQt5 QtDesigner + 3 Ways to Load UI Files
https://www.youtube.com/watch?v=tJQdfwAohlw&t=1160s
Convert GUI App to Real Program - Python to exe to setup wizard
https://www.youtube.com/watch?v=p3tSLatmGvU
../
Python GUI Development Using PyQt5
https://www.youtube.com/watch?v=MOItX2aKTGc&t=969s
15:00
Python GUI Development Using PyQt5
https://www.youtube.com/watch?v=MOItX2aKTGc&t=969s
../
''Ref
PyQt5 Tutorial - How to Use Qt Designer
https://www.youtube.com/watch?v=FVpho_UiDAY
../
PyQt5 Tutorial - Setup and a Basic GUI Application
https://www.youtube.com/watch?v=Vde5SH8e1OQ
.../
PyQt5 Tutorial - Buttons and Events (Signals)
https://www.youtube.com/watch?v=-2uyzAqefyE
# HMPython071724.py
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow
import sys
def window():
app = QApplication(sys.argv)
win =QMainWindow()
win.setGeometry(1200,400,500,500)
win.setWindowTitle('July25,2024')
label =QtWidgets.QLabel(win)
label.setText('first label')
label.move(50,50)
win.show()
sys.exit(app.exec_())
window()
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QApplication,QMainWindow,QMessageBox
from PyQt5.uic import loadUi
import sys
def AlphaClick(self):
msgBox = QMessageBox()
msgBox.setStandardButtons(QMessageBox.Close)
restartBtn = msgBox.addButton('play again', QMessageBox.ActionRole)
changeBtn = msgBox.addButton('change cards', QMessageBox.ActionRole)
ret = msgBox.exec()
class MainUI(QMainWindow):
def __init__(self):
super(MainUI,self).__init__()
loadUi("test1.ui",self)
self.Button1.clicked.connect(AlphaClick)
if __name__ == "__main__":
app = QApplication(sys.argv)
ui = MainUI()
ui.show()
app.exec_()
#self.Button1.clicked.connect(self.AlphaClick)
#self.pushButton_2.clicked.connect(Lambda:self.sayit((self.textEdit.toPlainText())