WxRubyWxRuby
WxRuby est un toolkit graphique libre utilisant le langage de programmation Ruby. Il est basé sur le widget toolkit multiplate-forme wxWidgets, écrit en C++. wxRuby permet d'utiliser Ruby pour la création d'applications graphiques sur Windows, Mac OS X, Linux GTK, etc. Les applications ainsi créées conservent l'apparence native du système sur lequel elles sont exécutées. LicenceWxRuby est publié sous la licence WxRuby2[1]. Exemple#!/usr/bin/env ruby
begin
require 'rubygems'
rescue LoadError
end
require 'wx'
# A Wx::Frame is a self-contained, top-level Window that can contain
# controls, menubars, and statusbars
class MinimalFrame < Wx::Frame
def initialize(title)
# The main application frame has no parent (nil)
super(nil, :title => title, :size => [ 400, 300 ])
menu_bar = Wx::MenuBar.new
# The "file" menu
menu_file = Wx::Menu.new
# Using Wx::ID_EXIT standard id means the menu item will be given
# the right label for the platform and language, and placed in the
# correct platform-specific menu - eg on OS X, in the Application's menu
menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
menu_bar.append(menu_file, "&File")
# The "help" menu
menu_help = Wx::Menu.new
menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
menu_bar.append(menu_help, "&Help")
# Assign the menubar to this frame
self.menu_bar = menu_bar
# Create a status bar at the bottom of the frame
create_status_bar(2)
self.status_text = "Welcome to wxRuby!"
# Set it up to handle menu events using the relevant methods.
evt_menu Wx::ID_EXIT, :on_quit
evt_menu Wx::ID_ABOUT, :on_about
end
# End the application; it should finish automatically when the last
# window is closed.
def on_quit
close()
end
# show an 'About' dialog - WxRuby's about_box function will show a
# platform-native 'About' dialog, but you could also use an ordinary
# Wx::MessageDialog here.
def on_about
Wx::about_box(:name => self.title,
:version => Wx::WXRUBY_VERSION,
:description => "This is the minimal sample",
:developers => ['The wxRuby Development Team'] )
end
end
# Wx::App is the container class for any wxruby app. To start an
# application, either define a subclass of Wx::App, create an instance,
# and call its main_loop method, OR, simply call the Wx::App.run class
# method, as shown here.
Wx::App.run do
self.app_name = 'Minimal'
frame = MinimalFrame.new("Minimal wxRuby App")
frame.show
end
RéférencesLiens externes
|
Index:
pl ar de en es fr it arz nl ja pt ceb sv uk vi war zh ru af ast az bg zh-min-nan bn be ca cs cy da et el eo eu fa gl ko hi hr id he ka la lv lt hu mk ms min no nn ce uz kk ro simple sk sl sr sh fi ta tt th tg azb tr ur zh-yue hy my ace als am an hyw ban bjn map-bms ba be-tarask bcl bpy bar bs br cv nv eml hif fo fy ga gd gu hak ha hsb io ig ilo ia ie os is jv kn ht ku ckb ky mrj lb lij li lmo mai mg ml zh-classical mr xmf mzn cdo mn nap new ne frr oc mhr or as pa pnb ps pms nds crh qu sa sah sco sq scn si sd szl su sw tl shn te bug vec vo wa wuu yi yo diq bat-smg zu lad kbd ang smn ab roa-rup frp arc gn av ay bh bi bo bxr cbk-zam co za dag ary se pdc dv dsb myv ext fur gv gag inh ki glk gan guw xal haw rw kbp pam csb kw km kv koi kg gom ks gcr lo lbe ltg lez nia ln jbo lg mt mi tw mwl mdf mnw nqo fj nah na nds-nl nrm nov om pi pag pap pfl pcd krc kaa ksh rm rue sm sat sc trv stq nso sn cu so srn kab roa-tara tet tpi to chr tum tk tyv udm ug vep fiu-vro vls wo xh zea ty ak bm ch ny ee ff got iu ik kl mad cr pih ami pwn pnt dz rmy rn sg st tn ss ti din chy ts kcg ve
Portal di Ensiklopedia Dunia