Hi!
I am kicking around with the wt examples (actually the ruby examples) and
for the life of me I can not add a dialog.
As soon as I add something as a dialog, then everything disappears.
Blank screen.
I am using the poem example (filesystem) and try to add a dialog ::
#!/usr/bin/ruby
=begin
Copyright (C) 2006 Wim Dumon, Koen Deforche
See the LICENSE file for terms of use.
Translated to Ruby by Richard Dale
=end
require 'wt'
require 'Ice'
Ice::loadSlice('../businesslogic/Filesystem.ice')
def listRecursive(dir, depth)
indent = ''
depth = depth + 1
for i in (0...depth)
indent += "\t"
end
contents = dir.list()
r = "<pre>"
for node in contents
subdir = Filesystem::DirectoryPrx::checkedCast(node)
file = Filesystem::FilePrx::uncheckedCast(node)
print indent + node.name()
if subdir
r += "(directory):<br/>"
r += listRecursive(subdir, depth)
else
r += "(file):"
text = file.read()
for line in text
r += indent + "\t" + line + "<br/>"
end
end
end
return r + "</pre>"
end
#
# A simple hello world application class which demonstrates how to react
# to events, read input, and give feed-back.
#
class HelloApplication < Wt::WApplication
#
# The env argument contains information about the new session, and
# the initial request. It must be passed to the WApplication
# constructor so it is typically also an argument for your custom
# application constructor.
#
def initialize(env)
super(env)
setTitle("mysite.com") # application title
root.addWidget(Wt::WText.new("Username:")) # show some text
@nameEdit = Wt::WLineEdit.new(root) do |e| # allow text input
e.setFocus # give focus
end
root.addWidget(Wt::WBreak.new) # insert a line break
root.addWidget(Wt::WText.new("Password:")) # show some text
@passEdit = Wt::WLineEdit.new(root) do |e| # allow text input
e.setFocus # give focus
end
root.addWidget(Wt::WBreak.new) # insert a line break
button = Wt::WPushButton.new("Login", root) do |b| # create a button
b.setMargin(Wt::WLength.new(5), Wt::Left) # add 5 pixels
margin
end
root.addWidget(Wt::WBreak.new) # insert a line break
@greeting = Wt::WText.new(root) # empty text
# THIS CODE breaks everything:
# Wt::WText.new("You can use Wt::WMessageBox for simple modal dialog boxes.
<br />",
# textdiv)
# buttons = Wt::WContainerWidget.new(root)
# buttons.styleClass = "buttons"
#
# Connect signals with slots
# button.clicked.connect(SLOT(self, :greet))
# @nameEdit.enterPressed.connect(SLOT(self, :greet))
# @passEdit.enterPressed.connect(SLOT(self, :greet))
#
# ic = Ice::initialize(ARGV)
# obj = ic.stringToProxy("RootDir:default -p 10000")
# @rootDir = Filesystem::DirectoryPrx::checkedCast(obj)
end
def greet
@greeting.text = "Hello there, " + @nameEdit.text + " you have password: "
+ @passEdit.text + listRecursive(@rootDir, 0)
end
end
=begin
Your main method may set up some shared resources, but should then
start the server application (FastCGI or httpd) that starts listening
for requests, and handles all of the application life cycles.
The block passed to WRun specifies the code that will instantiate
new application objects. That block is executed when a new user surfs
to the Wt application, and after the library has negotiated browser
support. The block should yield a newly instantiated application
object.
=end
begin
Wt::WRun(ARGV) do |env|
# You could read information from the environment to decide whether
# the user has permission to start a new application
HelloApplication.new(env)
end
rescue => e
puts "Exception: " + e
end
--
regards,
Jakob
It's is not, it isn't ain't, and it's it's, not its, if you mean it
is. If you don't, it's its. Then too, it's hers. It isn't her's. It
isn't our's either. It's ours, and likewise yours and theirs.
-- Oxford University Press, Edpress News
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest