提交 4dbef20e 编写于 作者: W wizardforcel

2019-11-21 17:34:09

上级 2bde067b
......@@ -11,10 +11,6 @@ sudo apt-get install python3-pyqt5
如果您使用 Windows 或 Mac 计算机,则可以从以下网站下载 [PyQT5](https://pythonspot.com/pyqt5/)[https://www.riverbankcomputing.com/software/pyqt/download5](https://www.riverbankcomputing.com/software/pyqt/download5)
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
## PyQt5 窗口
You can create a **[PyQT5](https://pythonspot.com/pyqt5/)** window using the code below:
......
......@@ -4,10 +4,6 @@
PyQt5 支持使用 QPushButton 类的按钮。 此类在 PyQt5.QtWidgets 组中。 可以通过调用构造函数 QPushButton 并将其文本显示为参数来创建按钮。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**简介** 要将按钮用于 [PyQt5](https://pythonspot.com/pyqt5/) 应用程序,我们需要更新导入行:
```
......
......@@ -15,8 +15,6 @@ from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMessageBox
我们使用方法 **QMessageBox.question()**显示消息框。
**相关课程:** [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**PyQt5 消息框代码** 复制以下代码以显示消息框。
```
......
......@@ -6,10 +6,6 @@
我们可以使用 resize(width,height)方法设置文本框的大小。 可以使用 move(x,y)方法或使用网格布局来设置位置。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**PyQt5 文本框** 创建文本框非常简单:
```
......
......@@ -4,8 +4,6 @@
要为 [**PyQt5**](https://pythonspot.com/pyqt5/) 程序创建菜单,我们需要使用 QMainWindow。 这种类型的菜单在许多应用程序中都可见,并显示在窗口栏的正下方。 它通常具有文件和编辑子菜单。
**相关课程:** [使用 PyQt5 创建 GUI 应用程序](https://gum.co/pysqtsamples)
可以使用 menuBar()方法创建顶部菜单。 子菜单添加了 addMenu(name) 示例:
```
......
......@@ -10,10 +10,6 @@
要添加表,您将需要导入 **QTableWidget****QTableWidgetItem**
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
## [](#Example "Example")范例
```
......
......@@ -6,10 +6,6 @@
![pyqt5-tabs](img/ca67319c33ab1709f8fd3eafa79c6dfb.jpg)
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**PyQt5 标签示例** 完整 [**PyQt5**](https://pythonspot.com/pyqt5/) 标签示例:
```
......
......@@ -8,10 +8,6 @@
![pyqt5-horizontal-layout](img/b18a764c1fce5b869fc970d63229d0d9.jpg)
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**水平布局示例** 我们将显示整个代码,然后进行解释。
```
......
......@@ -6,10 +6,6 @@
![pyqt-grid-layout](img/6094d3e9eaea24f4f064dfcd2ea91ddc.jpg)
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**PyQt5 网格布局示例:** 下面的示例创建网格:
```
......
......@@ -13,10 +13,6 @@ from PyQt5.QtWidgets import QApplication, QWidget, QInputDialog, QLineEdit
![pyqt5-input-dialog](img/6872d4e6f12488af0c0f4f9c14deb773.jpg)
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**获取整数** 使用 QInputDialog.getInt()获取整数:
```
......
......@@ -6,10 +6,6 @@
需要导入 **QFileDialog**
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**文件对话框示例** 使用的方法是 QFileDialog.getOpenFileName(),QFileDialog.getOpenFileNames(),QFileDialog.getSaveFileName()。 使用方法参数可以指定默认目录,文件类型和默认文件名。
![pyqt5-open-file-dialog](img/c145c7271f700e11aa378a211bb94dff.jpg)
......
......@@ -4,10 +4,6 @@
PyQt5(和 Qt)默认情况下支持图像。 在本文中,我们将向您展示如何向窗口添加图像。 可以使用 QPixmap 类加载图像。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**PyQt5 图像简介** 将图像添加到 [PyQt5](https://pythonspot.com/pyqt5/) 窗口就像创建标签并将图像添加到该标签一样简单。
```
......
......@@ -8,10 +8,6 @@
[PyQT4](https://pythonspot.com/pyqt4/) ,它是[图形用户界面(GUI)](https://pythonspot.com/gui)编程的 Python 选项之一。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
## PyQt4 窗口示例:
This application will create a graphical window that can be minimized, maximimzed and resized it.
......
......@@ -10,10 +10,6 @@ PyQt4(Qt4)通过 QPushButton 小部件支持按钮。
如果将鼠标悬停在该按钮上将显示一个工具提示,按下该按钮将关闭程序。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
## PyQt4 按钮示例
The example below adds a button to a PyQt4 window.
......
......@@ -4,8 +4,6 @@
[PyQT4](https://pythonspot.com/pyqt4/) 使用多种功能提供消息框功能。 [PyQT4](https://pythonspot.com/pyqt4/) 中包含的 消息框是:问题,警告,错误,信息,批评和关于框。
**相关课程:** [使用 Python PyQt5 创建 GUI 应用程序](https://gum.co/pysqtsamples)
## PyQt4 消息框
The code below will display a message box with two buttons:
......
......@@ -10,10 +10,6 @@ QMainWindow 类创建主应用程序窗口。 此类具有一个名为 menuBar
可以使用 addMenu()将菜单添加到标题栏。 在每个菜单内,您都可以使用 addAction 方法添加命令。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
## PyQt4 菜单栏
This code will add a menu to your qt4 app:
......
......@@ -10,8 +10,6 @@
For more widgets we suggest using the GUI creation tool covered in the next tutorial.
**相关课程:** [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**文本框小部件** 几乎每个应用程序中都存在输入字段。 在 [PyQT4](https://pythonspot.com/pyqt4/) 中,可以使用 QLineEdit()函数创建输入字段。
```
......
......@@ -8,10 +8,6 @@
如果要在文本框(QLineEdit)中显示文本,则可以使用 setText()方法。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
## PyQt4 QLineEdit
The textbox example below changes the text if the button is pressed.
......
......@@ -4,10 +4,6 @@
我们可以使用 QTableWidget 来显示表格,QTableWidget 是 [PyQt](https://pythonspot.com/pyqt4/) 模块的一部分。 我们设置标题,行数,列数并添加数据。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
## Qt4 表示例
An example below:
......
......@@ -11,10 +11,6 @@ tabs.addTab(tab1,"Tab 1")
其中第一个参数是选项卡对象,第二个参数是显示在屏幕上的名称。 我们在第一个标签(QWidget)中添加了一些按钮。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**示例代码:**
```
......
......@@ -4,10 +4,6 @@
在本文中,我们将演示如何使用 progressbar 小部件。 进度栏与其他小部件的不同之处在于,它会及时更新。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**QT4 进度栏示例** 让我们从代码开始:
```
......
......@@ -6,10 +6,6 @@
![PyQt4-load-image](img/77d7b4598127e8b587d29da009865dde.jpg) An image loaded in a PyQt4 window.
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
## 介绍
The constructor of Pixmap takes the image path as parameter:
......
......@@ -4,10 +4,6 @@
在这个简短的教程中,您将学习如何创建文件对话框并加载其文件内容。 使用文件访问的许多应用程序都需要文件对话框。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
**文件对话框示例** 要在 [PyQT](https://pythonspot.com/pyqt4/) 中获取文件名(而非文件数据),可以使用以下行:
```
......
......@@ -4,10 +4,6 @@
在本教程中,我们将教您如何使用 [PyQT4](https://pythonspot.com/pyqt4/) 创建图形应用程序。 这可以在支持 [PyQT4](https://pythonspot.com/pyqt4/) 的任何平台上使用,包括 Windows,Linux,UNIX,Android,OS X 和 iOS。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
## PyQt4 安装
PyQt does not include Qt itself – you may have to obtain it separately. The homepage for PyQt is [https://www.riverbankcomputing.com/software/pyqt/](https://www.riverbankcomputing.com/software/pyqt/).
......
......@@ -4,10 +4,6 @@
如果您尚未完成我们的[第一个 PyQT 教程](https://pythonspot.com/building-an-application-gui-with-pyqt-beginners-tutorial/),则应该这样做,这很有趣! 在本教程中,我们将使用 [PyQT4](https://pythonspot.com/pyqt4/) 和用户界面标记语言,该语言描述图形用户界面和控件。
**相关课程:**
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
## QML 和 PyQT
An excerpt of user interface markup [graphical user interfaces](https://pythonspot.com/gui/) and language code could look like:
......
......@@ -21,10 +21,6 @@ mainloop()
![tk button](img/b1fb57a653c6741ced779c294ca87447.jpg) tk button
**相关课程**
* [带有 Tkinter 的 Python 桌面应用](https://gum.co/ErLc)
**Tk 图像按钮** 如果需要图像按钮,请使用 PhotoImage 类。 我们使用函数 minsize()和 geometry()设置窗口的大小和最小大小。 例:
```
......
......@@ -8,10 +8,6 @@ Tkinter 工具箱包含所有用于创建图形应用程序的基本小部件。
![tk menu](img/ec69b97f82c9ef2d0bac39c941f21ed9.jpg) Tkinter menu
**相关课程**
* [带有 Tkinter 的 Python 桌面应用](https://gum.co/ErLc)
## Tkinter 菜单栏
You can create a simle menu with [Tkinter](https://pythonspot.com/tkinter/) using the code below. Every option (new, open, save.. ) should have its own callback.
......
......@@ -11,10 +11,6 @@
在本文中,我们将展示如何使用其中的一些 Tkinter 小部件。 请记住,Python 2.x 和 3.x 的 Tkinter 略有不同
**相关课程**
* [带有 Tkinter 的 Python 桌面应用](https://gum.co/ErLc)
**标签** 要创建标签,我们只需调用 Label()类并将其打包。 padx 和 pady 是水平和垂直填充。
```
......
......@@ -12,10 +12,6 @@ python3 --version
```
**相关课程**
* [带有 Tkinter 的 Python 桌面应用](https://gum.co/ErLc)
### Tkinter 消息框
![Tkinter Message box](img/e9d03180e4231af35183a0c4f9ff6277.jpg) TkMessage boxTo show a minimalistic ![tkinter-dialog](img/cada3d59a1bd4887694d8ded4576f519.jpg) Tk messagebox dialog
......
......@@ -4,10 +4,6 @@
`tkFileDialog`是具有打开和保存对话框功能的模块。 无需自己在 [Tkinter GUI](https://pythonspot.com/tkinter/) 中实现。
**相关课程**
* [带有 Tkinter 的 Python 桌面应用](https://gum.co/ErLc)
**概述** 文件对话框的概述:
## Tkinter 打开文件
......
......@@ -8,10 +8,6 @@
![tk dropdown menu](img/19e10ff770d93deeffd983bf09f95bdc.jpg)
**相关课程:**
* [带有 Tkinter 的 Python 桌面应用](https://gum.co/ErLc)
## Tkinter 下拉示例
The example below creates a Tkinter window with a combobox.
......
......@@ -8,8 +8,6 @@ wxPython 是用于 Python 编程语言的 GUI 工具箱。 [wxPython](https://py
当前支持的操作系统是 Microsoft Windows(32 位),大多数 Unix 或类 Unix 系统以及 Macintosh OSX。
**相关课程:** [使用 wxPython 创建 GUI 应用程序](https://gum.co/qapqB)
wxPython 模块基于 C ++ GUI 库 wxWidgets。
## wxPython 窗口
......
......@@ -6,8 +6,6 @@
面板使您可以选择将小部件放置在窗口中的任何位置。 参数(10,10)是面板上的位置。 id 参数是必需的,但它等于-1(wx.ID_ANY == -1)。 第三个参数是按钮上的文本。
**相关课程:** [使用 wxPython 创建 GUI 应用程序](https://gum.co/qapqB)
您可以使用下面的代码在 [wxPython](https://pythonspot.com/wx/) 中创建一个按钮:
```
......
......@@ -4,8 +4,6 @@
要使用[显示对话框,wxPython](https://pythonspot.com/wx/) 仅需要几行代码。 我们将在下面演示。 我们将讨论信息对话框,简单对话框,错误对话框,警告对话框等。
**相关课程:** [使用 wxPython 创建 GUI 应用程序](https://gum.co/qapqB)
**信息对话框** 信息对话框可以用一行代码显示:
```
......
......@@ -6,8 +6,6 @@
创建一个打开的文件对话框似乎是一个非常复杂的窗口:它包含按钮,位置,标签和许多其他小部件。 而且,此打开文件对话框的外观在每个平台上都不同:Mac OS,Windows 等。
**相关课程:** [使用 wxPython 创建 GUI 应用程序](https://gum.co/qapqB)
在 wxPython 的模块配备了开放式的文件对话框,可以用几个函数的调用来创建。
![wxPythonOpenFile](img/1d17f5d6e0c394ba2f1d574baf74c7b0.jpg) [wxPython](https://pythonspot.com/wx/) Open File Dialog
......
......@@ -8,8 +8,6 @@ wxPython 支持输入对话框,它们包含在框架中。 典型的 wxPython
![wx input](img/38adcfbb184729e5d1d74b09ba622436.jpg) input dialog made with wxPython
**相关课程:** [使用 wxPython 创建 GUI 应用程序](https://gum.co/qapqB)
## wxPython 输入对话框
The example code below creates an input dialog with wxPython:
......
......@@ -4,8 +4,6 @@
尽管出于简单性原因,我们并未在 [wxPython](https://pythonspot.com/wx/) 系列中大量使用面向对象,但是我们无法解决它。 在本教程中,您将学习如何使用 [wxPython](https://pythonspot.com/wx/) 创建选项卡界面。
**相关课程:** [使用 wxPython 创建 GUI 应用程序](https://gum.co/qapqB)
Mainframe 类创建框架,就像前面的示例一样。 其他类别是选项卡的内容。 我们在主框架中创建一个面板和笔记本(标签夹)。 然后我们创建标签对象:
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册