Ejemplo n.º 1
0
 def __init__(self, ctrl,**kwargs):
     super(BaseModel,self).__init__()
     Subject.__init__(self)
     self.register_observer(ctrl)
     self.dirty = False
     self.file = None
     self._dom = None
     self._Scribbles = {}
     self._TextWidgets = {}
     self._Children = []
     self._Parent = None
     self._Model = None
     self._Id = None
     self._Name = None
     self._Description = None
     self._StartDate = None
     self._EstimateFinishDate = None
     self._EstimateHours = None
     self._ActualFinish = None
     self._ActualHours = None
     self._schema = kwargs['model_str']
     self.path = abspath(join(Config().datastore,kwargs['folder']))
     if not os.path.exists(self.path):
         os.mkdir(self.path)
     Log.debug('Creating skeleton %s' % self._schema)
     self.processXml(self.create_model(self._schema))
     self.Id = uuid()
     self.Name = kwargs.setdefault('name','')
     self.Description = kwargs.setdefault('description',' ')
     Log.debug( self._dom.toxml())
     self.dirty = True
Ejemplo n.º 2
0
 def __init__(self, w, minv, **kwargs):
     self.screen_size = get_min_screen_size()
     self.isMinimal = True if minv == 'minimal' else False
     self.root = w 
     self.view = None
     self.story_view_size = None
     self.id = uuid()
     self.createView()
Ejemplo n.º 3
0
 def __init__(self, w, minv):
     self.screen_size = get_min_screen_size()
     self.isMinimal = True if minv == "minimal" else False
     self.root = w
     self.view = None
     self.id = uuid()
     self.Scribbles = None
     self.TextFields = None
     self._name = None
     self._description = None
     self.story_view_size = None
Ejemplo n.º 4
0
 def __init__(self, **kwargs):
     kwargs.setdefault('size',(20,20))
     kwargs.setdefault('pos',(0,0))
     self.Id = kwargs.get('Id',uuid())
     kwargs.setdefault('keyboard_to_root', True)
     super(ScribbleTextWidget, self).__init__(**kwargs)
     self.editmode = True
     kwargs.setdefault('color',[1.0,1.0,1.0,1.0])
     kwargs.setdefault('font-size',kwargs['size'][1]/1.1)
     self.cdata = kwargs.get('label','')
     del kwargs['size']
     del kwargs['pos']
     self.label = ScribbleText(**kwargs)
     self.label.push_handlers(on_text_change=self.on_text_change)
     self.add_widget(self.label)
     self.size = self.label.size
     self.label.center = self.to_local(*self.center)
     self.register_event_type('on_text_change')
Ejemplo n.º 5
0
 def on_touch_down(self, touch):
     if self.collide_point(touch.x, touch.y):
         if not self.is_pen_active:
             #eraser is active we need to check if there is something to 
             #erase
             if self.erase_scribble(touch):
                 return True
             if self.erase_text_filed(touch):
                 return True
             if not self.current_color == self.bg_color:
                 self.current_color = self.bg_color
         if super(MyScribbleWidget,self).on_touch_down(touch):
             return True
         self.touch_time[touch.id] = (time.time(),touch)
         touch.grab(self)
         Log.debug('Scribble: on_touch_down: touch id:%s grabbed @ pos(%d,%d)' % 
                    (touch.id, touch.x,touch.y))
         idu = self.touch_keys[touch.id] = uuid()
         self.touch_positions[idu]= {'Id':idu, 'Color':self.current_color,
                                    'Cdata':[touch.pos]}
         self.touch_positions[idu]['moved'] = 0
         return True
Ejemplo n.º 6
0
 def __init__(self, **kwargs):
     kwargs.setdefault('cls', 'scribbleBordercss')
     super(MyScribbleWidget,self).__init__(**kwargs)
     self.session = uuid()
     self.is_pen_active = True
     self.sessions = kwargs.setdefault('sessions',{self.session:{}})
     self.press_and_hold_distance = \
         kwargs.setdefault('activate_keyboard_distance',10 /1000.0)
     self.delete_distance = kwargs.setdefault('delete_distance',12)
     self.potential_deleted_lines  = None
     self.potential_deleted_text  = None
     self.touch_time = {}
     self.old_touches = {}
     self.old_colors = {}
     self.touch_positions = {}
     self.touch_keys = {}
     self.touch_positions = kwargs.get('scribbles',{})
     self.travel_limit = 5
     self.keyboard = MTVKeyboard()
     tf = kwargs.get('TextFields', {})
     if tf:
         args = {'group':self.session,
                 'keyboard':self.keyboard,
                 'cls':'scribbleKeyboardcss'}
         for txt in tf.values():
             # we need to create and add the following textfields
             args['Id']=txt['Id'] 
             args['pos']=eval(txt['pos'])
             args['size']=eval(txt['size'])
             args['color']=txt['Color']
             args['font-size']=eval(txt['Font-Size'])
             args['label']=txt['Cdata']
             stw = ScribbleTextWidget(**args) #IGNORE:W0142
             stw.push_handlers(on_transform=curry(self.on_transform,stw))
             self.add_widget(stw)
     self.ctrls_container = MySidePanel(layout=MTGridLayout(cols=1),
                                        use_root=False,#duration=0.1,
                                     corner=MTImageButton(padding=5,
                             image=Loader.image(OPEN_SIDE_ICON),
                                                     size=(48,48)),
                                     corner_open=MTImageButton(padding=5,
                             image=Loader.image(CLOSE_SIDE_ICON),
                                                     size=(48,48)),
                                     align='middle',
                                     side='right',
                                     pos=(0,0),cls='mybtn')
     btn_pen = MTImageButton(padding=5,image=Loader.image(PEN_ICON))
     btn_pen.connect('on_press', self.pen)
     self.ctrls_container.add_widget(btn_pen)
     btn_erase = MTImageButton(padding=5,image=Loader.image(ERASER_ICON))
     btn_erase.connect('on_press', self.eraser)
     self.ctrls_container.add_widget(btn_erase)
     btn_color = MTImageButton(padding=5,image=Loader.image(COLOR_ICON))
     btn_color.connect('on_press', self.color)
     self.ctrls_container.add_widget(btn_color)
     self.add_widget(self.ctrls_container)
     self.current_color = DEFAULT_COLOR
     self.bg_color = self.style['bg-color']
     self.new_color = None
     self.border_color = self.style['border-color']
     self.border_width = self.style['border-width']
     self.register_event_type('on_change')
     self.register_event_type('on_text_change')