Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Saturday, January 22, 2011

Install pySerial 2.5 in my XP platform with Python 2.6


1, Download Source from http://pypi.python.org/pypi/pyserial or  http://sourceforge.net/projects/pyserial/
2, cd pyserial-2.5
3, python setup.py install

Seems most source modules copied and byte-compiled into the folder
c:\Python26\Lib\site-packages\serial\

Sunday, November 7, 2010

New LGPL Python bindings for Qt slither into the light


New LGPL Python bindings for Qt slither into the light

There is a Project called PySide is established by the OpenBossa and Nokia, and its purpose is to provide structure in the LGPL Python Bindings to link to Qt Toolkit. This is a major bullish news, though different from the Riverbank Computing's PyQt dual license: GPL and commercial license.

But I'm a Python novice, to the discovery of a new book called Rapid GUI Programming with Python and Qt, began first as a way to learn Python.


I feel I must first learn Python, but also need to closely observe between Nokia and OpenBossa future direction. To prepare need to switch to PySide.

To start PySide, go to Get Involved

Sunday, September 12, 2010

My third Python book


Rapid GUI Programming with Python and QT: The Definitive Guide to PyQt Programming 

which is differed to prior two books that I bought, this book is brought to you that building GUI prototypes or full-fledged cross-platform GUI applications with native look-and-feel, PyQt 4 is your fastest, easiest, most powerful solution. So that's what I want. 

The examples are here.

Let's see Phil Thompson Talks About PyQt and PyQt in Wikipedia. 

Gotcha's: developing commercial software with PyQT vrs PySide

 

Monday, September 6, 2010

IndentationError: unindent does not match any outer indentation level


I got this err:
File "ru16.py", line 23
self.relay = Serial(port = port)
^
IndentationError: unindent does not match any outer indentation level

after I edited my python codes as following:

def __init__(self, port = '/dev/ttyUSB0', bps = 9600, timeout = 0.1):
"""Open serial port, set baud rate, timeout,
switch all relays off immediately"""
self.relay = Serial(port = port)
self.relay.xonxoff = False
self.relay.rtscts = False
self.relay.baudrate = bps
self.relay.timeout = timeout
self.relay.open()
self.allOff()

Later I found that it's because I've somehow mixed up tabs and spaces in my gedit editor. So if you met with this same err as mine. There might be spaces mixed in with your tabs. Try doing a search&replace to replace all tabs with a few spaces.

You could use:

python -m tabnanny yourfile.py

to check or instead you just set up your editor correctly.

Friday, September 3, 2010

Install eric4 IDE


For some reasons, I'd like to install eric4 IDE to have fun. After I downloaded install package, there's README.txt file shows that the following steps of installation must get them and install them in the following order (order is important). You'd better to follow installation guide from official site, here's just my references to recall while I was installing and learning. So you should always install them depends on your demands.
My environment is Ubuntu 10.04 LTS - the Lucid Lynx

1. Install Qt 4.6.2
1-1. Download http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.6.3.tar.gz, If you want to install this package, pls follow Qt on X11 Platforms
   After configure, it will show:

   Qt is now configured for building. Just run 'make'.
   Once everything is built, you must run 'make install'.
   Qt will be installed into /usr/local/Trolltech/Qt-4.6.3

   To reconfigure, run 'make confclean' and 'configure'.

 1-2. Download Qt 4.6.2
   The above 4.6.3 version didn't install successfully, so I used "Synaptic Package Manager" to install Qt 4.6.2.

2. Build and install SIP 4.11.1, to see installation
    
   ~/python configure.py

   This is SIP 4.11.1 for Python 2.6.5 on linux2.
   The SIP code generator will be installed in /usr/bin.
   The SIP module will be installed in /usr/lib/python2.6/dist-packages.
   The SIP header file will be installed in /usr/include/python2.6.
   The default directory to install .sip files in is /usr/share/sip.
   The platform/compiler configuration is linux-g++.
   Creating sipconfig.py...
   Creating top level Makefile...
   Creating sip code generator Makefile...
   Creating sip module Makefile...

   ~/make
   ~/sudo make install 

   make[1]: Entering directory `/home/adam/packages/sip-4.11.1/sipgen'
   cp -f sip /usr/bin/sip
   make[1]: Leaving directory `/home/adam/packages/sip-4.11.1/sipgen'
   make[1]: Entering directory `/home/adam/packages/sip-4.11.1/siplib'
   cp -f sip.so /usr/lib/python2.6/dist-packages/sip.so
   strip /usr/lib/python2.6/dist-packages/sip.so
   cp -f /home/adam/packages/sip-4.11.1/siplib/sip.h /usr/include/python2.6/sip.h
   make[1]: Leaving directory `/home/adam/packages/sip-4.11.1/siplib'
   cp -f sipconfig.py /usr/lib/python2.6/dist-packages/sipconfig.py
   cp -f /home/adam/packages/sip-4.11.1/sipdistutils.py /usr/lib/python2.6/dist-
   packages/sipdistutils.py


