QMainwindowشرح ال
1. QMainWindow:-
l Methods:
You can reach for all actions of ToolBar, MenuBar using the following signals: action button.triggered.connect(slot) |
addToolBar() : Add Tool Bar to the mainwindow Ex: open = QToolBar() #(open)ينشئ أداة بأسم |
setCentralWidget(self.window) :Add window to the center of mainwindow Ex: |
self.menuBar = self.menuBar():create a menue Bar Ex: self.menuBar = self.menuBar ينشأ شريط قوائم# () You can add menu to the menues of menubar then add action to it: self.menuBar = self.menuBar ينشأ شريط قوائم# () f.addAction(“Open new”)# Fileلقائمة Open newيضيف زرار أسمه f.addAction(“Open recent”)# File لقائمة Open recentيضيف زرار أسمه V.addAction(“View picture”)# View لقائمة View pictureيضيف زرار أسمه V.addAction(“View video”)# View لقائمة View videoيضيف زرار أسمه |
self.statusBar = self.statusBar():create the status Bar Ex: self.statusBar = self.statusBar() #ينشأ شريط الحالة self.statusBar.showMessage("This is an status message.",زمن الظهور)يظهر رسالة ع الشريط label = QLabel("permanent status")لعرض نص# QLabel ينشأ self.statusBar.addPermanentWidget(label)علي شريط الحالة#QLabel يعرض ال |
self.close() #يغلق النافذة self.showMinimized()يصغر النافذة# self.showNormal()يرجع النافذة لحجمها العادي( لو كانت كبيرة)# self.showFullScreen()يكبر النافذة للحجم الكامل للشاشة# self.setWindowFlag(Qt.FramelessWindowHint) من النافذة# تزيل شريط العنوان self.setWindowFlag(Qt.WindowStaysOnTopHint)#تخلي النافذة دائما أعلي التطبيقات الأخري self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)أكثر من تعديل في نفس الوقت# |
Example:
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QLabel, QDesktopWidget,QToolBar
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super().__init__(parent)
# Menu Bar Settings
self.menuBar = self.menuBar()
self.menuBar.addAction("File")
self.menuBar.addAction("View")
# Toolbars
open = QToolBar()
open.addAction("OPen")
self.addToolBar(open)
close = QToolBar()
close.addAction("Close")
self.addToolBar(close)
# Central Component Settings
self.window = QWidget()
self.setCentralWidget(self.window)
# Status Bar Settings
self.statusBar = self.statusBar()
self.statusBar.showMessage("This is an status message.", 5000)
label = QLabel("permanent status")
self.statusBar.addPermanentWidget(label)
self.resize(800, 600)
self.setWindowTitle("MainWindow Demo")
self.center()
def center(self):
screen = QDesktopWidget().screenGeometry()
size = self.geometry()
self.move((screen.width() - size.width()) / 2, (screen.height() - size.height()) / 2)
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
قم بتنزيل الصورة في الأسفل وتكبيرها لتري نص المقال بشكل أوضح
Comments
Post a Comment