Ejemplo n.º 1
0
 def h2d(self):
     import my_constant
     import tkinter.messagebox as messagebox
     import tkinter.filedialog as filedialog
     import my_io
     import traceback
     play = self.master.master.play
     if not self.clan.h:
         FileMenu.read_h(self)
         if not self.clan.h: return
     path = filedialog.asksaveasfilename(**my_constant.donate_opt)
     if path:
         try:
             my_io.append_donate(None, path, mode='clear')
             my_io.append_history(None, path + '.clh', mode='clear')
             for item in self.clan.hv:
                 self.clan.imah.copyfrom(item)
                 play.InitFlag[0] = True
                 play.flash()
                 play.InitFlag[0] = False
                 my_io.append_donate(self.clan.imad, path, check_exist=False)
                 my_io.append_history(self.clan.imah, path+ '.clh', check_exist=False)
             play.cls()
         except Exception as e:
             print('path=%s\n%s'%(path,e))
             traceback.print_exc()
             messagebox.showerror('出错了!', '保存失败')
         else: messagebox.showinfo('保存成功!', '已保存至' + path)
Ejemplo n.º 2
0
 def save_as(self):
     import tkinter.messagebox as messagebox
     import tkinter.filedialog as filedialog
     import my_constant
     import my_io
     import traceback
     try:
         if self.clan.h:
             path = filedialog.asksaveasfilename(**my_constant.history_opt)
             if path:
                 my_io.append_history(None, path, mode='clear')
                 for item in self.clan.hv:
                     my_io.append_history(item, path, check_exist=False)
                 messagebox.showinfo('保存成功!', '已保存至' + path)
         if self.clan.d:
             path = filedialog.asksaveasfilename(**my_constant.donate_opt)
             if path:
                 my_io.append_donate(None, path, mode='clear')
                 for item in self.clan.dv:
                     my_io.append_donate(item, path, check_exist=False)
                 messagebox.showinfo('保存成功!', '已保存至' + path)
     except Exception as e:
         traceback.print_exc()
         messagebox.showerror('出错了!', '保存失败')
     self.master.master.focus_force()
Ejemplo n.º 3
0
 def save(self): # 保存操作
     import traceback
     import my_io
     import tkinter
     try: import tkinter.filedialog
     except: pass
     import my_constant
     if all(self.FlagList):
         if tkinter.messagebox.askyesno('确认',\
                                        '你确定要保存吗?如果文件已不存在将自动创建。'):
             path = tkinter.filedialog.asksaveasfilename(**my_constant.history_opt)
             if path:
                 try:
                     my_io.append_history(self.clan.imah, path)
                 except Exception as e:
                     traceback.print_exc()
                     tkinter.messagebox.showerror('出错了!', '保存失败')
                 else:
                     self.clan.addh(my_io.read_history(self.clan, path))
                     
             path = tkinter.filedialog.asksaveasfilename(**my_constant.donate_opt)
             if path:
                 try:
                     my_io.append_donate(self.clan.imad, path)
                 except Exception as e:
                     traceback.print_exc()
                     tkinter.messagebox.showerror('出错了!', '保存失败')
                 else:
                     self.clan.addd(my_io.read_donate(self.clan, path))
     else:
         tkinter.messagebox.showerror('出错了!', '信息不完整!战斗结束请添加"end"')