Ruby Shoes GUI: Continually Updating Paragraphs
If you're looking to list all files in a directory and refresh the list every second, then I think this is what you're looking for:
Shoes.app do
stack do
@btn_exit = button("Exit") {exit}
@log = para "Logging goes here..."
end
every 1 do
@log.text = Dir.entries('C:/Test').select{|file| file != "."*file.length}.join("\n")
end
end
Ruby Shoes GUI Secret style not working
Try it this way
button "Login" do
username = ask("Enter Username: ")
password = ask("Enter Password: ", :secret => true)
end
Shoes GUI toolkit per pixel manipulation possible?
Yep, there is. Most elements accept a :top
and :right
that let you pick an offset per pixel, and lots of the drawing and shape stuff is per-pixel as well.
How to call Shoes methods from inside an instance method?
Shoes.app { ... }
does an instance_eval of the code block. What that means is the that the body of the block gets executed as though self were an instance of Shoes
(or whatever class it is using under the hood). What you'll want to do is something like the following:
class MyClass
def initialize(app)
@app = app
end
def draw
@app.oval :top => 100, :left => 100, :radius => 30
end
end
Shoes.app {
myclass = MyClass.new(self) # passing in the app here
myclass.draw
}
How can I make simple http requests within a ruby Shoes GUI application?
The problem for me when I tried to run your code was that the Shoes app couldn't connect locally using localhost
. Instead of using localhost
, use your computer's local IP address.
So just change this:
Net::HTTP.get(URI.parse("http://localhost:3000"))
to this:
Net::HTTP.get(URI.parse("http://10.1.4.123:3000"))
if your computer's local IP is 10.1.4.123
.
To see the error logs that confirm this is happening for you, insert this line at the top of your shoes app: Shoes.show_log
Or simply enter cmd
+/
on a Mac or ctrl
+/
in Windows(?) when you are running your *.rb
file in Shoes.app
For me the error that showed up was:
Connection refused - connect(2) for "::1" port 3000
Related Topics
How to Submit Polymorphic Comments on Feed? [Error]
Ruby Array to String Conversion
Sort Array Returned by Activerecord by Date (Or Any Other Column)
How to Get the Number of Days in a Given Month in Ruby, Accounting for Year
Rails: How to Access Restful Helpers
Rspec: How to Test File Operations and File Content
How to Unit-Test a JSON Controller
Error While Installing Ruby-1.8.7 on Fedora 15
How to Save Settings as a Hash in a External File
Is Ruby on Rails (Or at Least the Community) Dying
Ruby Shoes Gui: Continually Updating Paragraphs
What Is Mattr_Accessor in a Rails Module
How to Define a 'Before_Save' Callback in a Module
Should I Define a Main Method in My Ruby Scripts
How to Customize Gemfile Per Developer
How to Disable Mongodb Log Messages in Console