blogjava's web log

          blogjava's web log
          ...

          IronPython學習 之hello word.



          ?
          IronPython Python 語言在 .NET 平臺上的實現,它是一個完全動態的交互式解釋器,可以支持所有的.NET類型庫,需要.NET Framework 2.0的支持。
          ?
          IronPython1.0 下載
          http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&ReleaseId=423

          安裝很簡單:設置環境變量就可以了
          PAHT:
          IronPython1.0路徑 如 : path D:\IronPython-1.0


          簡單例子

          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)
          ????? # 添加個button
          ??? ??? myButton =Button()
          ??? ??? myButton.Text="sa Hello wujun"
          ??? ??? myButton.Location =Point(12,136)
          ??? ??? myButton.Click += Word.myButton_Click
          ??? ??? Word.Controls.Add(myButton)
          ??? ???
          ??? ??? #添加個listBox
          ??? ??? myListBox =ListBox()
          ??? ??? myListBox.Location=Point(12,12)
          ??? ??? Word.Controls.Add(myListBox)
          ??? ???
          ??? ??? #添加個datagridView
          ??? ??? myDataGridView =DataGridView()
          ??? ??? myDataGridView.Location=Point(12,165)
          ??? ??? myDataGridView.Size=Size(550,350)
          ??? ??? Word.Controls.Add(myDataGridView)
          ??? ???
          ??? ??? #簡單的鏈接數據庫 綁定 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()
          ??? ??? #循環
          ??? ??? for i in xrange(100):
          ??? ????? array.Add(i)
          ??? ?????
          ??? ????? #綁定到 ListBox
          ??? ??? myListBox.DataSource =array
          ??? ?
          ??? ?# 定義事件????
          ??? def myButton_Click(Word, *args):
          ??? ??? MessageBox.Show("hello word","歡迎來到神奇的世界")
          ???? # 中文亂碼噢???

          Application.Run(HelloWord())

          編譯 假設
          myFistPython.py 放在C盤

          運行dos 進入c盤? C:\> ipy?
          myFistPython.py


          運行結果:



          相關網站:

          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 閱讀(1328) 評論(0)  編輯  收藏 所屬分類: dot net相關

          導航

          常用鏈接

          留言簿(44)

          新聞檔案

          2.動態語言

          3.工具箱

          9.文檔教程

          友情鏈接

          搜索

          最新評論

          主站蜘蛛池模板: 聂拉木县| 兴隆县| 穆棱市| 福安市| 屯门区| 道孚县| 高阳县| 瑞金市| 济宁市| 苗栗县| 东安县| 科尔| 邮箱| 泸州市| 潮州市| 吴川市| 湖南省| 云南省| 蕲春县| 信丰县| 五大连池市| 拉萨市| 巴楚县| 蓝田县| 金门县| 溧阳市| 姚安县| 龙泉市| 水富县| 芦溪县| 察哈| 长汀县| 南岸区| 搜索| 如皋市| 潜江市| 巴中市| 会东县| 湾仔区| 盐池县| 伽师县|