PySide2 GUI

这个自动化脚本将帮助你使用 PySide2 Gui 模块创建你的 GUI 应用程序。

你可以在下面找到开始开发体面的现代应用程序所需的每种方法。

PySide2 还支持跨平台,对开发人员非常友好,请查看下面的代码。

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126


# PySide 2 


# pip install PySide2


from PySide6.QtWidgets import *


from PySide6.QtGui import *


import sys


app = QApplication(sys.argv)


window = QWidget()


# Resize the Window


window.resize(500, 500)


# Set the Window Title


window.setWindowTitle("PySide2 Window")


# Add Buttons


button = QPushButton("Click Me", window)


button.move(200, 200)


# Add Label Text


label = QLabel("Hello Medium", window)


label.move(200, 150)


# Add Input Box


input_box = QLineEdit(window)


input_box.move(200, 250)


print(input_box.text())


# Add Radio Buttons


radio_button = QRadioButton("Radio Button", window)


radio_button.move(200, 300)


# Add Checkbox


checkbox = QCheckBox("Checkbox", window)


checkbox.move(200, 350)


# Add Slider


slider = QSlider(window)


slider.move(200, 400)


# Add Progress Bar


progress_bar = QProgressBar(window)


progress_bar.move(200, 450)


# Add Image 


image = QLabel(window)


image.setPixmap(QPixmap("image.png"))


# Add Message Box


msg = QMessageBox(window)


msg.setText("Message Box")


msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)


window.show()


sys.exit(app.exec())