01 May 2013 - After the site upgrade, all passwords were reset and you will need to ask the site for a login reset on your first connection.
The CommandWidget is nearly like a
terminal and allows the user to issue commands to a shell
and view the result in a GtkTextView widget.
This widget can be used if you want to run some
commands in the background and never use any more any
printf. Or if you have some text output at
console the and would like to see it in a window.
CommandWidget can do that for you.
CommandWidget is a external process or a
shell connected to a GtkTextview to display
results. This connexion is made throught a pipe.
You can read and write to this external process. This can be a
(nearly) full interactive process, just like terminals
(command.com for Windows). There is a
special class with output only and really easy to use. It could be
used to proide feedback to some management tasks using
external commands (say, tar for example).
The code below wil create a window just like the one on top
of this page. You can send commands using the text entry field
at the bottom of the windows, and the results are displayed on
the top part (a GtkTextView widget).
Text color is higlighted for commands and errors.
<?php
# create the main window
$window = new GtkWindow();
$window->set_size_request(400, 500);
$window->set_position(Gtk::WIN_POS_CENTER);
$window->connect_simple('destroy', array('Gtk', 'main_quit'));
$window->set_title('CommandWidget demo');
# putenv('TERM=dumb');
$window->add(new CommandWidget('/bin/bash'));
$window->show_all();
Gtk::main();
?>ShellCommandWidget is a derived class to
simplify usage for text output only for external commands.
This widget has no entry widget, so commands can only sent from
a script. This widget creates a pipe with a standard shell
waiting for commands to be executed. Here is an example of
use (this is a bit similar to CommandWidget:
<?php
# create the main window
$window = new GtkWindow();
$window->set_size_request(40, 50);
$window->set_position(Gtk::WIN_POS_CENTER);
$window->connect_simple('destroy', array('Gtk', 'main_quit'));
$window->add($shell = new ShellCommandWidget());
$window->show_all();
$shell->exec('ls -al ; ps -aef');
$shell->exec('ls -al /etc | grep ".conf"');
$shell->exec('who am I');
$shell->exec('whoami');
$shell->exec('make love'); # echo to stderr (not working now)
Gtk::main();
?>See the attached sources file below
See on source code header
| Anhang | Größe |
|---|---|
| gtk-command-widget.php_.txt | 10.29 KB |
Neueste Kommentare
vor 43 Wochen 4 Tage
vor 44 Wochen 3 Tage
vor 45 Wochen 4 Stunden
vor 47 Wochen 3 Tage
vor 1 Jahr 15 Wochen
vor 1 Jahr 19 Wochen
vor 1 Jahr 23 Wochen
vor 1 Jahr 23 Wochen
vor 1 Jahr 23 Wochen
vor 1 Jahr 40 Wochen