class LogBehavior(object): log_manager = LogManager(construct_data_resource('logs/')) def on_touch_down(self, touch): log_manager = self.log_manager if self in touch.ud and log_manager.do_logging: print(self, 'in on touch dwon') coords = (touch.x, touch.y) log_interface = log_manager.log_interface touch_id = log_manager.touch_id touch.ud['log_id'] = touch_id log_interface.set_entry('touches', touch_id, 'touch_down_at', coords, do_timestamp=True) log_manager.touch_id += 1 log_interface.set_entry('touches', 'last_touch_id', 'value', touch_id) return super(LogBehavior, self).on_touch_down(touch) def on_touch_move(self, touch): log_manager = self.log_manager if self in touch.ud and log_manager.do_logging: coords = (touch.x, touch.y) touch_id = touch.ud['log_id'] log_manager.log_interface.append_entry('touches', touch_id, 'touch_moves_at', coords, do_timestamp=True) return super(LogBehavior, self).on_touch_move(touch) def on_touch_up(self, touch): log_manager = self.log_manager if self in touch.ud and log_manager.do_logging: coords = (touch.x, touch.y) touch_id = touch.ud['log_id'] log_manager.log_interface.set_entry('touches', touch_id, 'touch_up_at', coords, do_timestamp=True) return super(LogBehavior, self).on_touch_up(touch)
def on_style_dict(self, instance, value): if value is not None: self.font_name = construct_data_resource('font/' + value.font_file) self.font_size = font_size = get_metric_conversion( value.size_mobile) self.color[3] = value.alpha
from kivy.uix.gridlayout import GridLayout from kivy.properties import (ListProperty, DictProperty, StringProperty, ObjectProperty, NumericProperty) from kivy.lang import Builder from flat_kivy.utils import construct_data_resource Builder.load_file( construct_data_resource('ui_elements.kv')) class ErrorContent(GridLayout): error_text = StringProperty('Default Error Text') class OptionContent(GridLayout): option_text = StringProperty('Default Option Text') options_dict = DictProperty(None) callback = ObjectProperty(None) dismiss_func = ObjectProperty(None) def __init__(self, options_dict, **kwargs): super(OptionContent, self).__init__(**kwargs) self.options_dict = options_dict self.populate_options(options_dict) def populate_options(self, options_dict): rem_wid = self.remove_widget add_wid = self.add_widget
def on_style_dict(self, instance, value): if value is not None: self.font_name = construct_data_resource("font/" + value.font_file) self.font_size = font_size = get_metric_conversion(value.size_mobile) self.color[3] = value.alpha
class LogNoTouchBehavior(object): log_manager = LogManager(construct_data_resource('logs/'))
from kivy.uix.gridlayout import GridLayout from kivy.properties import (ListProperty, DictProperty, StringProperty, ObjectProperty, NumericProperty) from kivy.lang import Builder from flat_kivy.utils import construct_data_resource Builder.load_file(construct_data_resource('ui_elements.kv')) class ErrorContent(GridLayout): error_text = StringProperty('Default Error Text') class OptionContent(GridLayout): option_text = StringProperty('Default Option Text') options_dict = DictProperty(None) callback = ObjectProperty(None) dismiss_func = ObjectProperty(None) def __init__(self, options_dict, **kwargs): super(OptionContent, self).__init__(**kwargs) self.options_dict = options_dict self.populate_options(options_dict) def populate_options(self, options_dict): rem_wid = self.remove_widget add_wid = self.add_widget for child in self.children: if isinstance(child, OptionButton): rem_wid(child)