B
Bauduin Raphael
Hi,
I'm looking at Qtruby, trying to write a little log view app.
I'm basing the app on the p3 app from the tutorial found here:
http://developer.kde.org/language-bindings/ruby/kde3tutorial/p3.html
I modify it like that:
hello = Qt::TextEdit.new( "", "", self)
hello.textFormat = Qt::LogText
setCentralWidget hello
Thread.new("/tmp/test") do |f|
tail = IO.popen("/usr/bin/tail -f #{f}","r")
while line = tail.gets
hello.append line.chomp
#hello.refresh
end
end
First problem: when I qui the app, the tail -f continues to run.
I also tried to put the while in a block passed to IO.popen, with the
same result. This then understandably results in the message
/usr/bin/tail: write error: Broken pipe
/usr/bin/tail: write error
in the terminal from which I started the app when a new line is appended
to the watched file.
I have also problems refreshing the widget when a new log line is
appended. If I uncomment hello.refresh after hello.append, only the
first line is displayed in the widget when I start the app, and when new
log lines are appended to the watched file, I get the broken pipe in the
terminal. When replacing hello.refresh by puts line.chomp, the program
works fine, except for the refrech problem.....
Thanks for your help.
Raph
I'm looking at Qtruby, trying to write a little log view app.
I'm basing the app on the p3 app from the tutorial found here:
http://developer.kde.org/language-bindings/ruby/kde3tutorial/p3.html
I modify it like that:
hello = Qt::TextEdit.new( "", "", self)
hello.textFormat = Qt::LogText
setCentralWidget hello
Thread.new("/tmp/test") do |f|
tail = IO.popen("/usr/bin/tail -f #{f}","r")
while line = tail.gets
hello.append line.chomp
#hello.refresh
end
end
First problem: when I qui the app, the tail -f continues to run.
I also tried to put the while in a block passed to IO.popen, with the
same result. This then understandably results in the message
/usr/bin/tail: write error: Broken pipe
/usr/bin/tail: write error
in the terminal from which I started the app when a new line is appended
to the watched file.
I have also problems refreshing the widget when a new log line is
appended. If I uncomment hello.refresh after hello.append, only the
first line is displayed in the widget when I start the app, and when new
log lines are appended to the watched file, I get the broken pipe in the
terminal. When replacing hello.refresh by puts line.chomp, the program
works fine, except for the refrech problem.....
Thanks for your help.
Raph