I have upgraded my Python code to include a graphical user interface. Here is the code:
Run the program online here: http://www.codeskulptor.org/#user21_ikyPgf2883_1.py
import simplegui C,L,H,n=0,0,0,0 C_str, L_str,H_str,n_str='','','','' result=0 result_str='' # Handler for mouse click # Handler to draw on canvas def enter_C(t): global C, C_str C = float(t) C_str='You have entered C: '+''+ str(C) print C def enter_L(t): global L, L_str L = float(t) L_str='You have entered L: '+''+ str(L) print L def enter_H(t): global H, H_str H = float(t) H_str='You have entered H: '+''+ str(H) print H def enter_n(t): global n, n_str n = float(t) n_str='You have entered n: '+''+ str(n) print n def discharge_weir(): #Weirs allow hydrologists and engineers a simple method of measuring #the volumetric flow rate in small to medium-sized streams # Function for the discharge equation by Addition in 1949, for TRAPEZOIDAL WEIR ''' Q is flow rate C is a constant for structure, when flow in cfs, C=3.37 L is the width of the crest in FEET H is the height of head of water over the crest in FEET n varies with structure (e.g. 3/2 for horizontal weir, 5/2 for v-notch weir) ''' global C,L,H,n, result, result_str result=round(C*L*(H**n),2) print result result_str=str(result)+ ' is the flow in CFS using Addition (1949) formula' def draw_handler(canvas): canvas.draw_text(C_str, [50,22], 20, "White") canvas.draw_text(L_str, [50,52], 20, "White") canvas.draw_text(H_str, [50,82], 20, "White") canvas.draw_text(n_str, [50,112], 20, "White") canvas.draw_text(result_str, [50,142], 20, "White") #canvas.draw_text(result_str, [50,152], 24, "White") # Create a frame and assign callbacks to event handlers frame = simplegui.create_frame("Calculate Flow in CFS based on Addition Formula", 500, 400,400) label = frame.add_label('Calculate Flow in CFS from Weirs:') labe2 = frame.add_label('By Ankan Basu, CPG') labe3 = frame.add_label('contact: admin@coalgeology.com') inp1=frame.add_input('Enter C in CFS, hit enter', enter_C, 50) inp2=frame.add_input('Enter L in Feet, hit enter', enter_L, 50) inp3=frame.add_input('Enter H, head in Feet, hit enter', enter_H, 50) inp3=frame.add_input('Enter n for the structure, hit enter', enter_n, 50) flow= frame.add_button('Calculate flow in CFS', discharge_weir,200) frame.set_draw_handler(draw_handler) # Start the frame animation frame.start()