2016-11-15 11 views
2

YAD(Yet Another Dialog)で私を助けることができる人。yadノートブックにボタンを追加

私はソフトウェアインストール用のGUIを設計しています。私はフォームフィールドに固執しています。ここで私が働いているサンプルコードは次のとおりです。

sersoft() 
{ 
    root_verify #fucntion for root verification 
    os_verify #function to detect the OS and its version 

    if [ "$ret_val" == 3 ] || [ "$ret_val" == 4 ]; then #ret_val indicates type of OS 
      apt-get update -y 
      apt-get upgrade -y 
      apt-get -y install gcc g++ libpcap0.8-dev build-essential 
      #and many other installations 
      service ssh restart 
      apt-get -y update 
      apt-get -y upgrade 

    elif [ "$ret_val" == 5 ];then 
      yum groupinstall "Development Tools" 
      yum -y install gcc libpcap-devel fontconfig-devel 
      #etc 
      yum -y update 
      yum -y upgrade 
    fi 
} 

    MSP="Install Prerequesites for Server" 
    MCP="Install Prerequesites for Client" 
    MSP1="Software for Server" 
    MCP1="Software for Client" 

    #Welcome Tab 
    yad --plug=$KEY --tabnum=1 --form --image="$banner" --separator='\n' --quoted-output \ 
      > $res4 & 

    #Prerequesites Tab 
    yad --plug=$KEY --tabnum=2 --form --separator='\n' --text="\n\nPlease install the required softwares needed to configure Monosek software. \n\nClick any one of the options.\n\n" --text-align=center --quoted-output \ 
      --field="$MSP!gtk-yes:2":FBTN --align=center \ 
      --field="$MCP!gtk-yes:3":FBTN --align=center > $res1 & 

    #Installation Tab 
    action=$(yad --plug=$KEY --tabnum=3 --form --seperator='\n' --quoted-output \ 
      --field="Select:CBE" "\--Install\--!$MSP1!$MCP1") > $res2 & 

    #Main Dialog 
    yad --center --fixed --notebook --key=$KEY --tab-pos=left --tab="Welcome Tab" --tab="Prerequesites" --tab="Install" \ 
    --title="Software Setup Wizard" --image="$icon" \ 
    --button="OK:0" \ 
    --button="Exit:1" \ 
    --height=560 --width=665 --image-on-top --text=" Software version $VERSION" 

case $action in 

      $MSP1*) TAB2=install_ser_soft ;; 
      $MCP1*) TAB3=instal_client_soft ;; 

      *) yad --center --text="error" 
      ;; 
    esac 

今の問題は、私は、ボタンの仕事を取得する方法が分からないです。ボタンMSPをクリックすると、必要なソフトウェアをインストールするコマンドが含まれている関数install_pre_serが呼び出されます。他のボタンについても同様です。

これまでのカップルからほとんどすべての可能性を試してみたので、誰もがこれを手伝ってくれますか? 前もってありがとう:-)

答えて

1

アクションの代わりにyadの出力が$ res2ファイルに行くという事実のために、あなたのコードのアクションの部分= $(yad ....)は動作しません> $ res2。

あなたのコードでは、action = $(cat $ res2)を適用して、ケースチェックを実行する必要があります。いずれの場合においても

、私はインストール機能のためのさまざまな方法を適用することによって、私のマシンでコードを動作させることができた呼び出します。

function sersoft { 
yad --text "Server Prerequesites Will be installed now" 
} 
export -f sersoft 

function clientsoft { 
yad --text "Client Prerequesites Will be installed now" 
} 
export -f clientsoft 

function install_ser_soft { 
yad --text "Server SOFTWARE to be installed now" 
} 

function install_client_soft { 
yad --text "Client SOFTWARE to be installed now" 
} 


    MSP="Install Prerequesites for Server" 
    MCP="Install Prerequesites for Client" 
    MSP1="Software for Server" 
    MCP1="Software for Client" 

    yad --plug=12346 --tabnum=1 --form --image="abp.png" --separator='\n' &\ 
    yad --plug=12346 --tabnum=2 --form --separator='\n' --text="Please install softwares" --text-align=center \ 
    --field="$MSP!gtk-yes:2:FBTN" "bash -c sersoft" --align=center --field="$MCP!gtk-yes:3:FBTN" "bash -c clientsoft" \ 
    --align=center &\ 
    action=$(yad --plug=12346 --tabnum=3 --form --seperator=' ' --field="Select:CBE" "\--Install\--!$MSP1!$MCP1" &\ 
    yad --center --notebook --key=12346 --tab="Welcome Tab" --tab="Prerequesites" --tab="Install" --title="Software Setup Wizard" --image="abp.png" --button="OK:0" --button="Exit:1" --height=560 --width=665 --image-on-top --text="Software version 3") 
    ret=$? 
    echo "output=" $ret 
    echo "answer=" $action 
    case $action in 
    $MSP1*) install_ser_soft ;; 
    $MCP1*) install_client_soft ;; 
    *) yad --center --text="error";; 
    esac   

は、私のテストを試してみて、それがあなたのために働くなら、私に知らせてください。

PS:あなたは歓迎されているhttp://smokey01.com/yad/

+0

:あなたのプロジェクトのためにあなたを助けるかもしれない、ここでの素敵なチュートリアルがあります!これが助けてくれてうれしいです。 –

+0

インストールボタンを押すと、端末上で進行状況が確認できます。しかし、前提条件をインストールした後、コントロールはダイアログに戻りません。私がダイアログウィンドウでexitを押すと、ハングアップし、強制的にウィザードを終了するように求められます。 –

+0

インストールボタンの機能は正常に動作していますか?ボタンの機能の中で実行するコマンドが失敗し、yadと衝突する可能性のあるエラーコードが発生する可能性があります。私のテストでは、1つのコマンドしか実行されないので、制御はハングすることなくyadのノートブックのダイアログに戻ります。 –

関連する問題