马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
代码如下
- from PyQt5.QtWidgets import *
- from PyQt5.QtGui import *
- from PyQt5.QtCore import *
- import sys
- class MyWindow(QMainWindow):
- def __init__(self):
- super(MyWindow, self).__init__()
- self.setWindowTitle("图片处理")
- self.setGeometry(200, 200, 500, 400)
- self.central_widget = QWidget()
- self.setCentralWidget(self.central_widget)
- main_layout = QVBoxLayout() # 整体的垂直布局
- # 上面两个 label 的水平布局
- label_layout = QHBoxLayout()
- self.label1 = QLabel()
- label_layout.addWidget(self.label1) # 图片 1 居左
- self.label2 = QLabel()
- label_layout.addWidget(self.label2) # 图片 2 居右
- main_layout.addLayout(label_layout) # 将水平布局添加到垂直布局
- # 下面两个按钮的水平布局
- button_layout = QHBoxLayout()
- self.button1 = QPushButton("打开图片")
- self.button1.cl
复制代码 |