2011-02-15 4 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 모듈에는 진행률 막대 예제가 있습니다 ("더 많은 예제"섹션으로 스크롤). 나는 그것을 사용하지 않았고 당신의 유스 케이스에 맞는지 확신 할 수 없다. 그러나 그것은 당신에게 약간의 아이디어를 줄 것이다.

관련 문제