def tagimage(self, imageurl, pageid, latcoord, longcoord, hood, username): imageurl = util.convertimageurl(imageurl) query = db.GqlQuery("SELECT * FROM ImageModel where imageurl = :1", imageurl) image = query.get() if image is None: image = ImageModel(usernameupdated=username, imageurl=imageurl, pageid=int(pageid), latcoord=latcoord, longcoord=longcoord, neighborhood=hood) else: image.usernameupdated = username image.imageurl = imageurl image.pageid = int(pageid) image.latcoord = latcoord image.longcoord = longcoord image.neighborhood = hood try: image.put() user = util.getuser(username) if (user is not None): user.count = user.count + 1 else: user = UserModel(username=username, count=1) user.put() return True except Exception, err: logging.error(str(err)) return False
def saveimagedictionary(self): logging.info("Starting saving") newimagecount = updatedimagecount = 0 imagestosave = [] for imagename in self.imagedictionary.keys(): dbimage = util.getimage(imagename) wikiimage = self.imagedictionary[imagename] if (dbimage is not None): dbimage.pageid = int(wikiimage[0]) dbimage.neighborhood = wikiimage[1] imagetosave = dbimage updatedimagecount = updatedimagecount + 1 else: imagetosave = ImageModel(pageid=int(wikiimage[0]), imageurl=imagename, neighborhood=wikiimage[1], usernameupdated='WikiUser') savedimagecount = savedimagecount + 1 imagestosave.append(imagetosave) try: db.put(imagestosave) except Exception, err: logging.error(str(err))
def start_app(self): labels = [LabelModel() for _ in range(100)] self.image = Factory.MainImage(ImageModel()) self.root.ids.image_box.add_widget(self.image) self.exif = Factory.GetExifData(ButtonModel(image=self.image, labels=labels)) self.root.ids.button_box.add_widget(self.exif) right = Factory.RotateRight(self.exif.model) self.root.ids.button_box.add_widget(right) left = Factory.RotateLeft(self.exif.model) self.root.ids.button_box.add_widget(left) loc = Factory.GetLocation(self.exif.model) self.root.ids.button_box.add_widget(loc) next = Factory.NextImage(self.exif.model) self.root.ids.cycle_box.add_widget(next) prev = Factory.PreviousImage(self.exif.model) self.root.ids.cycle_box.add_widget(prev) get = Factory.OpenImage(self.exif.model) self.root.ids.button_box.add_widget(get) lab = Factory.ExifLabel(LabelModel()) self.root.ids.exif_container.add_widget(lab) list_adapter = SimpleListAdapter( data=labels, args_converter=lambda row, model: {'model': model, 'size_hint_y': None, 'height':100}, cls=Factory.ExifTags) self.root.ids.exif_container.add_widget(ListView(adapter=list_adapter))
def dialog_edit_image_property(self): propwin = ImagePropWin.get_instance() if not self.model: self.model = ImageModel() propwin.set_model(self.model) if not propwin.is_visible(): propwin.show() # Move window near the main window app parent = self.get_parent_window().get_effective_parent() _dont_care_, parent_x, parent_y = parent.get_origin() parent_w = parent.get_width() parent_h = parent.get_height() propwin.move(parent_x + parent_w, parent_y)
def _block_new(self, block_type=PARAGRAPH): #print("_block_new:") if block_type == SubdocView.PARAGRAPH: buf = EditorTextBuffer() widget = EditorTextView(self.elements_toolbar, self.notebook_app) widget.set_buffer(buf) self.add(widget) elif block_type == SubdocView.IMAGE: #print("Image insertion asked") widget = ImageView() self.add(widget) model = ImageModel() widget.set_model(model) else: raise NotImplementedError widget.connect("focus-in-event", self.on_child_focus_in) widget.connect("cursor-move", self.on_child_cursor_move) #self.add(widget) return widget