My Opera is closing 3rd of March

X光年

don't forget 2005

又见wx

好久没碰wx了,手有点痒。但这里只有windows和一个wxdev-cpp,编译速度实在是让人望而却步……

突然想起wx还有其它语言的绑定,比如说wxPython。但我对python不是很熟,并且我更喜欢ruby一些。记得去年看到过一个wxRuby的项目,去网上看看吧。

用google一搜就搜到了,下了一个for windows版的,写了一个小程序,哈,不用编译,一股熟悉的感觉(ruby 和 wx)。

这个程序的功能是查询北京市的公交车。

下面是源代码,

好久没碰wx了,手有点痒。但这里只有windows和一个wxdev-cpp,编译速度实在是让人望而却步……

突然想起wx还有其它语言的绑定,比如说wxPython。但我对python不是很熟,并且我更喜欢ruby一些。记得去年看到过一个wxRuby的项目,去网上看看吧。

用google一搜就搜到了,下了一个for windows版的,写了一个小程序,哈,不用编译,一股熟悉的感觉(ruby 和 wx)。

这个程序的功能是查询北京市的公交车。

下面是源代码,

#author: htbest2000[at]gmail.com
#announce: You can copy/use this code anywhere, but MUST retain
# the author-infomation.
def bus( the_start, the_end )
require 'win32ole'

command = "http://www.bjbus.com/busmap/map.jsp?" + \
"moduel=busrute&Start=#{the_start}" + \
"&End=#{the_end}&BusTactic=8"

ie = WIN32OLE.new('InternetExplorer.Application')
ie.visible = true
ie.Navigate(command)
end

require 'wxruby'
include Wx

ID_BTN_OK = 1000
ID_BTN_CANCEL = 1001
ID_TXT_SRC = 1002
ID_TXT_DST = 1003

class MyFrame < Dialog
def initialize( title )
super(nil, -1, title, Point.new(-1, -1), Size.new(320, 200))

# create widgets...
sizer_main = BoxSizer.new(Wx::VERTICAL)
sizer_btns = BoxSizer.new(Wx::HORIZONTAL)

txt_src = TextCtrl.new( self, ID_TXT_SRC, "" )
txt_dst = TextCtrl.new( self, ID_TXT_DST, "" )

btn_ok = Button.new( self, ID_BTN_OK, "&OK" )
btn_cancel = Button.new(self, ID_BTN_CANCEL, "&Cancel")

# layout...
sizer_main.add( StaticText.new( self, -1, "From:" ) )
sizer_main.add( txt_src, 0, ALL|EXPAND, 10 )
sizer_main.add( StaticText.new( self, -1, "To:" ) )
sizer_main.add( txt_dst, 0, ALL|EXPAND, 10 )

sizer_btns.add(btn_ok, 0, ALL, 10)
sizer_btns.add(btn_cancel, 0, ALL, 10)

sizer_main.add( sizer_btns )
set_sizer( sizer_main )

# install event handlers...
evt_close {destroy}
evt_button(ID_BTN_OK) { bus( txt_src.get_value, txt_dst.get_value) }
evt_button(ID_BTN_CANCEL){ destroy }
end
end

class MyApp < App
def on_init
MyFrame.new("bus query").show()
end
end

MyApp.new.main_loop

一个利用gmail大空间的firefox插件火箭启示录

Write a comment

New comments have been disabled for this post.