Hello Python Developer!
How are you? Hope you're in the best condition today. Because we will exercise PyQt WIndow setup.
-PyQt wIndow Size adjustment
import sys
from PyQt5.QtWidgets import *
class MyWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setGeometry(200,200,400,300)
app = QApplication(sys.argv)
window = MyWindow()
window.show()
app.exec_()
Github source : https://github.com/Cevastian/Python-Developer-start-today/commit/60eace260260cd57268f5aac9a89842154bd8ddf
Python codes running result
- PyQt titlebar & icon setting
* Note : An icon file "PyQt window sample icon.png" must be in the same folder with this Python code.
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
class MyWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setGeometry(200,200, 300,150)
self.setWindowTitle("PyQt exercise")
self.setWindowIcon(QIcon("PyQt window sample icon.png"))
app = QMainWindow(sys.argv)
window = MyWindow()
window.show()
app.exec_()
Github source : https://github.com/Cevastian/Python-Developer-start-today/commit/4f5d241ae501ad4b003c0a361dfa91eee269b88c
Python codes running result
Have you checked above PyQt exercise sample Python codes? Great job!
Let's learn more about PyQt window setup!
No comments:
Post a Comment