tk
require 'tk'
root = TkRoot.new { title "Ex1" }
TkLabel.new(root) {
text 'Hello, World!'
pack { padx 15 ; pady 15; side 'left' }
}
Tk.mainloop
wxRuby3
概述
wxRuby3是一个针对Ruby的跨平台GUI库,基于成熟的针对C++的wxWidgets GUI工具包。它尽可能地使用本地小部件,为Windows、OS X和Linux/GTK上的GUI应用程序提供正确的外观、感觉和行为。wxRuby旨在为在Ruby中开发专业标准的桌面应用程序提供一个全面的解决方案。
require 'wx'
Wx::App.run do
Wx::Frame.new(nil, title: 'Hello world!').show
end
gem install wxruby3
require 'wx'
class TheFrame < Wx::Frame
def initialize(title)
super(nil, title: title)
panel = Wx::Panel.new(self)
button = Wx::Button.new(panel, label: '单击我')
button.evt_button(Wx::ID_ANY) { Wx.message_box('你好,很高兴认识你', 'Button sample') }
end
end
Wx::App.run { TheFrame.new('Hello world!').show }
显示窗口
require 'wx'
Wx::App.run { Wx::Frame.new(nil, title: '你好,我的第一个wxruby').show }
frame
require 'wx'
class MyApp < Wx::App
def initialize
super
@frame = nil
end
attr_reader :frame
def on_init
@frame = Wx::Frame.new(nil, title: '你好,我的第一个wxruby')
@frame.show
end
def on_exit
puts 'Exiting.'
end
end
MyApp.run
本文来自博客园,作者:计算技术研究,转载请注明原文链接:https://www.cnblogs.com/mori-tec/p/17957217
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示