Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

visualruby

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

visualruby

  • 3.6.15
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

This "hello world" script is simple, but there are some important lessons to be learned from it.

As before, the HelloGUI.rb class has a corresponding glade file, HelloGUI.glade, to add a GUI. It maps like this:

HelloGUI.rb ==> glade/HelloGUI.glade

If you doubleclick on HelloGUI.glade, the file will open, and you can see the button with ID: "ui_hello_btn"

This ID follows a naming convention:

ui = user interface hello = identifier btn = a button

This naming convention isn't required, but it helps distinguish a variable that refers to a widget from one of your variables.

The main program creates an instance of the HelloGUI class and shows it:

HelloGUI.new().show_glade()

The following method uses this ID, such that it runs when the button is clicked:

From HelloGUI.rb:

def ui_hello_btn__clicked(*args) alert("Hello World") end

The name of this method is definately not an accident. It follows a naming convention:

__ # two underscores between ID and event!

So the method, ui_hello_btn__clicked(*args) runs when the button with glade ID "ui_hello_btn" encounters a "clicked" event. To make this work, you only need to create a unique glade ID and name your method correctly. It will call the method based on its name.

SUMMARY:

  1. Give the widgets on the form unique glade IDs, then refer to them by their ID.
  2. Store your glade files in the subdirectory /glade. Mapping: MyClass.rb => glade/MyClass.glade
  3. Visualruby will call event handlers by the naming convention: __ (see next examples)

FAQs

Package last updated on 17 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc