exception - Python error pop up not working -


writing code , broke somehow , can't remember working, been using python few weeks , after working on literally day, i'm more little frustrated...

# program calculate delivery order totals  graphics import *  #error window def errorwindow(): errwin = graphwin("error", 200, 200) errwin.setcoords(0.0, 0.0, 4.0, 4.0) errwin.setbackground(color_rgb(33,158,87)) text(point(2, 3), "this not valid order").draw(errwin) text(point(2, 2.5), "please try again").draw(errwin) outline = rectangle(point(1.5,1), point(2.5,2)) outline.setfill('white') outline.draw(errwin) okbutton = text(point(2,1.5),"ok") okbutton.draw(errwin) done=errwin.getmouse() if (done.getx() > 1.5 , done.getx() < 2.5):     errwin.close()  def main():         win = graphwin("brandi's bagel house", 500, 500)     win.setcoords(0.0, 0.0, 10.0, 10.0)     win.setbackground(color_rgb(33,158,87))  #banner     banner = rectangle(point(0, 8), point(10, 10))     banner.setfill(color_rgb(97,76,26))     banner.setoutline(color_rgb(97,76,26))     banner.draw(win)  #logo image     circ = circle(point(1,9), .65)     circ.setfill('white')     circ.setoutline('white')     circ.draw(win)      circ2 = circle(point(1,9), .6)     circ2.setfill(color_rgb(33,158,87))     circ2.setoutline(color_rgb(33,158,87))     circ2.draw(win)      bigb = text(point(1, 9),"b")     bigb.setstyle('bold italic')     bigb.settextcolor('white')     bigb.setface('courier')     bigb.setsize(28)     bigb.draw(win)  #horizontal lines     line(point(0,2.25), point(10,2.25)).draw(win)     line(point(0,4.25), point(10,4.25)).draw(win)     line(point(0,6.25), point(10,6.25)).draw(win)  #text     title = text(point(4,9), "delivery orders:")     title.setsize(20)     title.settextcolor('white')     title.draw(win)      text(point(1.5,7), "bagels:").draw(win)      whitetext = text(point(3,7.5), "white")     whitetext.setsize(10)     whitetext.draw(win)      wheattext = text(point(5,7.5), "wheat")     wheattext.setsize(10)     wheattext.draw(win)      text(point(1.5,5), "toppings:").draw(win)      creamtext = text(point(3,5.8), "cream")     creamtext.setsize(10)     creamtext.draw(win)      cheesetext = text(point(3,5.5), "cheese")     cheesetext.setsize(10)     cheesetext.draw(win)      buttertext = text(point(5,5.5), "butter")     buttertext.setsize(10)     buttertext.draw(win)      jellytext = text(point(7,5.5), "jelly")     jellytext.setsize(10)     jellytext.draw(win)      text(point(1.5,3), "coffee:").draw(win)      regtext = text(point(3,3.5), "regular")     regtext.setsize(10)     regtext.draw(win)      decaftext = text(point(5,3.5), "decaf")     decaftext.setsize(10)     decaftext.draw(win)      text(point(7,1.5), "subtotal:").draw(win)     text(point(7,1), "tax:").draw(win)     text(point(7,0.5), "total:").draw(win)  #input bagel     bagel1 = entry(point(3,7), 3)     bagel1.settext("0")     bagel1.draw(win)      bagel2 = entry(point(5,7), 3)     bagel2.settext("0")     bagel2.draw(win)  #input topping     top1 = entry(point(3,5), 3)     top1.settext("0")     top1.draw(win)      top2 = entry(point(5,5), 3)     top2.settext("0")     top2.draw(win)      top3 = entry(point(7,5), 3)     top3.settext("0")     top3.draw(win)  #input coffee      coff1 = entry(point(3,3), 3)     coff1.settext("0")     coff1.draw(win)      coff2 = entry(point(5,3), 3)     coff2.settext("0")     coff2.draw(win)  #calculate button     outer1 = rectangle(point(4.2,0.6), point(5.8,1.4))     outer1.setfill('white')     outer1.draw(win)     button = text(point(5,1),"calculate")     button.draw(win)  #quit buttons     outer2 = rectangle(point(9,9.2), point(9.95,9.95))     outer2.setfill('white')     outer2.draw(win)     button = text(point(9.5,9.6),"quit")     button.draw(win)  #output     subtotaloutput = text(point(9,1.5), "$0.00")     subtotaloutput.draw(win)      taxoutput = text(point(9,1), "$0.00")     taxoutput.draw(win)      totaloutput = text(point(9,0.5), "$0.00")     totaloutput.draw(win)  #calculations     whitebagel = eval(bagel1.gettext())     whitetotal = whitebagel* 1.25      wheatbagel = eval(bagel2.gettext())     wheattotal = wheatbagel*1.50      creamcheese = eval(top1.gettext())     creamtotal = creamcheese* 0.50      butter = eval(top2.gettext())     buttertotal = butter*0.25      jelly = eval(top3.gettext())     jellytotal = jelly*0.75      regularcoff = eval(coff1.gettext())     regulartotal = regularcoff*1.25      decafcoff = eval(coff2.gettext())     decaftotal = decafcoff*1.25      click = win.getmouse()      if (click.getx() > 4.2 , click.getx() < 5.8 , (whitebagel >0 or wheatbagel >0)):          subtotal = whitetotal+wheattotal+creamtotal+buttertotal+jellytotal+regulartotal+decaftotal         tax = .06         taxes = subtotal*tax         total = taxes+subtotal          subtotal = "$%0.2f" % (subtotal)         taxes = "$%0.2f" % (taxes)         total = "$%0.2f" % (total)          subtotaloutput.settext(subtotal)         taxoutput.settext(taxes)         totaloutput.settext(total)          #coffee cup image         bottomoval = oval(point(0.7,0.4), point(1.4, 0.7))         bottomoval.setfill(color_rgb(97,76,26))         bottomoval.setoutline(color_rgb(97,76,26))         bottomoval.draw(win)          cup = rectangle(point(0.7,0.5), point(1.4,1.3))         cup.setfill(color_rgb(97,76,26))         cup.setoutline(color_rgb(97,76,26))         cup.draw(win)          topoval = oval(point(0.6,1.2), point(1.5, 1.5))         topoval.setfill('white')         topoval.setoutline(color_rgb(97,76,26))         topoval.draw(win)          coffee = oval(point(0.7,1.26), point(1.4, 1.45))         coffee.setfill(color_rgb(71,54,14))         coffee.setoutline(color_rgb(71,54,14))         coffee.draw(win)          tinycirc = circle(point(1.05,0.8), .3)         tinycirc.setfill(color_rgb(33,158,87))         tinycirc.setoutline('white')         tinycirc.draw(win)          letter = text(point(1.05,0.8),"b")         letter.setstyle('bold italic')         letter.settextcolor('white')         letter.setface('courier')         letter.setsize(17)         letter.draw(win)          #bagel         outerbagel = oval(point(1.8, 0.4), point(2.7, 1))         outerbagel.setfill(color_rgb(191,157,61))         outerbagel.draw(win)          shadow = oval(point(2.1, 0.7), point(2.4, 0.8))         shadow.setfill(color_rgb(130,102,26))         shadow.draw(win)      elif(click.getx() > 4.2 , click.getx() < 5.8 , whitebagel <1 , wheatbagel <1):         errorwindow()  #end     point = win.getmouse()     if (point.getx() > 9 , point.getx() < 9.95):         win.close()  main() 

i need error window pop if bagels not selected order, example coffee , toppings not available delivery without bagels. think had in try/except, can't work either. either won't calculate totals , pops or calculates still pops error, or nothing happens! can't seem find direction on after closing pop up, go functioning main window. when close out error window, main window no longer works. i'd able that. lastly cannot use tkinter, graphics.py. apologize if crudely done, far it's way know. in advance advice.

i still hoping take pity on me , give me direction i'm going wrong code... have changed part i'm having issues it's still not working:

   try:     click = win.getmouse()      if click.getx() > 4.2 , click.getx() < 5.8 , whitebagel >0 , wheatbagel >0:          subtotal = whitetotal+wheattotal+creamtotal+buttertotal+jellytotal+regulartotal+decaftotal         tax = .06         taxes = subtotal*tax         total = taxes+subtotal          subtotal = "$%0.2f" % (subtotal)         taxes = "$%0.2f" % (taxes)         total = "$%0.2f" % (total)          subtotaloutput.settext(subtotal)         taxoutput.settext(taxes)         totaloutput.settext(total)          #coffee cup image         bottomoval = oval(point(0.7,0.4), point(1.4, 0.7))         bottomoval.setfill(color_rgb(97,76,26))         bottomoval.setoutline(color_rgb(97,76,26))         bottomoval.draw(win)          cup = rectangle(point(0.7,0.5), point(1.4,1.3))         cup.setfill(color_rgb(97,76,26))         cup.setoutline(color_rgb(97,76,26))         cup.draw(win)          topoval = oval(point(0.6,1.2), point(1.5, 1.5))         topoval.setfill('white')         topoval.setoutline(color_rgb(97,76,26))         topoval.draw(win)          coffee = oval(point(0.7,1.26), point(1.4, 1.45))         coffee.setfill(color_rgb(71,54,14))         coffee.setoutline(color_rgb(71,54,14))         coffee.draw(win)          tinycirc = circle(point(1.05,0.8), .3)         tinycirc.setfill(color_rgb(33,158,87))         tinycirc.setoutline('white')         tinycirc.draw(win)          letter = text(point(1.05,0.8),"b")         letter.setstyle('bold italic')         letter.settextcolor('white')         letter.setface('courier')         letter.setsize(17)         letter.draw(win)          #bagel         outerbagel = oval(point(1.8, 0.4), point(2.7, 1))         outerbagel.setfill(color_rgb(191,157,61))         outerbagel.draw(win)          shadow = oval(point(2.1, 0.7), point(2.4, 0.8))         shadow.setfill(color_rgb(130,102,26))         shadow.draw(win)  except:     errorwindow() 

i think i'm losing mind here amount of time i've been trying work...

first, tkinter not way go graphics. kinda old , lot of concepts there not turn out portable. again, use if there no other option...

second, code errorwindow not indented. when is, @ least 1 error popup. possibly not in right error condition.

third, put sort of check y coordinates of click well, since can trigger calculate button clicking anywhere in vertical column, wheat text box.

usually gui there sort of event loop processing multiple clicks. like:

while(true):    click = win.getmouse()    if calculate button:        text values        if not bagels:            errorwindow()            continue        calculate    elif quit button:        break 

i made modified version had event loop structured way , got give multiple totals, putting error when had no bagel order , keeping going.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -