2011-02-15 43 views
0

我在web2py中製作了一個進度表,但它只顯示在終端窗口中。我怎樣才能使進度條/米在web2py的HTML頁面中工作?如何在web2py中創建進度條/米?

下面的代碼的一部分:

k = 1 # This is the loop variable for subplots. 
for counter in nus: 
    fig = plt.figure() 
    D = E*(h**3)/(12*(1-counter**2)) # Cylindrical rigidity. 
    T0 = (L**2)/(D*np.pi**2)*T0_orig # Nondimensional tension. 
    amax = T0/kappa # Maximum allowed alpha (to keep tension nonnegative everywhere). 
    alphas = [0, (10**-6)*amax, (10**-4)*amax, (10**-2)*amax] # Nondimensional alphas to use for plot. 
    workdone = 0.0 # How much of the Figure has been calculated? 0.0 = none, 1.0 = Figure is ready to show. 
    workstep = 100.0/len(alphas) # How much work is done during one step in the loop? If there are 4 steps in the loop, then then step will be 100.0/4 = 25.0. 
    for alpha in alphas: 
     lambda_, xx, f = nonhomog_solver(kappa, alpha, nu, nx) 
     V0 = np.sqrt(T0_orig/m + np.pi**2 * D/(m*L**2)*lambda_) 
     if (k == 1): 
      V0_ref = V0 

     # Figure 1 
     fig_a = fig.add_subplot(2,2,k) 
     fig.subplots_adjust(hspace=0.4) 
     if (k == 1): 
      fig_a.set_title(r'$\alpha/\alpha_{max} = %.2g, V_{0}^{ref} = %.6g$ m/s' % (alpha/amax, V0)) 
     else: 
      fig_a.set_title(r'$\alpha/\alpha_{max} = %.2g, V_{0}/V_{0}^{ref} = %.6g$' % (alpha/amax, V0/V0_ref)) 
     fig_a.plot(xx,f) 
     plt.xlim(-kappa,kappa) 
     plt.xlabel(r'$\eta$') 
     plt.ylim(-0.1,1.1) 
     if ((k == 1) or (k == 3)): 
      plt.ylabel(r'$f(\eta)$') 
     workdone = workdone + workstep 
     print "Figure 1:", workdone, "%/100.0% done." 

     # Let's get ready for the next subfigure. 
     k = k + 1 

回答

2

你可能會更好詢問mailing list

你的代碼是在一個控制器函數裏面嗎?請注意,打印語句不會將任何輸出發送到網頁(即,它們不影響HTTP響應) - 爲此,控制器需要將dict返回到視圖(或返回字符串)。對於進度條,您最終可能需要使用Ajax(另請參閱here)。

Client Tools模塊有一個進度條示例(滾動到「更多示例」部分)。我沒有使用它,我不確定它適合你的用例,但它可能會給你一些想法。