mirror of
https://github.com/maicss/PyQt5-Chinese-tutorial.git
synced 2025-01-08 17:06:18 +08:00
修改图片路径
This commit is contained in:
parent
2eb5c00a36
commit
f8679f8d27
@ -2,7 +2,7 @@
|
||||
|
||||
* [欢迎](README.md)
|
||||
* [pyqt6](pyqt6/README.md)
|
||||
* [index](pyqt6/index.md)
|
||||
* [开始](pyqt6/index.md)
|
||||
* [PyQt6 简介](pyqt6/introduction.md)
|
||||
* [PyQt6 日期和时间](pyqt6/datetime.md)
|
||||
* [PyQt6 的第一个程序](pyqt6/firstprograms.md)
|
||||
|
@ -73,7 +73,7 @@ lbl1.move(15, 10)
|
||||
|
||||
程序展示:
|
||||
|
||||
![Absolute positioning](.gitbook/assets/3-absolute.png)
|
||||
![Absolute positioning](images/3-absolute.png)
|
||||
|
||||
## 盒布局
|
||||
|
||||
@ -172,7 +172,7 @@ self.setLayout(vbox)
|
||||
|
||||
程序预览:
|
||||
|
||||
![buttons](.gitbook/assets/3-buttons.png)
|
||||
![buttons](images/3-buttons.png)
|
||||
|
||||
## 栅格布局
|
||||
|
||||
@ -276,7 +276,7 @@ for position, name in zip(positions, names):
|
||||
|
||||
程序预览:
|
||||
|
||||
![Calculator skeleton](.gitbook/assets/3-calculator.png)
|
||||
![Calculator skeleton](images/3-calculator.png)
|
||||
|
||||
## 制作提交反馈信息的布局
|
||||
|
||||
@ -363,5 +363,5 @@ grid.addWidget(reviewEdit, 3, 1, 5, 1)
|
||||
|
||||
程序预览:
|
||||
|
||||
![review example](.gitbook/assets/3-review.png)
|
||||
![review example](images/3-review.png)
|
||||
|
||||
|
@ -62,7 +62,7 @@ self.statusBar().showMessage('Ready')
|
||||
|
||||
调用`QtGui.QMainWindow`类的`statusBar()`方法,创建状态栏。第一次调用会创建一个状态栏,而再次调用会返回一个状态栏对象。`showMessage()`方法在状态栏上显示一条信息。
|
||||
|
||||
程序预览: ![status](.gitbook/assets/2-status.png)
|
||||
程序预览: ![status](images/2-status.png)
|
||||
|
||||
## 菜单栏
|
||||
|
||||
@ -145,7 +145,7 @@ fileMenu.addAction(exitAct)
|
||||
|
||||
`menuBar()`创建菜单栏。这里创建了一个菜单栏,并用`addMenu()`在上面添加了一个file菜单,用`addAction()`关联了点击退出应用的事件。
|
||||
|
||||
程序预览: ![menu](.gitbook/assets/2-menu.png)
|
||||
程序预览: ![menu](images/2-menu.png)
|
||||
|
||||
## 子菜单
|
||||
|
||||
@ -217,7 +217,7 @@ impMenu.addAction(impAct)
|
||||
|
||||
使用`addAction()`添加一个动作。
|
||||
|
||||
程序预览: ![submenu](.gitbook/assets/2-submenu.png)
|
||||
程序预览: ![submenu](images/2-submenu.png)
|
||||
|
||||
## 勾选菜单
|
||||
|
||||
@ -307,7 +307,7 @@ def toggleMenu(self, state):
|
||||
|
||||
依据选中状态切换状态栏的显示与否。 程序预览:
|
||||
|
||||
![checkmenu](.gitbook/assets/2-checkmenu.png)
|
||||
![checkmenu](images/2-checkmenu.png)
|
||||
|
||||
## 右键菜单
|
||||
|
||||
@ -382,7 +382,7 @@ if action == quitAct:
|
||||
|
||||
程序预览:
|
||||
|
||||
![contextmenu](.gitbook/assets/2-contextmenu.png)
|
||||
![contextmenu](images/2-contextmenu.png)
|
||||
|
||||
## 工具栏
|
||||
|
||||
@ -456,7 +456,7 @@ self.toolbar.addAction(exitAct)
|
||||
|
||||
程序预览:
|
||||
|
||||
![toolbar](.gitbook/assets/2-toolbar.png)
|
||||
![toolbar](images/2-toolbar.png)
|
||||
|
||||
## 主窗口
|
||||
|
||||
@ -535,5 +535,5 @@ self.setCentralWidget(textEdit)
|
||||
|
||||
程序预览:
|
||||
|
||||
![mainwindow](.gitbook/assets/2-mainwindow.png)
|
||||
![mainwindow](images/2-mainwindow.png)
|
||||
|
||||
|
@ -81,7 +81,7 @@ if ok:
|
||||
|
||||
程序展示:
|
||||
|
||||
![input dialog](.gitbook/assets/5-inputdialog.png)
|
||||
![input dialog](images/5-inputdialog.png)
|
||||
|
||||
## 选取颜色
|
||||
|
||||
@ -175,7 +175,7 @@ if col.isValid():
|
||||
|
||||
程序展示:
|
||||
|
||||
![color dialog](.gitbook/assets/5-colordialog.png)
|
||||
![color dialog](images/5-colordialog.png)
|
||||
|
||||
## 选择字体
|
||||
|
||||
@ -264,7 +264,7 @@ if ok:
|
||||
|
||||
程序展示:
|
||||
|
||||
![font dialog](.gitbook/assets/5-fontdialog.png)
|
||||
![font dialog](images/5-fontdialog.png)
|
||||
|
||||
## 选择文件
|
||||
|
||||
@ -369,5 +369,5 @@ if fname[0]:
|
||||
|
||||
程序展示:
|
||||
|
||||
![file Dialog](.gitbook/assets/5-filedialog.png)
|
||||
![file Dialog](images/5-filedialog.png)
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
方块展示:
|
||||
|
||||
![tetrominoes](.gitbook/assets/11-tetrominoes.png)
|
||||
![tetrominoes](images/11-tetrominoes.png)
|
||||
|
||||
PyQt5是专门为创建图形界面产生的,里面一些专门为制作游戏而开发的组件,所以PyQt5是能制作小游戏的。
|
||||
|
||||
@ -847,7 +847,7 @@ self.coords = [[0,0] for i in range(4)]
|
||||
|
||||
坐标系示意图:
|
||||
|
||||
![coordinates](.gitbook/assets/11-coordinates.png)
|
||||
![coordinates](images/11-coordinates.png)
|
||||
|
||||
上面的图片可以帮助我们更好的理解坐标值的意义。比如元组`(0, -1), (0, 0), (-1, 0), (-1, -1)`代表了一个Z形状的方块。这个图表就描绘了这个形状。
|
||||
|
||||
@ -872,5 +872,5 @@ def rotateLeft(self):
|
||||
|
||||
程序展示:
|
||||
|
||||
![Tetris](.gitbook/assets/11-tetris.png)
|
||||
![Tetris](images/11-tetris.png)
|
||||
|
||||
|
@ -93,7 +93,7 @@ sys.exit(app.exec_())
|
||||
|
||||
程序预览:
|
||||
|
||||
![simple](.gitbook/assets/1-simple.png)
|
||||
![simple](images/1-simple.png)
|
||||
|
||||
## 例2,带窗口图标
|
||||
|
||||
@ -184,7 +184,7 @@ if __name__ == '__main__':
|
||||
|
||||
程序预览:
|
||||
|
||||
![icon](.gitbook/assets/1-icon.png)
|
||||
![icon](images/1-icon.png)
|
||||
|
||||
## 例3,提示框
|
||||
|
||||
@ -270,7 +270,7 @@ btn.move(50, 50)
|
||||
|
||||
程序预览:
|
||||
|
||||
![tooltip](.gitbook/assets/1-tooltips.png)
|
||||
![tooltip](images/1-tooltips.png)
|
||||
|
||||
## 例4,关闭窗口
|
||||
|
||||
@ -354,7 +354,7 @@ qbtn.clicked.connect(QCoreApplication.instance().quit)
|
||||
|
||||
程序预览:
|
||||
|
||||
![quitbutton](.gitbook/assets/1-quitbutton.png)
|
||||
![quitbutton](images/1-quitbutton.png)
|
||||
|
||||
## 例5,消息盒子
|
||||
|
||||
@ -435,7 +435,7 @@ else:
|
||||
|
||||
程序预览:
|
||||
|
||||
![messagebox](.gitbook/assets/1-messagebox.png)
|
||||
![messagebox](images/1-messagebox.png)
|
||||
|
||||
## 例6,窗口居中
|
||||
|
||||
@ -524,5 +524,5 @@ self.move(qr.topLeft())
|
||||
|
||||
程序预览:
|
||||
|
||||
![center](.gitbook/assets/1-center.png)
|
||||
![center](images/1-center.png)
|
||||
|
||||
|
@ -101,7 +101,7 @@ qp.drawText(event.rect(), Qt.AlignCenter, self.text)
|
||||
|
||||
程序展示:
|
||||
|
||||
![drawing text](.gitbook/assets/9-drawtext.png)
|
||||
![drawing text](images/9-drawtext.png)
|
||||
|
||||
### 点的绘画
|
||||
|
||||
@ -190,7 +190,7 @@ qp.drawPoint(x, y)
|
||||
|
||||
程序展示:
|
||||
|
||||
![points](.gitbook/assets/9-points.png)
|
||||
![points](images/9-points.png)
|
||||
|
||||
## 颜色
|
||||
|
||||
@ -279,7 +279,7 @@ qp.drawRect(10, 15, 90, 60)
|
||||
|
||||
程序展示:
|
||||
|
||||
![colours](.gitbook/assets/9-colours.png)
|
||||
![colours](images/9-colours.png)
|
||||
|
||||
### QPen
|
||||
|
||||
@ -382,7 +382,7 @@ qp.setPen(pen)
|
||||
|
||||
程序展示:
|
||||
|
||||
![pen styles](.gitbook/assets/9-penstyles.png)
|
||||
![pen styles](images/9-penstyles.png)
|
||||
|
||||
### QBrush
|
||||
|
||||
@ -489,7 +489,7 @@ qp.drawRect(10, 15, 90, 60)
|
||||
|
||||
程序展示:
|
||||
|
||||
![brushes](.gitbook/assets/9-brushes.png)
|
||||
![brushes](images/9-brushes.png)
|
||||
|
||||
### 贝塞尔曲线
|
||||
|
||||
|
@ -93,7 +93,7 @@ def changeTitle(self, state):
|
||||
|
||||
程序展示:
|
||||
|
||||
![QCheckBox](.gitbook/assets/6-qcheckbox.png)
|
||||
![QCheckBox](images/6-qcheckbox.png)
|
||||
|
||||
## 切换按钮
|
||||
|
||||
@ -230,7 +230,7 @@ self.square.setStyleSheet("QFrame { background-color: %s }" %
|
||||
|
||||
程序展示:
|
||||
|
||||
![toggle button](.gitbook/assets/6-togglebutton.png)
|
||||
![toggle button](images/6-togglebutton.png)
|
||||
|
||||
## 滑块
|
||||
|
||||
@ -334,7 +334,7 @@ if value == 0:
|
||||
|
||||
程序展示:
|
||||
|
||||
![QSlider widget](.gitbook/assets/6-qslider.png)
|
||||
![QSlider widget](images/6-qslider.png)
|
||||
|
||||
## 进度条
|
||||
|
||||
@ -463,7 +463,7 @@ def doAction(self):
|
||||
|
||||
程序展示:
|
||||
|
||||
![QProgressBar](.gitbook/assets/6-qprogressbar.png)
|
||||
![QProgressBar](images/6-qprogressbar.png)
|
||||
|
||||
## 日历
|
||||
|
||||
@ -555,5 +555,5 @@ def showDate(self, date):
|
||||
|
||||
程序展示:
|
||||
|
||||
![calendar](.gitbook/assets/6-calendar.png)
|
||||
![calendar](images/6-calendar.png)
|
||||
|
||||
|
@ -72,7 +72,7 @@ lbl.setPixmap(pixmap)
|
||||
|
||||
程序展示:
|
||||
|
||||
![pixmap](.gitbook/assets/7-pixmap.png)
|
||||
![pixmap](images/7-pixmap.png)
|
||||
|
||||
## 行编辑
|
||||
|
||||
@ -160,7 +160,7 @@ def onChanged(self, text):
|
||||
|
||||
程序展示:
|
||||
|
||||
![QLineEdit](.gitbook/assets/7-qlineedit.png)
|
||||
![QLineEdit](images/7-qlineedit.png)
|
||||
|
||||
## QSplitter
|
||||
|
||||
@ -262,7 +262,7 @@ splitter2.addWidget(splitter1)
|
||||
|
||||
程序展示:
|
||||
|
||||
![QSplitter widget](.gitbook/assets/7-qsplitter.png)
|
||||
![QSplitter widget](images/7-qsplitter.png)
|
||||
|
||||
## 下拉选框
|
||||
|
||||
@ -359,5 +359,5 @@ def onActivated(self, text):
|
||||
|
||||
程序展示:
|
||||
|
||||
![QComboBox](.gitbook/assets/7-qcombobox.png)
|
||||
![QComboBox](images/7-qcombobox.png)
|
||||
|
||||
|
@ -85,7 +85,7 @@ sld.valueChanged.connect(lcd.display)
|
||||
|
||||
程序展示:
|
||||
|
||||
![signal & slot](.gitbook/assets/4-sigslot.png)
|
||||
![signal & slot](images/4-sigslot.png)
|
||||
|
||||
## 重构事件处理器
|
||||
|
||||
@ -252,7 +252,7 @@ def mouseMoveEvent(self, e):
|
||||
|
||||
程序展示:
|
||||
|
||||
![event object](.gitbook/assets/4-eventobject.png)
|
||||
![event object](images/4-eventobject.png)
|
||||
|
||||
## 事件发送
|
||||
|
||||
@ -336,7 +336,7 @@ def buttonClicked(self):
|
||||
|
||||
程序展示:
|
||||
|
||||
![event sender](.gitbook/assets/4-eventsender.png)
|
||||
![event sender](images/4-eventsender.png)
|
||||
|
||||
## 信号发送
|
||||
|
||||
|
@ -123,7 +123,7 @@ edit.setDragEnabled(True)
|
||||
|
||||
程序展示:
|
||||
|
||||
![drag & drop](.gitbook/assets/8-dragdrop.png)
|
||||
![drag & drop](images/8-dragdrop.png)
|
||||
|
||||
## 拖放按钮组件
|
||||
|
||||
|
@ -220,5 +220,5 @@ def changeValue(self, value):
|
||||
|
||||
拖动滑块的时候,调用了`changeValue()`方法。这个方法内部,我们自定义了一个可以传参的updateBW信号。参数就是滑块的当前位置。这个数值之后还用来于Burning组件,然后重新渲染Burning组件。
|
||||
|
||||
![burning widget](.gitbook/assets/10-burning.png)
|
||||
![burning widget](images/10-burning.png)
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
Python PyQt6
|
||||
最后更新于 2021.05.18
|
||||
# Python PyQt6
|
||||
*最后更新于 2021.05.18*
|
||||
|
||||
这是一个 PyQt6 教程。本教程是个初、中级教程,学完本教程后,您可以编写一个非常不错的 PyQt6 应用。代码示例在作者的 Github 仓库 [PyQt6-Tutorial-Examples](https://github.com/janbodnar/PyQt6-Tutorial-Examples)。
|
||||
|
||||
|
||||
一本涵盖 PyQt5 库的高级特性的电子书: [Advanced PyQt5 e-book](https://zetcode.com/ebooks/advancedpyqt5/).
|
||||
|
||||
相关教程
|
||||
## 相关教程
|
||||
|
||||
[PyQt5 tutorial](https://zetcode.com/gui/pyqt5/) 是介绍了上个版本的 PyQt 。
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user