猴辣么大声干嘛 发表于 2018-9-12 22:52:58

如何返回 easygui的 multenterbox 按钮的值

又是我。。
小白在写python第37课的作业时,突然想用gui来完成操作 然后发现在进行到multenterbox的时候 如果用户点击cancel退出的时候 程序会直接退出,缺少确认的机制,健全性不足,小白想问下大佬们 怎么样可以返回OK 或者 Cancel的值 以便使程序更加健全
附上代码:
import easygui as g

class AmusePark:
    ticketPrice = 100
   
    def getPrice(self):
      
      title="购票系统"
      msg="你要购买周末的票吗(票价是平日的120%)"
      choices=["是的","不是"]
      isWeekend = g.ccbox(msg,title, choices)
      
      Count=[]
      msg="填入你想购票的数量"
      fields=["成年人","儿童"]
      
      Count=g.multenterbox(msg,title, fields,)
      totalPrice=int(Count)*100+int(Count)*50
      if isWeekend:
            msg="你的购票信息如下:周末票\n成人票:%s张,儿童票:%s张\n 总价为:%.2f" %(Count,Count,totalPrice*1.2)
      else :
            msg="你的购票信息如下:平日票\n成人票:%s张,儿童票:%s张\n 总价为:%.2f" %(Count,Count,totalPrice)
      title="信息确认"
      choices=["确认无误","信息有误重新购买"]
      choice = g.ccbox(msg, title, choices)
      if choice:
            pass
      else :
            self.getPrice()
            exit()
            
      if isWeekend :
            msg="你所购买的票价一共是:%.2f" % (totalPrice*1.2)
            ok_button="确定"
            g.msgbox(msg, title, ok_button)
      else:
            msg="你所购买的票价一共是:%.2f" % totalPrice
            ok_button="确定"
            g.msgbox(msg, title, ok_button)
            
Ticket = AmusePark()
Ticket.getPrice()

猴辣么大声干嘛 发表于 2018-9-12 22:55:28

帮自己D一下

claws0n 发表于 2018-9-12 23:28:46

#18.   int(fieldValues)*100 + int(fieldValues)*50
页: [1]
查看完整版本: 如何返回 easygui的 multenterbox 按钮的值