Developing with pyGTK in EeePC 胡崇偉 [email_address] 自由軟體鑄造場 http://www.openfoundry.org/ 中央研究院 資訊科學研究所
自由軟體鑄造場的服務特色 <ul><li>提供協同式專案開發知識及工具 </li></ul><ul><li>提供法務授權條款專業諮詢 </li></ul><ul><li>與學術研究單位及社群團體密切連繫 </li></ul><ul><li>培育...
OpenFoundry  網站功能簡介 專案管理
OpenFoundry  網站功能簡介 專案管理 版本管理 待辦事項 共同筆記 檔案下載 通信論壇 統計資訊
OpenFoundry  網站功能簡介 專案管理 版本管理 待辦事項 共同筆記 檔案下載 通信論壇 統計資訊 授權條款 精靈 電子報 人才資料庫 推廣光碟 資源目錄 研究報告 教學文件
 
 
 
 
Easy Path to Linux Programming
Easy Path to App Programming <ul><li>Especially for EeePC Linux Application Development, where requires the ability to  qu...
Benefits Using Python <ul><li>Easy to Implement </li></ul><ul><li>Easy to Integrate </li></ul><ul><li>Rich Libraries and S...
Python Programming Overview <ul><li>Builtins </li></ul><ul><li>Data Types </li></ul><ul><li>Functions </li></ul><ul><li>Cl...
Checking Basic Info <ul><li>python -V </li></ul><ul><ul><li>Show Version Info </li></ul></ul><ul><li>dir() </li></ul><ul><...
Basic Data Types <ul><li>myString = “Hello World” </li></ul><ul><li>myList = [‘I’, ‘Love’, 7, 11] </li></ul><ul><li>myTupl...
Indexing and Slicing <ul><li>myString = “I Love Python” </li></ul><ul><li>myString[0] == “I” </li></ul><ul><li>myString[-1...
Builtin Function Example <ul><li>range(3)‏ </li></ul><ul><li>[0, 1, 2] </li></ul><ul><li>for a in range(3): </li></ul><ul>...
Indenting Code <ul><li>No explicit begin or end </li></ul><ul><li>No curly braces </li></ul><ul><li>Use colon (:) and the ...
Python Style Guide <ul><li>http://www.python.org/doc/essays/styleguide.html </li></ul><ul><li>Lay-out -- how to use tabs, ...
Importing Modules <ul><li>myString = “250” </li></ul><ul><li>import math </li></ul><ul><li>math.sqrt(myString) </li></ul><...
Function Example <ul><li>def myFunc(score): </li></ul><ul><li>“”” </li></ul><ul><li>document strings </li></ul><ul><li>“””...
Libraries and Their Capabilities <ul><li>OS Operation </li></ul><ul><ul><li>import os </li></ul></ul><ul><ul><li>import sy...
import os <ul><li>os.chdir() </li></ul><ul><li>os.getenv(“HOME”) </li></ul><ul><li>os.listdir(os.getcwd()) </li></ul>
import sys <ul><li>sys.path </li></ul><ul><li>sys.stdin </li></ul><ul><li>sys.stdout </li></ul><ul><li>sys.stderr </li></ul>
File Handling <ul><li>fileobj = open(“myfile”, “r”) </li></ul><ul><li>lines = fileobj.readlines() </li></ul><ul><li>for li...
Socket Connection for Client/Server <ul><li>Socket Creation </li></ul><ul><li>Port Binding </li></ul><ul><li>Raw Data I/O ...
Socket Creation <ul><li>import socket </li></ul><ul><li>s = socket.socket( </li></ul><ul><li>socket.AF_INET, </li></ul><ul...
Port Binding <ul><li>import socket </li></ul><ul><li>serversocket = socket.socket( </li></ul><ul><li>socket.AF_INET, </li>...
FTP lib <ul><li>from ftplib import FTP </li></ul><ul><li>ftp = FTP(“ftp.cdrom.com”) </li></ul><ul><li>print ftp.login() </...
FTP library example - miniFTP <ul><li>FTP Object and Dialog Initialization </li></ul><ul><li>Login to Server and Logout fr...
gtkmozembed <ul><li>Get ready with these packages </li></ul><ul><ul><li>xulrunner </li></ul></ul><ul><ul><li>libxul-dev </...
Gtkmozembed + flash <ul><li>Flash plug-in library placed in specific user folder </li></ul><ul><li>$HOME/.mozilla/plugins ...
Code Samples <ul><li>aspn.activestate.com/ASPN/Cookbook/Python </li></ul><ul><li>pyshop </li></ul><ul><li>Other Important ...
THANK YOU
Upcoming SlideShare
Loading in...5
×

Developing with pyGTK in EeePC

1,667

Published on

speech delivered in EeePC Developer's Day, on May 8, 2008.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,667
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
14
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • http://www.flickr.com/photos/82365211@N00/2473197800
  • Developing with pyGTK in EeePC

    1. 1. Developing with pyGTK in EeePC 胡崇偉 [email_address] 自由軟體鑄造場 http://www.openfoundry.org/ 中央研究院 資訊科學研究所
    2. 2. 自由軟體鑄造場的服務特色 <ul><li>提供協同式專案開發知識及工具 </li></ul><ul><li>提供法務授權條款專業諮詢 </li></ul><ul><li>與學術研究單位及社群團體密切連繫 </li></ul><ul><li>培育人才並提供教學訓練材料 </li></ul>
    3. 3. OpenFoundry 網站功能簡介 專案管理
    4. 4. OpenFoundry 網站功能簡介 專案管理 版本管理 待辦事項 共同筆記 檔案下載 通信論壇 統計資訊
    5. 5. OpenFoundry 網站功能簡介 專案管理 版本管理 待辦事項 共同筆記 檔案下載 通信論壇 統計資訊 授權條款 精靈 電子報 人才資料庫 推廣光碟 資源目錄 研究報告 教學文件
    6. 10. Easy Path to Linux Programming
    7. 11. Easy Path to App Programming <ul><li>Especially for EeePC Linux Application Development, where requires the ability to quickly prototype and to glue software components. </li></ul>
    8. 12. Benefits Using Python <ul><li>Easy to Implement </li></ul><ul><li>Easy to Integrate </li></ul><ul><li>Rich Libraries and Sample Codes </li></ul>
    9. 13. Python Programming Overview <ul><li>Builtins </li></ul><ul><li>Data Types </li></ul><ul><li>Functions </li></ul><ul><li>Classes/Objects </li></ul><ul><li>Methods (Member Functions) </li></ul><ul><li>Modules </li></ul><ul><li>Packages </li></ul>
    10. 14. Checking Basic Info <ul><li>python -V </li></ul><ul><ul><li>Show Version Info </li></ul></ul><ul><li>dir() </li></ul><ul><ul><li>Show Namespace Info </li></ul></ul>
    11. 15. Basic Data Types <ul><li>myString = “Hello World” </li></ul><ul><li>myList = [‘I’, ‘Love’, 7, 11] </li></ul><ul><li>myTuple = (myList, ‘works’, 2) </li></ul><ul><li>myDictionary = {“name”:”marr”,”location”:”taipei”} </li></ul>
    12. 16. Indexing and Slicing <ul><li>myString = “I Love Python” </li></ul><ul><li>myString[0] == “I” </li></ul><ul><li>myString[-1] == “n” </li></ul><ul><li>myString[7:-2] == “Pyth” </li></ul>n o h t y P e v o L I [ ] -1 ↓ -2 ↓ 7 -6 ↓ 2 ↓ 1 ↓ 0 ↓
    13. 17. Builtin Function Example <ul><li>range(3)‏ </li></ul><ul><li>[0, 1, 2] </li></ul><ul><li>for a in range(3): </li></ul><ul><li>print “count down”, a </li></ul>
    14. 18. Indenting Code <ul><li>No explicit begin or end </li></ul><ul><li>No curly braces </li></ul><ul><li>Use colon (:) and the indentation </li></ul>
    15. 19. Python Style Guide <ul><li>http://www.python.org/doc/essays/styleguide.html </li></ul><ul><li>Lay-out -- how to use tabs, spaces, and newlines. </li></ul><ul><li>Comments -- on proper use of comments (and documentation strings). </li></ul><ul><li>Names -- various naming conventions. </li></ul>
    16. 20. Importing Modules <ul><li>myString = “250” </li></ul><ul><li>import math </li></ul><ul><li>math.sqrt(myString) </li></ul><ul><li>TypeError: a float is required </li></ul><ul><li>from string‏ import atoi </li></ul><ul><li>atoi(myString) </li></ul><ul><li>250 </li></ul>
    17. 21. Function Example <ul><li>def myFunc(score): </li></ul><ul><li>“”” </li></ul><ul><li>document strings </li></ul><ul><li>“”” </li></ul><ul><li>import math </li></ul><ul><li>math.sqrt(score) * 10 </li></ul>
    18. 22. Libraries and Their Capabilities <ul><li>OS Operation </li></ul><ul><ul><li>import os </li></ul></ul><ul><ul><li>import sys </li></ul></ul><ul><li>File Handling </li></ul><ul><ul><li>open() </li></ul></ul><ul><li>Networking </li></ul><ul><ul><li>Socket creating and handling </li></ul></ul><ul><ul><li>Twisted for high level applications </li></ul></ul>
    19. 23. import os <ul><li>os.chdir() </li></ul><ul><li>os.getenv(“HOME”) </li></ul><ul><li>os.listdir(os.getcwd()) </li></ul>
    20. 24. import sys <ul><li>sys.path </li></ul><ul><li>sys.stdin </li></ul><ul><li>sys.stdout </li></ul><ul><li>sys.stderr </li></ul>
    21. 25. File Handling <ul><li>fileobj = open(“myfile”, “r”) </li></ul><ul><li>lines = fileobj.readlines() </li></ul><ul><li>for line in lines: </li></ul><ul><li>print line </li></ul>
    22. 26. Socket Connection for Client/Server <ul><li>Socket Creation </li></ul><ul><li>Port Binding </li></ul><ul><li>Raw Data I/O (sending and receiving) </li></ul><ul><li>select() and pull() for Nonblocking sockets </li></ul>
    23. 27. Socket Creation <ul><li>import socket </li></ul><ul><li>s = socket.socket( </li></ul><ul><li>socket.AF_INET, </li></ul><ul><li>socket.SOCK_STREAM) </li></ul><ul><li>s.connect( </li></ul><ul><li>(&quot;www.mysite.com&quot;, 80)) </li></ul>
    24. 28. Port Binding <ul><li>import socket </li></ul><ul><li>serversocket = socket.socket( </li></ul><ul><li>socket.AF_INET, </li></ul><ul><li>socket.SOCK_STREAM) </li></ul><ul><li>serversocket.bind( </li></ul><ul><li>(socket.gethostname(), 80)) </li></ul><ul><li>serversocket.listen(5) </li></ul>
    25. 29. FTP lib <ul><li>from ftplib import FTP </li></ul><ul><li>ftp = FTP(“ftp.cdrom.com”) </li></ul><ul><li>print ftp.login() </li></ul><ul><li>ftp.retrlines('LIST‘) </li></ul><ul><li>filename = “toPut.exe” </li></ul><ul><li>file = open(filename, ‘wb’) </li></ul>
    26. 30. FTP library example - miniFTP <ul><li>FTP Object and Dialog Initialization </li></ul><ul><li>Login to Server and Logout from Server </li></ul><ul><li>File List Generation </li></ul><ul><li>File Get/Put/Remove </li></ul><ul><li>Event Handling: BUTTON_PRESS event, error exception </li></ul>
    27. 31. gtkmozembed <ul><li>Get ready with these packages </li></ul><ul><ul><li>xulrunner </li></ul></ul><ul><ul><li>libxul-dev </li></ul></ul><ul><ul><li>python-gnome2-extras </li></ul></ul><ul><li>http://www.pygtk.org/pygtkmozembed/class-gtkmozembed.html </li></ul>
    28. 32. Gtkmozembed + flash <ul><li>Flash plug-in library placed in specific user folder </li></ul><ul><li>$HOME/.mozilla/plugins </li></ul>
    29. 33. Code Samples <ul><li>aspn.activestate.com/ASPN/Cookbook/Python </li></ul><ul><li>pyshop </li></ul><ul><li>Other Important Issues </li></ul><ul><ul><li>File Format Manipulation </li></ul></ul><ul><ul><li>Exceptions </li></ul></ul><ul><ul><li>Debugging and Testing </li></ul></ul><ul><ul><li>GUI Libraries (Cairo) </li></ul></ul><ul><ul><li>Unicode Howto </li></ul></ul>
    30. 34. THANK YOU
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×