3. Build and install QScintilla2.4.5, see installation
    To build and install QScintilla, run:
   ~/cd Qt4
   ~/qmake qscintilla.pro
   ~/make
   ~/make install
4. Build and install PyQt4 PyQt-x11-gpl-4.7.6.tar.gz

    ~/python configure.py

    Determining the layout of your Qt installation...
    This is the GPL version of PyQt 4.7.6 (licensed under the GNU General Public
    License) for Python 2.6.5 on linux2.

    Type '2' to view the GPL v2 license.
    Type '3' to view the GPL v3 license.
    Type 'yes' to accept the terms of the license.
    Type 'no' to decline the terms of the license.

    Do you accept the terms of the license? yes
    Checking to see if the QtGui module should be built...
    Checking to see if the QtHelp module should be built...
    Checking to see if the QtMultimedia module should be built...
    Checking to see if the QtNetwork module should be built...
    Checking to see if the QtOpenGL module should be built...
    Checking to see if the QtScript module should be built...
    Checking to see if the QtScriptTools module should be built...
    Checking to see if the QtSql module should be built...
    Checking to see if the QtSvg module should be built...
    Checking to see if the QtTest module should be built...
    Checking to see if the QtWebKit module should be built...
    Checking to see if the QtXml module should be built...
    Checking to see if the QtXmlPatterns module should be built...
    Checking to see if the phonon module should be built...
    Checking to see if the QtAssistant module should be built...
    Checking to see if the QtDesigner module should be built...
    Checking to see if the dbus support module should be built...
    DBus v1 does not seem to be installed.
    Qt v4.6.2 free edition is being used.
    SIP 4.11.1 is being used.
    The Qt header files are in /usr/include/qt4.
    The shared Qt libraries are in /usr/lib.
    The Qt binaries are in /usr/bin.
    The Qt mkspecs directory is in /usr/share/qt4.
    These PyQt modules will be built: QtCore, QtGui, QtHelp, QtMultimedia,
    QtNetwork, QtOpenGL, QtScript, QtScriptTools, QtSql, QtSvg, QtTest, QtWebKit,
    QtXml, QtXmlPatterns, QtAssistant, QtDesigner.
    The PyQt Python package will be installed in /usr/lib/python2.6/dist-packages.
    PyQt is being built with generated docstrings.
    PyQt is being built with 'protected' redefined as 'public'.
    The Designer plugin will be installed in /usr/lib/qt4/plugins/designer.
    The QScintilla API file will be installed in /usr/share/qt4/qsci/api/python.
    The PyQt .sip files will be installed in /usr/share/sip/PyQt4.
    pyuic4, pyrcc4 and pylupdate4 will be installed in /usr/bin.
    Generating the C++ source for the QtCore module...
    Creating the Makefile for the QtCore module...
    Generating the C++ source for the QtGui module...
    Creating the Makefile for the QtGui module...
    Generating the C++ source for the QtHelp module...
    Creating the Makefile for the QtHelp module...
    Generating the C++ source for the QtMultimedia module...
    Creating the Makefile for the QtMultimedia module...
    Generating the C++ source for the QtNetwork module...
    Creating the Makefile for the QtNetwork module...
    Determining the OpenGL data types...
    Generating the C++ source for the QtOpenGL module...
    Creating the Makefile for the QtOpenGL module...
    Generating the C++ source for the QtScript module...
    Creating the Makefile for the QtScript module...
    Generating the C++ source for the QtScriptTools module...
    Creating the Makefile for the QtScriptTools module...
    Generating the C++ source for the QtSql module...
    Creating the Makefile for the QtSql module...
    Generating the C++ source for the QtSvg module...
    Creating the Makefile for the QtSvg module...
    Generating the C++ source for the QtTest module...
    Creating the Makefile for the QtTest module...
    Generating the C++ source for the QtWebKit module...
    Creating the Makefile for the QtWebKit module...
    Generating the C++ source for the QtXml module...
    Creating the Makefile for the QtXml module...
    Generating the C++ source for the QtXmlPatterns module...
    Creating the Makefile for the QtXmlPatterns module...
    Generating the C++ source for the QtAssistant module...
    Creating the Makefile for the QtAssistant module...
    Generating the C++ source for the QtDesigner module...
    Creating the Makefile for the QtDesigner module...
    Generating the C++ source for the Qt module...
    Creating the Makefile for the Qt module...
    Creating QScintilla API file...
    Creating top level Makefile...
    Creating QPy support library for QtCore Makefile...
    Creating QPy support library for QtGui Makefile...
    Creating QPy support library for QtDesigner Makefile...
    Creating QPy support libraries Makefile...
    Creating pyuic4 wrapper...
    Creating pyuic4 Makefile...
    Creating pylupdate4 Makefile...
    Creating pyrcc4 Makefile...
    Creating Qt Designer plugin Makefile...
    Creating pyqtconfig.py...
    ~/make
    ~/make install

 5. Build and install QScintilla2 Python bindings

    To build and install the Python bindings, run:
    ~/ cd Python
    ~/python configure.py
    QScintilla 2.4.5 is being used.
    PyQt 4.7.6 is being used.
    Qt v4.6.2 free edition is being used.
    SIP 4.11.1 is being used.
    The QScintilla module will be installed in
    /usr/lib/python2.6/dist-packages/PyQt4.
    The QScintilla API file will be installed in /usr/share/qt4/qsci/api/python.
    The QScintilla .sip files will be installed in /usr/share/sip/PyQt4.
    The QScintilla module is being built with generated docstrings.
    Generating the C++ source for the Qsci module...
    Creating the Makefile for the Qsci module... 
    ~/make
  ~/make install 

