Skip to content

Commit 2f77ce8

Browse files
committed
add 25
1 parent 39f3d1a commit 2f77ce8

File tree

5 files changed

+109
-1
lines changed

5 files changed

+109
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@
4040

4141
* p23_自适应布局 [博文地址](https://xugaoxiang.com/2022/03/21/pyqt5-23-auto-fit-windows/)
4242

43-
* p24_QMessageBox按钮自定义 [源码下载](p24_QMessageBox自定义按钮) [博文地址](https://xugaoxiang.com/2022/04/10/pyqt5-24-qmessagebox-button-customization/)
43+
* p24_QMessageBox按钮自定义 [源码下载](p24_QMessageBox自定义按钮) [博文地址](https://xugaoxiang.com/2022/04/10/pyqt5-24-qmessagebox-button-customization/)
44+
45+
* p25_图片自适应label控件大小 [源码下载](p25_图片自适应label控件大小) [博文地址](https://xugaoxiang.com/2022/04/10/pyqt5-25-image-scale/)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import sys
2+
3+
from PyQt5.QtWidgets import QMainWindow, QApplication
4+
from PyQt5.QtGui import QPixmap
5+
6+
from ui import Ui_MainWindow
7+
8+
9+
class MainWindow(QMainWindow, Ui_MainWindow):
10+
11+
def __init__(self, parent=None):
12+
super(MainWindow, self).__init__(parent)
13+
self.setupUi(self)
14+
15+
pix = QPixmap('wechat.jpg')
16+
self.label.setScaledContents(True)
17+
self.label.setPixmap(pix)
18+
19+
if __name__ == '__main__':
20+
app = QApplication(sys.argv)
21+
windows = MainWindow()
22+
windows.show()
23+
sys.exit(app.exec_())
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>MainWindow</class>
4+
<widget class="QMainWindow" name="MainWindow">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>800</width>
10+
<height>600</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>MainWindow</string>
15+
</property>
16+
<widget class="QWidget" name="centralwidget">
17+
<layout class="QGridLayout" name="gridLayout">
18+
<item row="0" column="0">
19+
<widget class="QLabel" name="label">
20+
<property name="text">
21+
<string/>
22+
</property>
23+
<property name="alignment">
24+
<set>Qt::AlignCenter</set>
25+
</property>
26+
</widget>
27+
</item>
28+
</layout>
29+
</widget>
30+
<widget class="QMenuBar" name="menubar">
31+
<property name="geometry">
32+
<rect>
33+
<x>0</x>
34+
<y>0</y>
35+
<width>800</width>
36+
<height>26</height>
37+
</rect>
38+
</property>
39+
</widget>
40+
<widget class="QStatusBar" name="statusbar"/>
41+
</widget>
42+
<resources/>
43+
<connections/>
44+
</ui>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Form implementation generated from reading ui file '.\project.ui'
4+
#
5+
# Created by: PyQt5 UI code generator 5.9.2
6+
#
7+
# WARNING! All changes made in this file will be lost!
8+
9+
from PyQt5 import QtCore, QtGui, QtWidgets
10+
11+
class Ui_MainWindow(object):
12+
def setupUi(self, MainWindow):
13+
MainWindow.setObjectName("MainWindow")
14+
MainWindow.resize(800, 600)
15+
self.centralwidget = QtWidgets.QWidget(MainWindow)
16+
self.centralwidget.setObjectName("centralwidget")
17+
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
18+
self.gridLayout.setObjectName("gridLayout")
19+
self.label = QtWidgets.QLabel(self.centralwidget)
20+
self.label.setText("")
21+
self.label.setAlignment(QtCore.Qt.AlignCenter)
22+
self.label.setObjectName("label")
23+
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
24+
MainWindow.setCentralWidget(self.centralwidget)
25+
self.menubar = QtWidgets.QMenuBar(MainWindow)
26+
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
27+
self.menubar.setObjectName("menubar")
28+
MainWindow.setMenuBar(self.menubar)
29+
self.statusbar = QtWidgets.QStatusBar(MainWindow)
30+
self.statusbar.setObjectName("statusbar")
31+
MainWindow.setStatusBar(self.statusbar)
32+
33+
self.retranslateUi(MainWindow)
34+
QtCore.QMetaObject.connectSlotsByName(MainWindow)
35+
36+
def retranslateUi(self, MainWindow):
37+
_translate = QtCore.QCoreApplication.translate
38+
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
39+
37.9 KB
Loading

0 commit comments

Comments
 (0)