提交 09dda4cd 编写于 作者: W wizardforcel

2019-11-19 11:57:59

上级 bf573ae3
......@@ -19,7 +19,7 @@ Template matching with OpenCV and Python. Template (left), result image (right)
* **源图像(S)**:在其中查找匹配项的空间
* **模板图像(T):**模板图像
* **模板图像(T)**模板图像
The template image T is slided over the source image S (moved over the source image), and the program tries to find matches using statistics.
......
......@@ -19,8 +19,6 @@ Web 应用程序通常是使用框架创建的。 框架使开发可扩展,可
例如,Flask Web 应用程序框架不支持数据库,您将需要一个单独的模块来使用数据库。 Django Web 应用程序框架默认支持数据库。
**相关课程:** [使用 Python Flask 创建网络应用](https://gum.co/IMzBy)
## 为什么要使用 Web 框架?
在进行 Web 开发时,您要避免花费时间在已经解决的事情上进行编程。 另一方面,如果您是经验丰富的 Web 开发人员,则 Web 框架可能无法提供您所需的一切。
......
......@@ -265,7 +265,7 @@ $ sudo pip install Flask-SqlAlchemy
SQLAlchemy 是用于 Python 编程语言的 SQL 工具箱和对象关系映射器(ORM)。 它支持 MySQL,Microsoft SQL Server 和许多其他关系数据库管理系统。 如果您不熟悉所有这些术语,请继续阅读。
创建文件 _**tabledef.py:**_
创建文件`tabledef.py`
```py
from sqlalchemy import *
......
......@@ -4,7 +4,7 @@
![Python browser PyQt4](img/287d5ac2bd36de412e26bc9ed4a3f4c9.jpg)
Python browser with PyQt4
带有 PyQt4 的 Python 浏览器
在本教程中,我们将使用 Python 构建一个 Web 浏览器。 我们将使用具有 Web 组件的 [PyQT](https://pythonspot.com/en/pyqt4/) 库。 在本教程中,您将学习如何将所有组件链接在一起。 在本教程中,我们将使用默认的渲染引擎,而不是其中一个。
......@@ -12,7 +12,7 @@ Python browser with PyQt4
## PyQt 安装
Install the required packages:
安装所需的软件包:
```py
sudo pip install python-qt4
......@@ -24,9 +24,11 @@ sudo apt-get install python-kde4
## 使用 PyQt 创建 GUI
Start qt4-designer from your applications menu. The [QT](https://pythonspot.com/en/pyqt4/) Designer application will appear:![QT_Designer](img/c5c710d4eea36d37879737f96ff29bc9.jpg)
从应用程序菜单中启动 qt4-designer。[QT](https://pythonspot.com/en/pyqt4/) 设计器应用程序将出现:
QT_Designer
![QT_Designer](img/c5c710d4eea36d37879737f96ff29bc9.jpg)
QT 设计器
选择主窗口,然后按创建。 现在,我们打开了设计器窗口。 在窗口上拖动 _KWebView_ 组件。 如果组件列表中有 _QtWebView_ 。 用它代替。 我们还在顶部添加 _Line Edit_ 。 按文件>另存为> browser.ui。 运行命令:
......@@ -39,7 +41,7 @@ pyuic4 browser.ui > browser.py
## `QWebView`探索
Create a file called** _r_**_**un.py**_ with this contents:
使用以下内容创建一个名为`run.py`的文件:
```py
import sys
......@@ -95,7 +97,7 @@ python run.py
![Python browser](img/287d5ac2bd36de412e26bc9ed4a3f4c9.jpg)
Python browser
Python 浏览器
如果您的代码未运行,请使用以下代码(或查看不同之处并更改错误之处):
......
......@@ -4,7 +4,7 @@
![wordcloud python](img/9bd0f09416c906b80796a1f54cff8df4.jpg)
word cloud based on gmail
基于 gmail 的词云
我们创建了一个 python 程序,该程序**根据您的 gmail** 帐户生成一个 wordcloud。 输出内容可能看起来像这样,具体取决于您电子邮件的内容。
......
......@@ -8,7 +8,7 @@ Django 是一个高级 Python Web 框架,它处理了很多 Web 开发的麻
## Django 教程
Install Django using:
使用以下命令安装 Django:
```py
pip install Django==1.7.1
......@@ -54,7 +54,7 @@ HTTP Django 服务器将启动,如果您打开 [http://127.0.0.1:8000/hello/](
![Django Web Framework](img/e60f6a76e7fe2549ced2f64702af8620.jpg)
Django Web Framework
Django Web 框架
## Django 代码说明:
......
......@@ -4,7 +4,7 @@
## Django
If you want to start with python web development, you could use a web framework named Django. It is designed to be fast, secure and scalable. It comes with an object-relational mapper (ORM), which means that objects in Python are mapped to objects in a database.
如果要开始 python Web 开发,可以使用一个名为 Django 的 Web 框架。它被设计为快速,安全和可扩展的。 它带有一个对象关系映射器(ORM),这意味着 Python 中的对象被映射到数据库中的对象。
用 Django 创建的应用程序分为三个独立的层:模型(数据库),视图(外观)和控制器(逻辑),或者简称为模型-视图-控制器(MVC)体系结构。
......@@ -16,7 +16,7 @@ Start with:
django-admin startproject mysite
```
This will create the directory mysite. Open mysite/mysite/settings.py. You can configure your desired database here:
这将创建目录`mysite`。 打开`mysite/mysite/settings.py`。您可以在此处配置所需的数据库:
```py
1
......@@ -61,7 +61,7 @@ This will create the directory mysite. Open mysite/mysite/settings.py. You can c
![django](img/2b32675c9f6d4fd2f2bb157ad1dbb461.jpg)
Our first Django app.
我们的第一个 Django 应用。
现在我们创建了一个项目,我们创建了一个应用程序。 一个项目可以有许多应用程序。
......@@ -85,7 +85,7 @@ notes/
## Django 数据库模型
Change /mysite/notes/models.py to:
`/mysite/notes/models.py`更改为:
```py
1
......@@ -119,7 +119,7 @@ python manage.py syncdb
```
which will update the database. We then update /mysite/mysite/admin.py to:
这将更新数据库。 然后,我们将`/mysite/mysite/admin.py`更新为:
```py
1
......@@ -151,19 +151,21 @@ manage.py runserver
```
Once you open up the admin panel [http://127.0.0.1:8000/admin](http://127.0.0.1:8000/admin), Notes will appear on the page:<caption id=”attachment_1715” align=”alignnone” width=”830”]![django_admin](img/e6109601b6daf8134d2007b85d72e77a.jpg)
一旦打开管理面板 [http://127.0.0.1:8000/admin](http://127.0.0.1:8000/admin),便笺将出现在页面上:
![django_admin](img/e6109601b6daf8134d2007b85d72e77a.jpg)
Django admin panel
如果单击便笺,则可以查看所有便笺并添加/删除它们:
<caption id=”attachment_1720” align=”alignnone” width=”839”]![django_database](img/48b89f4abcd4c9c1aa2472cd3bc509c1.jpg)
![django_database](img/48b89f4abcd4c9c1aa2472cd3bc509c1.jpg)
Django database admin menu.
Django 数据库管理菜单。
## 显示数据
We have all our data in the database, now we want to create our app. Open /mysite/settings.py and add:
我们将所有数据存储在数据库中,现在我们要创建应用程序。 打开`/mysite/settings.py`并添加:
```py
1
......@@ -176,9 +178,9 @@ We have all our data in the database, now we want to create our app. Open /mysit
```
to the bottom of the file. This defines the directory of our templates (html).
到文件底部。 这定义了模板的目录(html)。
Change /mysite/mysite/urls.py to:
`/mysite/mysite/urls.py`更改为:
```py
1
......@@ -195,7 +197,7 @@ Change /mysite/mysite/urls.py to:
```
Finally create /mysite/static/templates/ and add note.html, which is a simple static html file.
最后,创建`/mysite/static/templates/`并添加`note.html`,这是一个简单的静态 html 文件。
```py
1
......@@ -206,7 +208,7 @@ Finally create /mysite/static/templates/ and add note.html, which is a simple st
```
Open [http://127.0.0.1:8000/](http://127.0.0.1:8000/) to test if works. Change note.html to:
打开 [http://127.0.0.1:8000/](http://127.0.0.1:8000/) 进行测试。 将`note.html`更改为:
```py
1
......@@ -217,7 +219,7 @@ Open [http://127.0.0.1:8000/](http://127.0.0.1:8000/) to test if works. Change n
```
Then open /mysite/notes/views.py and change to:
然后打开`/mysite/notes/views.py`并更改为:
```py
1
......@@ -237,16 +239,15 @@ Then open /mysite/notes/views.py and change to:
```
Once you fire up your browser you will see the list of notes:
启动浏览器后,您将看到便签列表:
<caption id=”attachment_1723” align=”alignnone” width=”541”]![django app](img/23cf03d0a6badbf9bead1760c2dc3aad.jpg)
![django app](img/23cf03d0a6badbf9bead1760c2dc3aad.jpg)
django app
django 应用
## 插入数据
While it’s nice to have a list, we want to add some notes to it.
Create the file /mysite/notes/forms.py
虽然有一个列表很不错,但我们想在其中添加一些注释。创建文件`/mysite/notes/forms.py`
```py
1
......@@ -260,7 +261,7 @@ Create the file /mysite/notes/forms.py
```
Change view.py to:
`view.py`更改为:
```py
1
......@@ -286,7 +287,7 @@ Change view.py to:
```
Finally we update note.html to:
最后,我们将`note.html`更新为:
```py
1
......@@ -303,15 +304,15 @@ Finally we update note.html to:
```
Run it and we have our note taking app :-)
运行它,我们有记笔记的应用程序 :-)
<caption id=”attachment_1726” align=”alignnone” width=”635”]![django_app_insert](img/dfeb48b2ab36e759c1a0397c54d6b925.jpg)
![django_app_insert](img/dfeb48b2ab36e759c1a0397c54d6b925.jpg)
Djano note taking app
## 为应用添加样式
By modifying the note.html we can style it like any other html/css website. If you change note.html to:
通过修改`note.html`,我们可以像其他任何 html/css 网站一样设置其样式。 如果将`note.html`更改为:
```py
1
......@@ -333,8 +334,8 @@ By modifying the note.html we can style it like any other html/css website. If y
```
You will get:
你会得到:
![django_note_app](img/18212430a11e21ca680a2bbd5ca295f1.jpg)
Django note taking app
\ No newline at end of file
Django 笔记记录应用
\ No newline at end of file
......@@ -9,18 +9,22 @@
* [PyQT5](https://pythonspot.com/pyqt5/)
* [WxWidgets(WxPython)](https://pythonspot.com/wx/)
While you can create a graphical user interface (GUI) with any of these modules, they do not have the same features.
您可以使用任何这些模块创建图形用户界面(GUI),但它们不具有相同的功能。
## GUI 工具包
_**Tk**_ provides basic widgets such as a button, menu, text and label. It is very limited compared to QT4 and WxPython but it is also the oldest module.  It runs on most versions of Mac OS, Linux and Windows.![TkMessage box](img/e9d03180e4231af35183a0c4f9ff6277.jpg)
**Tk** 提供基本的小部件,例如按钮,菜单,文本和标签。 与 QT4 和 WxPython 相比,它非常有限,但它也是最旧的模块。 它可以在大多数版本的 Mac OS,Linux 和 Windows 上运行。
a messagebox in Tk. GUIs made in Tk do not have a native look.
![TkMessage box](img/e9d03180e4231af35183a0c4f9ff6277.jpg)
Tk 中的一个消息框。 用 Tk 制作的 GUI 没有本机外观。
_**QT4 和 QT5** _ 由 Qt 公司开发。 使用 QT4 或 QT5 制作的图形应用程序可在 Windows,Linux / X11 和 Mac OS X 上运行。它具有大量的小部件,包括选项卡,按钮,项目视图,表视图,进度条,输入字段,日历视图等等。 与 Tk 相比,它有更多可用的小部件。
[&lt;picture&gt;&lt;source srcset="/wp-content/uploads/2016/07/pyqt5-QLineEdit.png.webp" type="image/webp"&gt; &lt;source srcset="/wp-content/uploads/2016/07/pyqt5-QLineEdit.png" type="image/jpeg"&gt; ![Graphical application using PyQt5](img/4c1c799e1aa4d7f3a9c4b9104ff0efe2.jpg)&lt;/picture&gt; ](/wp-content/uploads/2016/07/pyqt5-QLineEdit.png)
![Graphical application using PyQt5](img/4c1c799e1aa4d7f3a9c4b9104ff0efe2.jpg)
_**WxPython** _ 是一个模块,可创建本机 GUI 外观,而与所使用的操作系统无关。 在 Windows 上将其视为 Windows 应用程序,而在 Mac OS 上将其视为 Mac 应用程序。 与 QT4 或 Tk 相比,这可能是一个明显的优势,具体取决于您的用途。 WxWidgets 有许多可用的小部件,例如按钮,菜单,文本,还有更高级的小部件,如 htmlview 或树控件。
[&lt;picture&gt;&lt;source srcset="/wp-content/uploads/2015/05/wxTabs.png.webp" type="image/webp"&gt; &lt;source srcset="/wp-content/uploads/2015/05/wxTabs.png" type="image/jpeg"&gt; ![wxTabs](img/5a58343f3bd5e027d97e90721b1c4a53.jpg) &lt;/picture&gt;](/wp-content/uploads/2015/05/wxTabs.png) 用 wxPython 创建的窗口。 wxPython 在所有操作系统上都有本机外观。
\ No newline at end of file
![wxTabs](img/5a58343f3bd5e027d97e90721b1c4a53.jpg)
用 wxPython 创建的窗口。wxPython 在所有操作系统上都有本机外观。
\ No newline at end of file
......@@ -11,8 +11,8 @@ PyQt 被广泛用于开发可在各种操作系统上运行的图形界面。
您可以在下面找到 PyQT 文章的集合。
![QT_Designer](img/c001705e2cbb8d9befa1f91127a880e3.jpg)
可以使用 QT Designer
设计应用程序
可以使用 QT Designer 设计应用程序
* [QT4 窗口](https://pythonspot.com/qt4-window/ "QT4 Window")
* [QT4 按钮](https://pythonspot.com/qt4-buttons/ "QT4 Buttons")
......@@ -28,7 +28,9 @@ PyQt 被广泛用于开发可在各种操作系统上运行的图形界面。
* [QT4:构建应用程序(初学者教程)](https://pythonspot.com/building-an-application-gui-with-pyqt-beginners-tutorial/ "Building an application GUI with PyQT, beginners tutorial")
* [QT4:使用设计器创建 GUI(专业教程)](https://pythonspot.com/qml-and-pyqt-creating-a-gui-tutorial/ "QML and PyQT: Creating a GUI (tutorial)")
**真实示例**使用 PyQt 的程序示例
## 真实示例
使用 PyQt 的程序示例
* 投寄箱
* 忍者 IDE
......
......@@ -15,7 +15,7 @@ python3 --version python --version
* [使用 PyQt5 创建 GUI 应用](https://gum.co/pysqtsamples)
![PyQt5 example (appearance depends on operating system](img/4c1c799e1aa4d7f3a9c4b9104ff0efe2.jpg)
![PyQt5 example (appearance depends on operating system](img/4c1c799e1aa4d7f3a9c4b9104ff0efe2.jpg)
## 文章
......
......@@ -36,4 +36,4 @@ Tkinter 视频课程:
* [带有 Tkinter 的 Python 桌面应用](https://gum.co/ErLc)
**注意:**在 Python 3.x 中,该程序包名为 tkinter。 为 Python 2.x 编写的程序可能正在导入 Tkinter。
\ No newline at end of file
**注意**:在 Python 3.x 中,该程序包名为 tkinter。 为 Python 2.x 编写的程序可能正在导入 Tkinter。
\ No newline at end of file
......@@ -10,8 +10,6 @@
使用 **wxPython** 制作的应用程序具有本机系统界面,而无需更改代码。
**相关课程:** [使用 wxPython 创建 GUI 应用程序](https://gum.co/qapqB)
## 目录
......@@ -22,4 +20,4 @@
* [Wx 输入对话框](https://pythonspot.com/wxpython-input-dialog/)
* [Wx 文件菜单](https://pythonspot.com/wxpython-menu-2)
* [Wx 标签](https://pythonspot.com/wxpython-tabs/)
* [Wx 创建 GUI](https://pythonspot.com/creating-a-gui-in-python-with-wxwidgets-tutorial-for-beginners/ "Creating a gui in Python with WxWidgets [tutorial for beginners]")
\ No newline at end of file
* [Wx 创建 GUI](https://pythonspot.com/creating-a-gui-in-python-with-wxwidgets-tutorial-for-beginners/)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册