Oto mój skrypt, kalkulator w bashu:
Kod: Zaznacz cały
#! /bin/bash
export MAIN_DIALOG='
<window width_request="400" spacing="0" window_position="0" title="Kalkulator" resizable="false">
<vbox>
<notebook labels="Kalkulator|Menu">
<vbox>
<frame Kalkulator>
<entry>
<variable>a</variable>
</entry>
<button>
<label>Licz</label>
<action>./calc</action>
</button>
<frame>
<hbox spacing="0">
<button width_request="50">
<label>1</label>
</button>
<button width_request="50">
<label>2</label>
</button>
<button width_request="50">
<label>3</label>
</button>
<button width_request="50">
<label>+</label>
</button>
</hbox>
<hbox spacing="0">
<button width_request="50">
<label>4</label>
</button>
<button width_request="50">
<label>5</label>
</button>
<button width_request="50">
<label>6</label>
</button>
<button width_request="50">
<label>-</label>
</button>
</hbox>
<hbox spacing="0">
<button width_request="50">
<label>7</label>
</button>
<button width_request="50">
<label>8</label>
</button>
<button width_request="50">
<label>9</label>
</button>
<button width_request="50">
<label>*</label>
</button>
</hbox>
<hbox spacing="0">
<button width_request="50">
<label>0</label>
</button>
<button width_request="50">
<label>,</label>
</button>
<button width_request="50">
<label>=</label>
</button>
<button width_request="50">
<label>/</label>
</button>
</hbox>
</frame>
</frame>
</vbox>
<vbox>
<button>
<label>Zamknij program</label>
<action>killall kalkulator\ w\ bashu.sh && killall gtkdialog</action>
</button>
</vbox>
</notebook>
</vbox>
</window>'
gtkdialog --program MAIN_DIALOG
Kod: Zaznacz cały
#!/bin/bash
function wynikDoPliku
{
echo "$(($a))" > wynik
}
function wywolanieOknaWyniku
{
export Popup='
<window width_request="200" spacing="0" window_position="0" title="Kalkulator" resizable="false">
<vbox>
<text>
<label>Wynik to: '"$( < wynik)"'</label>
</text>
</vbox>
</window>'
gtkdialog --program Popup
}
wynikDoPliku
wywolanieOknaWyniku
Proszę o pomoc i z góry dziękuję.