2010年12月18日 星期六

中文顯示

chinese = u"中文!"
print chinese


--------------------------------------------------------
加入 wxpython 的練習,建立一個中文標題視窗
-------------------------------------------------------
mytitle = u"練習"
import wx # 導入wxPython
class App(wx.App):#子類化wxPython
    def OnInit(self): #定義一個應用程序的初始化方法
        frame = wx.Frame(parent=None, title=mytitle)
        frame.Show()
        return True
app = App() #創建一個應用程序類的實例
app.MainLoop() #進入這個應用程序的主事件循環

-------------------------------------
讀取utf8檔案
------------------------------------------
import codecs
fileObj = codecs.open( "someFile", "r", "utf-8" )
u = fileObj.read() # Returns a Unicode string from the UTF-8 bytes in the file
-------------------------------------------------------------
以萬用碼Unicode編寫python

special comment in the first or second lines of your script:
# -*- coding: utf-8 -*-

python ide

DrPtyhon
BOa Constructor
spe 提供linux版本
PyScripter
WingWare
Eric
Geany


 

2010年12月16日 星期四

helloworld.py

import sys
from PyQt4.QtGui import *
app = QApplication(sys.argv)
button = QPushButton("Hello World", None)
button.show()
app.exec_()


執行
python helloworld.py

test1

#include
#include
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello world!");
hello.show();
return app.exec();
}

然後依序執行以下指令,Makefile會自動產生

$ qmake -project
$ qmake
$ make

編譯完成

PyQt4

Ubuntu 10.04


安裝Qt4
$ sudo apt-get install libqt4-dev libqt4-dbg libqt4-gui libqt4-sql qt4-dev-tools qt4-doc qt4-designer qt4-qtconfig

安裝PyQt4

$ sudo apt-get install "python-qt4-*"

PyQt4範例
/usr/share/doc/python-qt4-doc/examples

Qt+KDevelop

http://www.kdevelop.org/

KDevelop採用用GPL,支援許多語言如:C/C++,
Ada, Java, Pascal, Fortran, PHP, Perl, Shell, Python, Ruby,
SQL等

Qt Designer是一個強大GUI界面開發工具

安裝
# tar zvxf qt-x11-opensource-src-4.1.0.tar.gz
# cd qt-x11-opensource-src-4.1.0
# ./configure
# make
# make install


設置KDEDIR和QTDIR兩個環境變數,
以及PATH變數
KDE的頭文件在/usr/include/kde

Qt的頭文件和API在/usr/lib/qt-3.3

設置環境變數


# export KDEDIR=/usr/include/kde
# export QTDIR=/usr/lib/qt-3.3
# export PATH=$QTDIR/bin:$KDEDIR/bin:$PATH
# export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH


也可將上述指令寫入.bashrc 文件中

Ubuntu 10.04

Based on a clean Ubuntu 10.04, I could get FreeBASIC 0.21 to work with these packages:

32bit Ubuntu:
Quote:
libncurses5-dev
libx11-dev
libxext-dev
libxpm-dev
libxrandr-dev
libxrender-dev
libstdc++6-4.4-dev (only needed with the normal non-standalone FreeBASIC)