Use Eric IDE to develop python

1. run eric5, and select menu "project > New..", in the popup window (note: before create new project, you must create a project folder manullay first, because Eric IDE will not auto create project folder )

   1) Projcet Name HelloWorld

   2) Projcet Type QT4 GUI

   3) Projcet Directory: your project path

   4) click "OK", version dialog popup, select "None"

   5) it will create a python project

 

2. in the IDE left area, select the 2nd tab "Forms" of "Projcet-Viewer", right click and select "New Form..", select "Dialog", click "OK". give name "HelloWorld.ui" to the form file, click "Save" button.

 

3. QT design window popup, drag a "Line Edit" component to the form window, set "objectName" property as "LText"

 

4. add a push button labeled "hello" and a push button labeled "exit"

 

5. In the IDE right-bottom area, select "signal/slot editor" tab, click "+" button, it will create a empty event line. set "sender" as "exitbutton", set "signal" as "click()", set "receiver" as "Dialog", set "slot " as "close()", Save and then close the QT design window.

 

<!-- /* Font Definitions */ @font-face {font-family:SimSun; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:宋体; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@SimSun"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:SimSun;} p.MsoPlainText, li.MsoPlainText, div.MsoPlainText {margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Courier New"; mso-fareast-font-family:SimSun;} @page Section1 {size:8.5in 11.0in; margin:1.0in 1.25in 1.0in 1.25in; mso-header-margin:.5in; mso-footer-margin:.5in; mso-paper-source:0;} div.Section1 {page:Section1;} -->

   在 PyQt4下,事件处理方面的术语为" signal" "slot"。事件对应信号 signal,而事件的处理函数则为 slot

PyQt4有一些预定义的 slot,我们可以直接用,比如“退出”按钮的 slot,其实就是关闭对 话框,这个 slot已经在 PyQt4中有定义了。对于这样的 slot,我们不用单独写代码,在 QtDesigner中就可以完成。而对于“你好”按钮,我 们需要自己写代码。对于这样的 slot,我们在 QtDesigner中不做任何处理,甚至不做定义。


6. in the IDE main window, you can see "HelloWorld.ui" in "forms" tab, right click it, select "compile form".

 

7. click the 1st tab "Sources" in the "Projcet-Viewer", you can see a file named "Ui_HelloWorld.py" generated which is mapping to "HelloWorld.ui". double click it to open source.

 

8. Click "F2" to run it.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值