From 34f6aa1c5a5d69d926c503068da78c4a17045117 Mon Sep 17 00:00:00 2001 From: kdxcxs Date: Wed, 12 Feb 2020 11:53:07 +0800 Subject: Add PyQT Chinese translation --- zh-cn/pyqt-cn.html.markdown | 76 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 zh-cn/pyqt-cn.html.markdown (limited to 'zh-cn') diff --git a/zh-cn/pyqt-cn.html.markdown b/zh-cn/pyqt-cn.html.markdown new file mode 100644 index 00000000..27c2aba4 --- /dev/null +++ b/zh-cn/pyqt-cn.html.markdown @@ -0,0 +1,76 @@ +--- +category: tool +tool: PyQT +filename: learnpyqt.py +contributors: + - ["kdxcxs", "https://github.com/kdxcxs"] +--- + +**Qt** is a widely-known framework for developing cross-platform software that can be run on various software and hardware platforms with little or no change in the code, while having the power and speed of native applications. Though **Qt** was originally written in *C++*. + + +This is an adaption on the C++ intro to QT by [Aleksey Kholovchuk](https://github.com/vortexxx192 +), some of the code examples should result in the same functionality +this version just having been done using pyqt! + +```python +import sys +from PyQt4 import QtGui + +def window(): + # Create an application object + app = QtGui.QApplication(sys.argv) + # Create a widget where our label will be placed in + w = QtGui.QWidget() + # Add a label to the widget + b = QtGui.QLabel(w) + # Set some text for the label + b.setText("Hello World!") + # Give some size and placement information + w.setGeometry(100, 100, 200, 50) + b.move(50, 20) + # Give our window a nice title + w.setWindowTitle("PyQt") + # Have everything display + w.show() + # Execute what we have asked for, once all setup + sys.exit(app.exec_()) +if __name__ == '__main__': + window() +``` + +In order to get some of the more advanced features in **pyqt** we need to start looking at building additional elements. +Here we show how to introduce a dialog popup box, useful for asking the user to confirm a decision or to provide information. + +```Python +import sys +from PyQt4.QtGui import * +from PyQt4.QtCore import * +def window(): + app = QApplication(sys.argv) + w = QWidget() + # Create a button and attach to widget w + b = QPushButton(w) + b.setText("Press me") + b.move(50, 50) + # Tell b to call this function when clicked + # notice the lack of "()" on the function call + b.clicked.connect(showdialog) + w.setWindowTitle("PyQt Dialog") + w.show() + sys.exit(app.exec_()) + +# This function should create a dialog window with a button +# that waits to be clicked and then exits the program +def showdialog(): + d = QDialog() + b1 = QPushButton("ok", d) + b1.move(50, 50) + d.setWindowTitle("Dialog") + # This modality tells the popup to block the parent whilst it's active + d.setWindowModality(Qt.ApplicationModal) + # On click I'd like the entire process to end + b1.clicked.connect(sys.exit) + d.exec_() +if __name__ == '__main__': + window() \ No newline at end of file -- cgit v1.2.3 From 844029c9277fb9b55c3fb9a04b2ec37d739c8d4d Mon Sep 17 00:00:00 2001 From: kdxcxs Date: Wed, 12 Feb 2020 11:57:05 +0800 Subject: Add PyQT Chinese translation --- zh-cn/pyqt-cn.html.markdown | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'zh-cn') diff --git a/zh-cn/pyqt-cn.html.markdown b/zh-cn/pyqt-cn.html.markdown index 27c2aba4..3d2e07d1 100644 --- a/zh-cn/pyqt-cn.html.markdown +++ b/zh-cn/pyqt-cn.html.markdown @@ -3,44 +3,44 @@ category: tool tool: PyQT filename: learnpyqt.py contributors: + - ["Nathan Hughes", "https://github.com/sirsharpest"] +translators: - ["kdxcxs", "https://github.com/kdxcxs"] +lang: zh-cn --- -**Qt** is a widely-known framework for developing cross-platform software that can be run on various software and hardware platforms with little or no change in the code, while having the power and speed of native applications. Though **Qt** was originally written in *C++*. +**Qt** 是一个著名的用C++实现的跨平台软件开发框架。只需更改少量甚至有时候不需要更改代码就能在多个软硬件平台上运行。 -This is an adaption on the C++ intro to QT by [Aleksey Kholovchuk](https://github.com/vortexxx192 -), some of the code examples should result in the same functionality -this version just having been done using pyqt! +这是[Aleksey Kholovchuk](https://github.com/vortexxx192)对QT的C++简介的改编,用pyqt实现了一些相同功能的代码! ```python import sys from PyQt4 import QtGui def window(): - # Create an application object + # 创建应用对象 app = QtGui.QApplication(sys.argv) - # Create a widget where our label will be placed in + # 创建一个widget,label将会被放置在里面 w = QtGui.QWidget() - # Add a label to the widget + # 在widget中添加一个label b = QtGui.QLabel(w) - # Set some text for the label + # 设置label的文字 b.setText("Hello World!") - # Give some size and placement information + # 设置尺寸和位置 w.setGeometry(100, 100, 200, 50) b.move(50, 20) - # Give our window a nice title + # 设置窗口的标题 w.setWindowTitle("PyQt") - # Have everything display + # 将所有东西都显示出来 w.show() - # Execute what we have asked for, once all setup + # 完成所有设置后,执行我们要求的操作 sys.exit(app.exec_()) if __name__ == '__main__': window() ``` -In order to get some of the more advanced features in **pyqt** we need to start looking at building additional elements. -Here we show how to introduce a dialog popup box, useful for asking the user to confirm a decision or to provide information. +为了获得pyqt中的一些更高级的功能,我们需要开始研究构建其他元素。在这里,我们展示了如何使用弹出对话框,该对话框对于要求用户确认操作或提供信息很有用。 ```Python import sys @@ -49,28 +49,31 @@ from PyQt4.QtCore import * def window(): app = QApplication(sys.argv) w = QWidget() - # Create a button and attach to widget w + # 创建一个按钮并附加到widget w b = QPushButton(w) b.setText("Press me") b.move(50, 50) - # Tell b to call this function when clicked - # notice the lack of "()" on the function call + # 当按钮b被点击时调用下面这个函数 + # 注意函数调用时没有“()”,这样函数就能以对象的方式传入而非调用它所得到的返回值 + # 更多关于pyqt函数调用、传参等的内容见pyqt的信号机制 b.clicked.connect(showdialog) w.setWindowTitle("PyQt Dialog") w.show() sys.exit(app.exec_()) -# This function should create a dialog window with a button -# that waits to be clicked and then exits the program +# 此函数将会创建一个带有按钮的对话框窗口 +# 当按钮被点击时会退出这个程序 def showdialog(): d = QDialog() b1 = QPushButton("ok", d) b1.move(50, 50) d.setWindowTitle("Dialog") + # 这里的模态实现了在对话框弹出时阻塞程序同时屏蔽父窗口 # This modality tells the popup to block the parent whilst it's active d.setWindowModality(Qt.ApplicationModal) - # On click I'd like the entire process to end + # 当按钮被点击时整个进程将会结束 b1.clicked.connect(sys.exit) d.exec_() if __name__ == '__main__': - window() \ No newline at end of file + window() +``` \ No newline at end of file -- cgit v1.2.3 From 890aedaa5dbf5aa61227005878998f6096d1cefd Mon Sep 17 00:00:00 2001 From: kdxcxs Date: Wed, 12 Feb 2020 12:03:24 +0800 Subject: Add PyQT Chinese translation --- zh-cn/pyqt-cn.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zh-cn') diff --git a/zh-cn/pyqt-cn.html.markdown b/zh-cn/pyqt-cn.html.markdown index 3d2e07d1..258c70df 100644 --- a/zh-cn/pyqt-cn.html.markdown +++ b/zh-cn/pyqt-cn.html.markdown @@ -9,7 +9,7 @@ translators: lang: zh-cn --- -**Qt** 是一个著名的用C++实现的跨平台软件开发框架。只需更改少量甚至有时候不需要更改代码就能在多个软硬件平台上运行。 +**Qt** 是一个著名的用C++实现的跨平台软件开发框架。只需更改少量甚至有时候不需要更改代码就能在多个软硬件平台上运行同时拥有原生应用程序的功能和速度。 这是[Aleksey Kholovchuk](https://github.com/vortexxx192)对QT的C++简介的改编,用pyqt实现了一些相同功能的代码! -- cgit v1.2.3 From a64868904b03a05f61b24673be8930eb5b3fb29d Mon Sep 17 00:00:00 2001 From: kdxcxs Date: Tue, 18 Feb 2020 08:20:34 +0800 Subject: remove a translated sentence --- zh-cn/pyqt-cn.html.markdown | 1 - 1 file changed, 1 deletion(-) (limited to 'zh-cn') diff --git a/zh-cn/pyqt-cn.html.markdown b/zh-cn/pyqt-cn.html.markdown index 258c70df..4c87c295 100644 --- a/zh-cn/pyqt-cn.html.markdown +++ b/zh-cn/pyqt-cn.html.markdown @@ -69,7 +69,6 @@ def showdialog(): b1.move(50, 50) d.setWindowTitle("Dialog") # 这里的模态实现了在对话框弹出时阻塞程序同时屏蔽父窗口 - # This modality tells the popup to block the parent whilst it's active d.setWindowModality(Qt.ApplicationModal) # 当按钮被点击时整个进程将会结束 b1.clicked.connect(sys.exit) -- cgit v1.2.3 From e68ea78b253862e1fbd394174c38de9d4bfe428e Mon Sep 17 00:00:00 2001 From: kdxcxs Date: Tue, 18 Feb 2020 11:04:49 +0800 Subject: Replace tabs with spaces --- zh-cn/pyqt-cn.html.markdown | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'zh-cn') diff --git a/zh-cn/pyqt-cn.html.markdown b/zh-cn/pyqt-cn.html.markdown index 4c87c295..a9820a63 100644 --- a/zh-cn/pyqt-cn.html.markdown +++ b/zh-cn/pyqt-cn.html.markdown @@ -17,24 +17,24 @@ lang: zh-cn ```python import sys from PyQt4 import QtGui - + def window(): - # 创建应用对象 + # 创建应用对象 app = QtGui.QApplication(sys.argv) - # 创建一个widget,label将会被放置在里面 + # 创建一个widget,label将会被放置在里面 w = QtGui.QWidget() - # 在widget中添加一个label + # 在widget中添加一个label b = QtGui.QLabel(w) - # 设置label的文字 + # 设置label的文字 b.setText("Hello World!") - # 设置尺寸和位置 + # 设置尺寸和位置 w.setGeometry(100, 100, 200, 50) b.move(50, 20) - # 设置窗口的标题 + # 设置窗口的标题 w.setWindowTitle("PyQt") - # 将所有东西都显示出来 + # 将所有东西都显示出来 w.show() - # 完成所有设置后,执行我们要求的操作 + # 完成所有设置后,执行我们要求的操作 sys.exit(app.exec_()) if __name__ == '__main__': window() @@ -60,7 +60,7 @@ def window(): w.setWindowTitle("PyQt Dialog") w.show() sys.exit(app.exec_()) - + # 此函数将会创建一个带有按钮的对话框窗口 # 当按钮被点击时会退出这个程序 def showdialog(): -- cgit v1.2.3 From fb626bb078c8b42871af61f2bd7c8189d95847dd Mon Sep 17 00:00:00 2001 From: kdxcxs Date: Tue, 18 Feb 2020 11:36:42 +0800 Subject: =?UTF-8?q?=E7=BA=A0=E6=AD=A3=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF?= =?UTF-8?q?=EF=BC=8C=E4=B8=AD=E8=8B=B1=E6=96=87=E8=BF=9E=E6=8E=A5=E5=A4=84?= =?UTF-8?q?=E5=8A=A0=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zh-cn/pyqt-cn.html.markdown | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'zh-cn') diff --git a/zh-cn/pyqt-cn.html.markdown b/zh-cn/pyqt-cn.html.markdown index a9820a63..234c7a29 100644 --- a/zh-cn/pyqt-cn.html.markdown +++ b/zh-cn/pyqt-cn.html.markdown @@ -9,10 +9,10 @@ translators: lang: zh-cn --- -**Qt** 是一个著名的用C++实现的跨平台软件开发框架。只需更改少量甚至有时候不需要更改代码就能在多个软硬件平台上运行同时拥有原生应用程序的功能和速度。 +**Qt** 是一个用 C++ 实现的著名跨平台软件开发框架。只需少量更改有时候甚至不需要更改代码就能在多个软硬件平台上运行,同时拥有原生应用程序的功能和速度。 -这是[Aleksey Kholovchuk](https://github.com/vortexxx192)对QT的C++简介的改编,用pyqt实现了一些相同功能的代码! +以下是[Aleksey Kholovchuk](https://github.com/vortexxx192)对 QT 的 C++ 简介的部分代码的 python 实现。 ```python import sys @@ -21,26 +21,26 @@ from PyQt4 import QtGui def window(): # 创建应用对象 app = QtGui.QApplication(sys.argv) - # 创建一个widget,label将会被放置在里面 + # 创建一个 widget,作为 label 的父控件 w = QtGui.QWidget() - # 在widget中添加一个label + # 在 widget 中添加一个 label 子控件 b = QtGui.QLabel(w) - # 设置label的文字 + # 设置 labe l的文字 b.setText("Hello World!") # 设置尺寸和位置 w.setGeometry(100, 100, 200, 50) b.move(50, 20) # 设置窗口的标题 w.setWindowTitle("PyQt") - # 将所有东西都显示出来 + # 显示 widget 及其所有子控件 w.show() - # 完成所有设置后,执行我们要求的操作 + # 下面让程序跑起来,这行代码会启动事件循环并阻塞直到应用程序退出。 sys.exit(app.exec_()) if __name__ == '__main__': window() ``` -为了获得pyqt中的一些更高级的功能,我们需要开始研究构建其他元素。在这里,我们展示了如何使用弹出对话框,该对话框对于要求用户确认操作或提供信息很有用。 +为了运用 pyqt 中一些更高级的功能,我们需要开始学习使用其他控件。在这里演示了弹出对话框的代码,该对话框在用户确认操作或输入信息等情况下经常用到。 ```Python import sys @@ -49,20 +49,20 @@ from PyQt4.QtCore import * def window(): app = QApplication(sys.argv) w = QWidget() - # 创建一个按钮并附加到widget w + # 创建一个按钮并添加到 widget 控件 w b = QPushButton(w) b.setText("Press me") b.move(50, 50) - # 当按钮b被点击时调用下面这个函数 - # 注意函数调用时没有“()”,这样函数就能以对象的方式传入而非调用它所得到的返回值 - # 更多关于pyqt函数调用、传参等的内容见pyqt的信号机制 + # 当按钮 b 被点击时调用下面这个函数 + # 注意函数调用时没有“()”,这样函数就能以对象的方式传入而非传入执行它所得到的返回值 + # 更多关于 pyqt 函数调用、传参等的内容见 pyqt 的信号机制 b.clicked.connect(showdialog) w.setWindowTitle("PyQt Dialog") w.show() sys.exit(app.exec_()) -# 此函数将会创建一个带有按钮的对话框窗口 -# 当按钮被点击时会退出这个程序 +# 对话框窗口创建函数 +# 当窗口中的按钮被点击时退出本程序 def showdialog(): d = QDialog() b1 = QPushButton("ok", d) -- cgit v1.2.3 From 891061acd46cbe01c1fee5247e30237b484928fc Mon Sep 17 00:00:00 2001 From: kdxcxs Date: Tue, 18 Feb 2020 11:39:31 +0800 Subject: Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 完善注释 Co-Authored-By: lsvih --- zh-cn/pyqt-cn.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'zh-cn') diff --git a/zh-cn/pyqt-cn.html.markdown b/zh-cn/pyqt-cn.html.markdown index 234c7a29..c05d43d8 100644 --- a/zh-cn/pyqt-cn.html.markdown +++ b/zh-cn/pyqt-cn.html.markdown @@ -27,7 +27,7 @@ def window(): b = QtGui.QLabel(w) # 设置 labe l的文字 b.setText("Hello World!") - # 设置尺寸和位置 + # 设置 widget 的尺寸和位置 w.setGeometry(100, 100, 200, 50) b.move(50, 20) # 设置窗口的标题 @@ -75,4 +75,4 @@ def showdialog(): d.exec_() if __name__ == '__main__': window() -``` \ No newline at end of file +``` -- cgit v1.2.3 From 4ad5bf24fc72444681a889cf33d5da5a37d92bff Mon Sep 17 00:00:00 2001 From: kdxcxs Date: Tue, 18 Feb 2020 11:53:47 +0800 Subject: Apply suggestions from code review Co-Authored-By: lsvih --- zh-cn/pyqt-cn.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zh-cn') diff --git a/zh-cn/pyqt-cn.html.markdown b/zh-cn/pyqt-cn.html.markdown index c05d43d8..23cda53c 100644 --- a/zh-cn/pyqt-cn.html.markdown +++ b/zh-cn/pyqt-cn.html.markdown @@ -25,7 +25,7 @@ def window(): w = QtGui.QWidget() # 在 widget 中添加一个 label 子控件 b = QtGui.QLabel(w) - # 设置 labe l的文字 + # 设置 label 的文字 b.setText("Hello World!") # 设置 widget 的尺寸和位置 w.setGeometry(100, 100, 200, 50) -- cgit v1.2.3 From 23e84fb3417e64d3101a4775a6275f5c2f12ccff Mon Sep 17 00:00:00 2001 From: kdxcxs Date: Tue, 18 Feb 2020 11:58:59 +0800 Subject: Update pyqt-cn.html.markdown Suggestions from lsvih --- zh-cn/pyqt-cn.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'zh-cn') diff --git a/zh-cn/pyqt-cn.html.markdown b/zh-cn/pyqt-cn.html.markdown index 23cda53c..34aa23cc 100644 --- a/zh-cn/pyqt-cn.html.markdown +++ b/zh-cn/pyqt-cn.html.markdown @@ -12,7 +12,7 @@ lang: zh-cn **Qt** 是一个用 C++ 实现的著名跨平台软件开发框架。只需少量更改有时候甚至不需要更改代码就能在多个软硬件平台上运行,同时拥有原生应用程序的功能和速度。 -以下是[Aleksey Kholovchuk](https://github.com/vortexxx192)对 QT 的 C++ 简介的部分代码的 python 实现。 +以下内容改编自 [Aleksey Kholovchuk](https://github.com/vortexxx192) 编写的 C++ 版 QT 简介,并用 pyqt 重构原文代码,实现了部分相同的功能。 ```python import sys @@ -40,7 +40,7 @@ if __name__ == '__main__': window() ``` -为了运用 pyqt 中一些更高级的功能,我们需要开始学习使用其他控件。在这里演示了弹出对话框的代码,该对话框在用户确认操作或输入信息等情况下经常用到。 +为了运用 pyqt 中一些更高级的功能,我们需要开始学习使用其他控件。下文演示了如何弹出对话框,该对话框在用户确认操作或输入信息等情况下经常用到。 ```Python import sys @@ -53,7 +53,7 @@ def window(): b = QPushButton(w) b.setText("Press me") b.move(50, 50) - # 当按钮 b 被点击时调用下面这个函数 + # 当按钮 b 被点击时调用 showdialog 函数 # 注意函数调用时没有“()”,这样函数就能以对象的方式传入而非传入执行它所得到的返回值 # 更多关于 pyqt 函数调用、传参等的内容见 pyqt 的信号机制 b.clicked.connect(showdialog) -- cgit v1.2.3 From 473b296fb5c7ad58e3d843553d58ed19a1459fb4 Mon Sep 17 00:00:00 2001 From: kdxcxs Date: Tue, 18 Feb 2020 12:16:41 +0800 Subject: Update pyqt-cn.html.markdown Update translators list --- zh-cn/pyqt-cn.html.markdown | 2 ++ 1 file changed, 2 insertions(+) (limited to 'zh-cn') diff --git a/zh-cn/pyqt-cn.html.markdown b/zh-cn/pyqt-cn.html.markdown index 34aa23cc..55e5bbe3 100644 --- a/zh-cn/pyqt-cn.html.markdown +++ b/zh-cn/pyqt-cn.html.markdown @@ -6,6 +6,8 @@ contributors: - ["Nathan Hughes", "https://github.com/sirsharpest"] translators: - ["kdxcxs", "https://github.com/kdxcxs"] + - ["lsvih", "https://github.com/lsvih"] + - ["imlonghao", "https://github.com/imlonghao"] lang: zh-cn --- -- cgit v1.2.3