2016-05-05 81 views
0

我想創建簡單的GUI,將顯示基於單個領域的一些數據,用戶進入如何更新鞋(紅寶石)para.text

這是我用來顯示代碼數據

Shoes.app { 
    background "#EFC" 
    border("#BE8", strokewidth: 6) 
    stack(margin: 12) { 
     @here=para "Eneter your summoner name" 
     flow { 
      @sumName=edit_line 
      @push=button "Enter" 
      @push.click { 
       setup(@sumName.text) 
      } 
     } 
    } 
    #Champion Stats Table 
    flow{ 
     $table = [[]] 
     i = 0 
     #Name 
     stack(:width => 100){ 
      $table[i][0] = para "Champion", margin: 4 
      $Summoner.rankedChamps.each do |c| 
       $table[i][0] = para c.name, margin: 4 
      end 
      i+=1 
     } 
     i = 0 
     #Wins 
     stack(:width => 50){ 
      $table[i][1] = para "Wins", margin: 4 
      $Summoner.rankedChamps.each do |c| 
       $table[i][1] = para c.wins.to_s, margin: 4 
      end 
      i+=1 
     } 
     i = 0 
     #Loses 
     stack(:width => 50){ 
      $table[i][1] = para "Loses", margin: 4 
      $Summoner.rankedChamps.each do |c| 
       $table[i][2] = para c.loses.to_s, margin: 4 
      end 
      i+=1 
     } 
     i = 0 
     #KDA 
     stack(:width => 50){ 
      $table[i][1] = para "KDA", margin: 4 
      $Summoner.rankedChamps.each do |c| 
       $table[i][3] = para c.KDA.to_s, margin: 4 
      end 
      i+=1 
     } 
    } 

當用戶點擊確認按鈕的$Summoner對象被正確地更新,但是我無法弄清楚如何更新所有對文本精密組件

回答

0

不知道的,瞭解你想什麼但這裏有一個辦法:

Shoes.app { 
    background "#EFC" 
    border "#BE8", strokewidth: 6 
    stack margin: 12 do 
     para "Enter your summoner name" 
     flow { 
      sumName = edit_line 
      button "Enter" do 
       setup(sumName.text) 
      end 
     } 
    end 

    flow do 
     stack(:width => 100) { 
      @para1 = para "Champion", margin: 4 
     } 
     stack(:width => 50) { 
      @para2 = para "Wins", margin: 4 
     } 
     stack(:width => 50) { 
      @para3 = para "Loses", margin: 4 
     } 
     stack(:width => 50) { 
      @para4 = para "KDA", margin: 4 
     } 
    end 
} 

然後可能在你的設置方法更新與文本setter方法你第,例如:@para3.text = your_text_data
建立你的GUI佈局,再後來當用戶名可用更新所需的字段