PHP code example of clue / zenity-react

1. Go to this page and download the library: Download clue/zenity-react library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

clue / zenity-react example snippets




cher = new Clue\React\Zenity\Launcher();

$entry = new EntryDialog();
$entry->setText('What\'s your name?');
$entry->setEntryText(getenv('USER')); // prefill with current user

$launcher->launch($entry)->then(function ($name) use ($launcher) {
    $launcher->launch(new InfoDialog('Welcome to zenity-react, ' . $name .'!'));
}, function (Exception $e) {
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
});

$launcher = new Clue\React\Zenity\Launcher();

$launcher->setBin('/some/other/path/zenity');

$result = $launcher->waitFor($dialog);

$launcher->launch($dialog)->then(
    function ($result) {
        // info dialogs complete with a boolean true result
        // text dialogs complete with their respective text
    },
    function ($reason) {
        // dialog was cancelled or there was an error launching the process
    }
});

$zen = $launcher->launchZen($dialog);
Loop::addTimer(3.0, function () use ($zen) {
    $zen->close();
});

$zen->promise()->then(function ($result) {
    // dialog completed
}, function (Exception $e) {
    echo 'Error: ' . $e->getMessage() . PHP_EOL;
});

$builder = new Builder();
$dialog = $builder->info('Hello world');

$builder->entry($prompt = null, $prefill = null);

$builder->error($text, $title = null);

$builder->fileSelection($title = null, $multiple = false);
$builder->fileSave($title = null, $previous = null);
$builder->directorySelection($title = null, $multiple = false);

$builder->info($text, $title = null);

$builder->listCheck(array $list, $text = null, array $selected = null);
$builder->listMenu(array $list, $text = null);
$builder->listRadio(array $list, $text = null, $selected = null);
$builder->table(array $rows, array $columns = null, $text = null);

$builder->notification($text);
$builder->notifier();

$builder->progress($text = null);
$builder->pulsate($text = null);

$builder->question($question, $title = null);

$builder->text($filename, $title = null);
$builder->editable($filename, $title = null);
$builder->confirmLicense($filename, $confirmation, $title = null);

$builder->warning($text, $title = null);

$launcher = new Clue\React\Zenity\Launcher();
$launcher->setBin('/path/to/zenity');