from kivy.uix.floatlayout import FloatLayout
from kivy.graphics import Color, Rectangle
from kivy.uix.label import Label
+from kivy.uix.popup import Popup
from kivy.utils import platform
from kivy.config import Config
self.add_widget(save_label)
def do_save(self, label, ref):
- pass
+ try:
+ self.level_obj.validate()
+ except RuntimeError as err:
+ print err
+ popup = Popup(title='Error',
+ content=Label(text='Level not valid: %s' % err),
+ size_hint=(.5, .5))
+ popup.open()
+ return
+ save_data = self.level_obj.get_level_data()
+ savefile = file(filepath(self.level), 'w')
+ savefile.write(save_data)
+ savefile.write('\n')
+ savefile.close()
+ popup = Popup(title='Success',
+ content=Label(text='Level saved to %s' % self.level),
+ size_hint=(.5, .5))
+ popup.open()
+
def change_tool(self, label, ref):
self.tool = ref