Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 104157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:14:14+00:00 2026-05-11T01:14:14+00:00

I have a function that presents the user a combo-box. def select_interface(interfaces) list_box :items

  • 0

I have a function that presents the user a combo-box.

def select_interface(interfaces)   list_box :items => interfaces do |list|     interface = list.text   end   ### ideally should wait until interface has a value then: ###   return interface end 

The rest of the program depends on the selection from this combo-box.

I would like to find a way to make ruby wait for the input from the combo-box and then carry executing the rest of the code.

There is a similar function in shoes called ask that will wait for the input of the user.

interface =  ask('write your interface here') 

How can I implement this ‘wait until the variable has a value’ function in Ruby/shoes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:14:15+00:00Added an answer on May 11, 2026 at 1:14 am

    It took me a while to understand your question 🙂 I started writing a long answer about the entire theory of GUI applications. But you already have everything you need. The block that list_box takes is really its change method. You’re telling it what to do when it gets changed. Just defer the rest of the program to run when you get a value you want.

    Shoes.app do    interfaces = ['blah', 'blah1', 'blah2']   # proc is also called lambda   @run_rest_of_application = proc do     if @interface == 'blah'       do_blah     # etc   end    @list_box = list_box(:items => interfaces) do |list|     @interface = list.text     @run_rest_of_application.call     @list_box.hide # Maybe you only wanted this one time?   end end 

    This is the basic idea behind all GUI applications: build the initial application then wait for ‘events’, which will create new states for you respond to. In ruby-gnome2, for example, you would use a callback function/block with a Gtk::ComboBox that would change the state of your application. Something like this:

    # Let's say you're in a method in a class @interface = nil @combobox.signal_connect('changed') do |widget|    @interface = widget.selection.selected   rebuild_using_interface end 

    Even outside of a toolkit you can get a ‘free’ events system using Ruby’s Observer module. Hope this helped.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 106k
  • Answers 106k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can try to use DOMDocument. $dom = new DOMDocument('1.0',… May 11, 2026 at 8:49 pm
  • Editorial Team
    Editorial Team added an answer You can just write something quickly yourself: public static class… May 11, 2026 at 8:49 pm
  • Editorial Team
    Editorial Team added an answer No, the structure you found is how Java handles it,… May 11, 2026 at 8:49 pm

Related Questions

I have a web application that I'm writing (C#, MSSQL) and I need to
I’m on the learning curve up the Silverlight trail. I’m a data-centric developer so
I have a javascript function which would populate a list of related item in
How should I write error reporting modules in PHP? Say, I want to write

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.