6. Download eric4-4.4.8.tar.gz and Install eric4
    but I've not installed successfully and got err below:

    ~/python install.py
    Checking dependencies
    Python Version: 2.6.5
    An internal error occured.  Please report all the output of the program,
    including the following traceback, to eric4-bugs@eric-ide.python-projects.org.

    Traceback (most recent call last):
    File "install.py", line 831, in 
    main(sys.argv)
    File "install.py", line 744, in main
    doDependancyChecks()
    File "install.py", line 516, in doDependancyChecks
    from PyQt4.QtCore import qVersion, PYQT_VERSION
    RuntimeError: the sip module implements API v8.0 but the PyQt4.QtCore       

    module  requires API v7.1

    so I sent an email to eric4-bugs@eric-ide.python-projects.org, then replies as below:

"You probably updated sip to a newer version. Once you do this, you must either
update PyQt4 as well or build it from your sources using the newer sip. After
you've done this, don't forget to rebuild the QScintilla Python bindings. The
issue is not related to eric in any way."


    I got this err since my PyQt version is 4.7.2, so I removed all my PyQt by "Synaptic Package Manager" and download a version 4.7.6 from PyQt4 PyQt-x11-gpl-4.7.6.tar.gz

    ~/sudo python install.py

    [sudo] password for adam:
    Checking dependencies
    Python Version: 2.6.5
    Found PyQt
    Found QScintilla2
    Qt Version: 4.6.2
    PyQt Version:  4.7.6
    QScintilla Version:  2.4.5
    All dependencies ok.

    Compiling user interface files...

    Compiling source files...

    Installing eric4 ...

    Installation complete.

ref.: 1, http://nxforce.blogspot.com/2010/07/pyqt.html
     2, http://lianix.blogspot.com/2009/12/pyqt-eric-windows.html
     3, http://fire01312.javaeye.com/blog/703339

Monday, August 30, 2010

My second Python book


I bought my second Python handbook called Python 3 技術手冊.  The author is the funder of http://www.python.tw/ . This handbook is exactly what I want. Sometimes that reading a technical book wrote in English is good for learning English. But for me now, the fast way to finish my first UI python program and write an unique, compact even more powerful and reuseful classes and libaries is now my first top priority after daily work. Last week I also bought a book called GIMP創意影像設計18堂課. I like this open source software, but now I can not use it. So I expectedly hope to use it as tool to design my web pictures.

ref.: http://www.gimp.org/downloads/

Sunday, July 25, 2010

A Videogame that Teaches Japanese

Kotodama is targeted towards high school age kids with an interest in videogames and Japanese anime. It developed by using Panda3D. Panda3D is a game engine, a framework for 3D rendering and game development for Python and C++ programs. This is some sort of my dreams.

Tuesday, May 18, 2010

My First Python Book


Eventually I bought a book of Programming Python by Mark Lutz. Why I wanted to buy this handbook. The reasons are:
1, Free Tool, not like other Wxxx...
2, Easily readable back when I am elder.
3, Don't need to learn new Wxxx....operation system every time when OS is upgraded.
4, Learn this language one time in Linux then get myself happiness.
5, Build my own test environment.
6, Learn a GUI tool by Python to go for my goals to have a retirement plan.

Christopher  & Carlos suggested me also to learn this great language. They have more experiences than me in this such field. Especially Christopher pointed me that thewikireader.com repository which have a testudo I can start to study from it. That's the test program he did for that device. I was happy that I can co-work with him when I was at openmoko. So no more wrong directions should be happened unexpectedly as following their past ways in possessing skills with over ten to twenty years. How such stupid I did to follow Wxxxxx....for several years! I made a very very stupid mistake! There are tons of softwares that use Python here. Damn it! I learn this too slow! Well.....actually not slow to an elder Adam now. I'll see where I can go. But then a real one thing is that I really got an obliviousness about leaving my scooter stayed at underground parking of Taipei Shien City Hall. And took a 307 bus back home. As usual way to back my home. Suddenly, indeed I am very elder now..hehe..
一些中文 Python 教學 Web sites:
1, Python 教學文件
2, Python教學
3, 程式語言: 教學誌
4, 遊戲設計-pygame
5, The Eric Python IDE