blogjava's web log

          blogjava's web log
          ...

          IronPython學(xué)習(xí) 之hello word.



          ?
          IronPython Python 語(yǔ)言在 .NET 平臺(tái)上的實(shí)現(xiàn),它是一個(gè)完全動(dòng)態(tài)的交互式解釋器,可以支持所有的.NET類型庫(kù),需要.NET Framework 2.0的支持。
          ?
          IronPython1.0 下載
          http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&ReleaseId=423

          安裝很簡(jiǎn)單:設(shè)置環(huán)境變量就可以了
          PAHT:
          IronPython1.0路徑 如 : path D:\IronPython-1.0


          簡(jiǎn)單例子

          myFistPython.py

          import clr
          clr.AddReference("System.Windows.Forms")
          clr.AddReference("System.Data")
          clr.AddReferenceByPartialName("System.Drawing")

          from System.Collections import *
          from System.Windows.Forms import *
          from System import *
          from System.Data import *
          from System.Data.SqlClient import *
          from System.Drawing import *


          class HelloWord(Form):
          ??? def __init__(Word):
          ??????????? Word.Text='hello'
          ??????????? Word.ClientSize=Size(600,455)
          ????? # 添加個(gè)button
          ??? ??? myButton =Button()
          ??? ??? myButton.Text="sa Hello wujun"
          ??? ??? myButton.Location =Point(12,136)
          ??? ??? myButton.Click += Word.myButton_Click
          ??? ??? Word.Controls.Add(myButton)
          ??? ???
          ??? ??? #添加個(gè)listBox
          ??? ??? myListBox =ListBox()
          ??? ??? myListBox.Location=Point(12,12)
          ??? ??? Word.Controls.Add(myListBox)
          ??? ???
          ??? ??? #添加個(gè)datagridView
          ??? ??? myDataGridView =DataGridView()
          ??? ??? myDataGridView.Location=Point(12,165)
          ??? ??? myDataGridView.Size=Size(550,350)
          ??? ??? Word.Controls.Add(myDataGridView)
          ??? ???
          ??? ??? #簡(jiǎn)單的鏈接數(shù)據(jù)庫(kù) 綁定 DataGridView
          ??? ??? sql = String()
          ??? ??? conStr =String()
          ??? ??? sql="select * from orders"
          ??? ??? conStr="server=.;uid=sa;pwd=cwave;database=Northwind"
          ??? ??? sa =SqlDataAdapter(sql,conStr)
          ??? ??? ds =DataSet()
          ??? ??? sa.Fill(ds)
          ??? ??? myDataGridView.DataSource=ds.Tables[0]
          ??? ???
          ??? ???

          ??? ??? array=ArrayList()
          ??? ??? #循環(huán)
          ??? ??? for i in xrange(100):
          ??? ????? array.Add(i)
          ??? ?????
          ??? ????? #綁定到 ListBox
          ??? ??? myListBox.DataSource =array
          ??? ?
          ??? ?# 定義事件????
          ??? def myButton_Click(Word, *args):
          ??? ??? MessageBox.Show("hello word","歡迎來(lái)到神奇的世界")
          ???? # 中文亂碼噢???

          Application.Run(HelloWord())

          編譯 假設(shè)
          myFistPython.py 放在C盤

          運(yùn)行dos 進(jìn)入c盤? C:\> ipy?
          myFistPython.py


          運(yùn)行結(jié)果:



          相關(guān)網(wǎng)站:

          http://www.python.org/
          http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython

          http://wiki.woodpecker.org.cn/moin/

          http://blogs.msdn.com/hugunin/


          http://blogs.msdn.com/hugunin/



          posted on 2006-09-15 16:30 record java and net 閱讀(1324) 評(píng)論(0)  編輯  收藏 所屬分類: dot net相關(guān)

          導(dǎo)航

          常用鏈接

          留言簿(44)

          新聞檔案

          2.動(dòng)態(tài)語(yǔ)言

          3.工具箱

          9.文檔教程

          友情鏈接

          搜索

          最新評(píng)論

          主站蜘蛛池模板: 温宿县| 山东省| 隆德县| 红安县| 木里| 永新县| 桃园县| 中方县| 措勤县| 安庆市| 凤山县| 尼勒克县| 资源县| 彭阳县| 离岛区| 喀喇| 叶城县| 吕梁市| 高邑县| 玉田县| 屏东市| 太白县| 石林| 荥阳市| 依安县| 左云县| 通海县| 邹平县| 房山区| 云安县| 巴林右旗| 山西省| 兴业县| 阿勒泰市| 安庆市| 武冈市| 三穗县| 沧州市| 张家港市| 项城市| 阆中市|