Ejemplo n.º 1
0
 def load (self, node):
     self.parent_number = self.child_number = -1
     tmp = node.getAttribute ("end")
     if not tmp:
         print "No tmp found"
         return
     self.end = utils.parse_coords (tmp)
     tmp = node.getAttribute ("start")
     if not tmp:
         print "No start found"
         return
     self.start = utils.parse_coords (tmp)
     self.strength = int(node.getAttribute ("strength"))
     try:
         colors = node.getAttribute ("color").split()
         self.color = (float(colors[0].strip('(,)')), float(colors[1].strip('(,)')), float(colors[2].strip('(,)')))
     except:
         pass
     if node.hasAttribute ("parent"):
         tmp = node.getAttribute ("parent")
         if tmp == "None":
             self.parent_number = -1
         else:
             self.parent_number = int (tmp)
     if node.hasAttribute ("child"):
         tmp = node.getAttribute ("child")
         if tmp == "None":
             self.child_number = -1
         else:
             self.child_number = int (tmp)
Ejemplo n.º 2
0
 def load(self, node):
     self.parent_number = self.child_number = -1
     tmp = node.getAttribute("end")
     if not tmp:
         print "No tmp found"
         return
     self.end = utils.parse_coords(tmp)
     tmp = node.getAttribute("start")
     if not tmp:
         print "No start found"
         return
     self.start = utils.parse_coords(tmp)
     self.strength = int(node.getAttribute("strength"))
     try:
         colors = node.getAttribute("color").split()
         self.color = (float(colors[0].strip('(,)')),
                       float(colors[1].strip('(,)')),
                       float(colors[2].strip('(,)')))
     except:
         pass
     if node.hasAttribute("parent"):
         tmp = node.getAttribute("parent")
         if tmp == "None":
             self.parent_number = -1
         else:
             self.parent_number = int(tmp)
     if node.hasAttribute("child"):
         tmp = node.getAttribute("child")
         if tmp == "None":
             self.child_number = -1
         else:
             self.child_number = int(tmp)
Ejemplo n.º 3
0
    def load (self, node, tar):
        tmp = node.getAttribute ("ul-coords")
        self.ul = utils.parse_coords (tmp)
        tmp = node.getAttribute ("lr-coords")
        self.lr = utils.parse_coords (tmp)
        self.filename = os.path.join('images', 
                os.path.basename(node.getAttribute ("file")))
        self.identity = int (node.getAttribute ("identity"))
        try:
            tmp = node.getAttribute ("background-color")
            self.background_color = Gdk.Color.parse(tmp)

        except ValueError:
            pass

        self.width = float(node.getAttribute ("image_width"))
        self.height = float(node.getAttribute ("image_height"))
        self.am_selected = node.hasAttribute ("current_root")
        self.am_primary = node.hasAttribute ("primary_root")

        for n in node.childNodes:
            if n.nodeName == "Extended":
                self.extended_buffer.load(n)
            else:
                print "Unknown: "+n.nodeName
        margin = utils.margin_required (utils.STYLE_NORMAL)
        self.pic_location = (self.ul[0]+margin[0], self.ul[1]+margin[1])
        self.orig_pic = tar.read_pixbuf(self.filename)
        self.lr = (self.pic_location[0]+self.width+margin[2], self.pic_location[1]+self.height+margin[3])
        self.recalc_edges()
Ejemplo n.º 4
0
    def load(self, node, tar):
        tmp = node.getAttribute("ul-coords")
        self.ul = utils.parse_coords(tmp)
        tmp = node.getAttribute("lr-coords")
        self.lr = utils.parse_coords(tmp)
        self.filename = os.path.join(
            'images', os.path.basename(node.getAttribute("file")))
        self.identity = int(node.getAttribute("identity"))
        try:
            tmp = node.getAttribute("background-color")
            self.background_color = Gdk.Color.parse(tmp)

        except ValueError:
            pass

        self.width = float(node.getAttribute("image_width"))
        self.height = float(node.getAttribute("image_height"))
        self.am_selected = node.hasAttribute("current_root")
        self.am_primary = node.hasAttribute("primary_root")

        for n in node.childNodes:
            if n.nodeName == "Extended":
                self.extended_buffer.load(n)
            else:
                print("Unknown: " + n.nodeName)
        margin = utils.margin_required(utils.STYLE_NORMAL)
        self.pic_location = (self.ul[0] + margin[0], self.ul[1] + margin[1])
        self.orig_pic = tar.read_pixbuf(self.filename)
        self.lr = (self.pic_location[0] + self.width + margin[2],
                   self.pic_location[1] + self.height + margin[3])
        self.recalc_edges()
Ejemplo n.º 5
0
    def load(self, node, tar):
        self.index = int(node.getAttribute("cursor"))
        self.end_index = self.index
        tmp = node.getAttribute("ul-coords")
        self.ul = utils.parse_coords(tmp)
        tmp = node.getAttribute("lr-coords")
        self.lr = utils.parse_coords(tmp)

        self.width = self.lr[0] - self.ul[0]
        self.height = self.lr[1] - self.ul[1]

        self.identity = int(node.getAttribute("identity"))
        try:
            tmp = node.getAttribute("background-color")
            self.background_color = Gdk.Color.parse(tmp)
            tmp = node.getAttribute("foreground-color")
            self.foreground_color = Gdk.Color.parse(tmp)
        except ValueError:
            pass

        self.am_selected = node.hasAttribute("current_root")
        self.am_primary = node.hasAttribute("primary_root")

        if node.getAttribute("edge") == "True":
            self.edge = True
        else:
            self.edge = False

        for n in node.childNodes:
            if n.nodeType == n.TEXT_NODE:
                self.text = n.data
            elif n.nodeName == "Extended":
                self.extended_buffer.load(n)
            elif n.nodeName == "attribute":
                attrType = n.getAttribute("type")
                start = int(n.getAttribute("start"))
                end = int(n.getAttribute("end"))

                attr = None  ## FIXME: REMOVE THIS

                # FIXME: Apply from start to end
                if attrType == "bold":
                    attr = Pango.Weight(Pango.Weight.BOLD)
                elif attrType == "italics":
                    attr = Pango.Style(Pango.Style.ITALIC)
                elif attrType == "underline":
                    attr = Pango.Underline(Pango.Underline.SINGLE)
                elif attrType == "font":
                    #font_name = str(n.getAttribute("value"))
                    #pango_font = Pango.FontDescription (font_name)
                    #attr = pango.AttrFontDesc (pango_font, start, end)
                    pass

                if attr:  ## FIXME: REMOVE THIS
                    self.attributes.change(attr)
            else:
                print("Unknown: " + n.nodeName)
        self.rebuild_byte_table()
        self.recalc_edges()
Ejemplo n.º 6
0
    def load(self, node):
        self.index = int(node.getAttribute("cursor"))
        if node.hasAttribute("selection_end"):
            self.end_index = int(node.getAttribute("selection_end"))
        else:
            self.end_index = self.index
        tmp = node.getAttribute("ul-coords")
        self.ul = utils.parse_coords(tmp)
        tmp = node.getAttribute("lr-coords")
        self.lr = utils.parse_coords(tmp)
        self.identity = int(node.getAttribute("identity"))
        try:
            tmp = node.getAttribute("background-color")
            self.background_color = gtk.gdk.color_parse(tmp)
            tmp = node.getAttribute("foreground-color")
            self.foreground_color = gtk.gdk.color_parse(tmp)
        except ValueError:
            pass

        if node.hasAttribute("edit"):
            self.editing = True
        else:
            self.editing = False
            self.end_index = self.index

        self.am_selected = node.hasAttribute("current_root")
        self.am_primary = node.hasAttribute("primary_root")

        for n in node.childNodes:
            if n.nodeType == n.TEXT_NODE:
                self.text = n.data
            elif n.nodeName == "Extended":
                self.extended_buffer.load(n)
            elif n.nodeName == "attribute":
                attrType = n.getAttribute("type")
                start = int(n.getAttribute("start"))
                end = int(n.getAttribute("end"))

                if attrType == "bold":
                    attr = pango.AttrWeight(pango.WEIGHT_BOLD, start, end)
                elif attrType == "italics":
                    attr = pango.AttrStyle(pango.STYLE_ITALIC, start, end)
                elif attrType == "underline":
                    attr = pango.AttrUnderline(pango.UNDERLINE_SINGLE, start,
                                               end)
                elif attrType == "font":
                    font_name = str(n.getAttribute("value"))
                    pango_font = pango.FontDescription(font_name)
                    attr = pango.AttrFontDesc(pango_font, start, end)
                self.attributes.change(attr)
            else:
                print "Unknown: " + n.nodeName
        self.rebuild_byte_table()
        self.recalc_edges()
Ejemplo n.º 7
0
    def load (self, node):
        self.index = int (node.getAttribute ("cursor"))
        if node.hasAttribute ("selection_end"):
            self.end_index = int (node.getAttribute ("selection_end"))
        else:
            self.end_index = self.index
        tmp = node.getAttribute ("ul-coords")
        self.ul = utils.parse_coords (tmp)
        tmp = node.getAttribute ("lr-coords")
        self.lr = utils.parse_coords (tmp)
        self.identity = int (node.getAttribute ("identity"))
        try:
            tmp = node.getAttribute ("background-color")
            self.background_color = gtk.gdk.color_parse(tmp)
            tmp = node.getAttribute ("foreground-color")
            self.foreground_color = gtk.gdk.color_parse(tmp)
        except ValueError:
            pass

        if node.hasAttribute ("edit"):
            self.editing = True
        else:
            self.editing = False
            self.end_index = self.index

        self.am_selected = node.hasAttribute ("current_root")
        self.am_primary = node.hasAttribute ("primary_root")

        for n in node.childNodes:
            if n.nodeType == n.TEXT_NODE:
                self.text = n.data
            elif n.nodeName == "Extended":
                self.extended_buffer.load(n)
            elif n.nodeName == "attribute":
                attrType = n.getAttribute("type")
                start = int(n.getAttribute("start"))
                end = int(n.getAttribute("end"))

                if attrType == "bold":
                    attr = pango.AttrWeight(pango.WEIGHT_BOLD, start, end)
                elif attrType == "italics":
                    attr = pango.AttrStyle(pango.STYLE_ITALIC, start, end)
                elif attrType == "underline":
                    attr = pango.AttrUnderline(pango.UNDERLINE_SINGLE, start, end)
                elif attrType == "font":
                    font_name = str(n.getAttribute("value"))
                    pango_font = pango.FontDescription (font_name)
                    attr = pango.AttrFontDesc (pango_font, start, end)
                self.attributes.change(attr)
            else:
                print "Unknown: " + n.nodeName
        self.rebuild_byte_table ()
        self.recalc_edges ()
Ejemplo n.º 8
0
	def load (self, node, tar):
		tmp = node.getAttribute ("ul-coords")
		self.ul = utils.parse_coords (tmp)
		tmp = node.getAttribute ("lr-coords")
		self.lr = utils.parse_coords (tmp)
		self.identity = int (node.getAttribute ("identity"))
		try:
			tmp = node.getAttribute ("background-color")
			self.background_color = gtk.gdk.color_parse(tmp)
			tmp = node.getAttribute ("foreground-color")
			self.foreground_color = gtk.gdk.color_parse(tmp)
		except ValueError:
			pass

		def get_min_max(node, name):
			attr = node.getAttribute(name)
			if attr == 'None':
				return None
			else:
				return float(attr)

		self.min_x = get_min_max(node, 'min_x')
		self.min_y = get_min_max(node, 'min_y')
		self.max_x = get_min_max(node, 'max_x')
		self.max_y = get_min_max(node, 'max_y')

		self.width = self.lr[0] - self.ul[0]
		self.height = self.lr[1] - self.ul[1]

		self.am_selected = node.hasAttribute ("current_root")
		self.am_primary = node.hasAttribute ("primary_root")

		for n in node.childNodes:
			if n.nodeName == "Extended":
				self.extended_buffer.load(n)
			elif n.nodeName == "point":
				style = int (n.getAttribute ("type"))
				tmp = n.getAttribute ("coords")
				c = utils.parse_coords (tmp)
				col = None
				try:
					tmp = n.getAttribute ("color")
					col = gtk.gdk.color_parse (tmp)
				except ValueError:
					pass
				self.points.append (self.DrawingPoint (c, style, col))
			else:
				print "Unknown node type: "+str(n.nodeName)
Ejemplo n.º 9
0
	def load (self, node, tar):
		tmp = node.getAttribute ("ul-coords")
		self.ul = utils.parse_coords (tmp)
		tmp = node.getAttribute ("lr-coords")
		self.lr = utils.parse_coords (tmp)
		self.identity = int (node.getAttribute ("identity"))
		try:
			tmp = node.getAttribute ("background-color")
			self.background_color = Gdk.Color.parse(tmp)[1]
			tmp = node.getAttribute ("foreground-color")
			self.foreground_color = Gdk.Color.parse(tmp)[1]
		except ValueError:
			pass

		def get_min_max(node, name):
			attr = node.getAttribute(name)
			if attr == 'None':
				return None
			else:
				return float(attr)

		self.min_x = get_min_max(node, 'min_x')
		self.min_y = get_min_max(node, 'min_y')
		self.max_x = get_min_max(node, 'max_x')
		self.max_y = get_min_max(node, 'max_y')

		self.width = self.lr[0] - self.ul[0]
		self.height = self.lr[1] - self.ul[1]

		self.am_selected = node.hasAttribute ("current_root")
		self.am_primary = node.hasAttribute ("primary_root")

		for n in node.childNodes:
			if n.nodeName == "Extended":
				self.extended_buffer.load(n)
			elif n.nodeName == "point":
				style = int (n.getAttribute ("type"))
				tmp = n.getAttribute ("coords")
				c = utils.parse_coords (tmp)
				col = None
				try:
					tmp = n.getAttribute ("color")
					col = Gdk.Color.parse(tmp)[1]
				except ValueError:
					pass
				self.points.append (self.DrawingPoint (c, style, col))
			else:
				print ("Unknown node type: "+str(n.nodeName))
Ejemplo n.º 10
0
    def load (self, node, tar):
        self.index = 0 ##int (node.getAttribute ("cursor"))
        self.end_index = self.index
        tmp = node.getAttribute ("ul-coords")
        self.ul = utils.parse_coords (tmp)
        tmp = node.getAttribute ("lr-coords")
        self.lr = utils.parse_coords (tmp)

        self.width = self.lr[0] - self.ul[0]
        self.height = self.lr[1] - self.ul[1]

        self.identity = 0 ##int (node.getAttribute ("identity"))
        try:
            tmp = node.getAttribute ("background-color")
            self.background_color = Gdk.Color.parse(tmp)
            tmp = node.getAttribute ("foreground-color")
            self.foreground_color = Gdk.Color.parse(tmp)
        except ValueError:
            pass

        self.am_selected = node.hasAttribute ("current_root")
        self.am_primary = node.hasAttribute ("primary_root")

        for n in node.childNodes:
            if n.nodeType == n.TEXT_NODE:
                self.text = n.data
            elif n.nodeName == "Extended":
                self.extended_buffer.load(n)
            elif n.nodeName == "attribute":
                attrType = n.getAttribute("type")
                start = int(n.getAttribute("start"))
                end = int(n.getAttribute("end"))

                if attrType == "bold":
                    self.attributes["bold"] = True
                elif attrType == "italics":
                    self.atributes["italic"] = True
                elif attrType == "underline":
                    self.attributes["underline"] = True
                ##elif attrType == "font":
                ##    self.attributes["font"] = font
            else:
                print "Unknown: "+n.nodeName
        self.rebuild_byte_table ()
        self.recalc_edges()
Ejemplo n.º 11
0
    def load(self, node, tar):
        self.index = 0  ##int (node.getAttribute ("cursor"))
        self.end_index = self.index
        tmp = node.getAttribute("ul-coords")
        self.ul = utils.parse_coords(tmp)
        tmp = node.getAttribute("lr-coords")
        self.lr = utils.parse_coords(tmp)

        self.width = self.lr[0] - self.ul[0]
        self.height = self.lr[1] - self.ul[1]

        self.identity = 0  ##int (node.getAttribute ("identity"))
        try:
            tmp = node.getAttribute("background-color")
            self.background_color = Gdk.Color.parse(tmp)
            tmp = node.getAttribute("foreground-color")
            self.foreground_color = Gdk.Color.parse(tmp)
        except ValueError:
            pass

        self.am_selected = node.hasAttribute("current_root")
        self.am_primary = node.hasAttribute("primary_root")

        for n in node.childNodes:
            if n.nodeType == n.TEXT_NODE:
                self.text = n.data
            elif n.nodeName == "Extended":
                self.extended_buffer.load(n)
            elif n.nodeName == "attribute":
                attrType = n.getAttribute("type")
                start = int(n.getAttribute("start"))
                end = int(n.getAttribute("end"))

                if attrType == "bold":
                    self.attributes["bold"] = True
                elif attrType == "italics":
                    self.atributes["italic"] = True
                elif attrType == "underline":
                    self.attributes["underline"] = True
                ##elif attrType == "font":
                ##    self.attributes["font"] = font
            else:
                print "Unknown: " + n.nodeName
        self.rebuild_byte_table()
        self.recalc_edges()
Ejemplo n.º 12
0
    def load(self, node):
        tmp = node.getAttribute("ul-coords")
        self.ul = utils.parse_coords(tmp)
        tmp = node.getAttribute("lr-coords")
        self.lr = utils.parse_coords(tmp)
        self.filename = node.getAttribute("file")
        self.identity = int(node.getAttribute("identity"))
        try:
            tmp = node.getAttribute("background-color")
            self.background_color = gtk.gdk.color_parse(tmp)
        except ValueError:
            pass
        self.width = float(node.getAttribute("image_width"))
        self.height = float(node.getAttribute("image_height"))
        self.am_selected = node.hasAttribute("current_root")
        self.am_primary = node.hasAttribute("primary_root")

        for n in node.childNodes:
            if n.nodeName == "Extended":
                self.extended_buffer.load(n)
            else:
                print "Unknown: " + n.nodeName
        margin = utils.margin_required(utils.STYLE_NORMAL)
        self.pic_location = (self.ul[0] + margin[0], self.ul[1] + margin[1])
        self.okay = self.open_image(self.filename)
        self.lr = (self.pic_location[0] + self.width + margin[2],
                   self.pic_location[1] + self.height + margin[3])
        if not self.okay:
            dialog = gtk.MessageDialog(
                None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE,
                _("Error loading file"))
            dialog.format_secondary_text(
                _("%s could not be found.  Associated thought will be empty." %
                  self.filename))
            dialog.run()
            dialog.hide()
            self.pic = None
            self.orig_pic = None
        else:
            self.pic = self.orig_pic.scale_simple(int(self.width),
                                                  int(self.height),
                                                  gtk.gdk.INTERP_HYPER)
        return
Ejemplo n.º 13
0
    def parse_file(self, filename):
        with open(filename, 'r') as f:
            doc = dom.parse(f)
        top_element = doc.documentElement
        self.title_cp = top_element.getAttribute("title")
        self.mode = int(top_element.getAttribute("mode"))
        if top_element.hasAttribute("maximised"):
            maxi = top_element.getAttribute("maximised")
        else:
            maxi = False
        if maxi == "True":
            self.main_window.maximize()
        if top_element.hasAttribute("pane_position"):
            self.pane_pos = int(top_element.getAttribute("pane_position"))
        else:
            self.pane_pos = 500
        if top_element.hasAttribute("view_type"):
            vt = int(top_element.getAttribute("view_type"))
        else:
            vt = 0
        self.extended_visible = vt == 1

        tmp = top_element.getAttribute("size")
        (width, height) = utils.parse_coords(tmp)
        tmp = top_element.getAttribute("position")
        (x, y) = utils.parse_coords(tmp)
        self.main_window.resize(int(width), int(height))

        # Don't know why, but metacity seems to move the window 24 pixels
        # further down than requested.  Compensate by removing 24
        # pixels from the stored size
        y -= 24
        self.main_window.move(int(x), int(y))

        self.MainArea.set_mode(self.mode)
        self.MainArea.load_thyself(top_element, doc)
        if top_element.hasAttribute("scale_factor"):
            self.MainArea.scale_fac = float(
                top_element.getAttribute("scale_factor"))
        if top_element.hasAttribute("translation"):
            tmp = top_element.getAttribute("translation")
            (x, y) = utils.parse_coords(tmp)
            self.MainArea.translation = [x, y]
Ejemplo n.º 14
0
    def parse_file (self, filename):
        with open(filename, 'r') as f:
            doc = dom.parse(f)
        top_element = doc.documentElement
        self.title_cp = top_element.getAttribute ("title")
        self.mode = int (top_element.getAttribute ("mode"))
        if top_element.hasAttribute ("maximised"):
            maxi = top_element.getAttribute ("maximised")
        else:
            maxi = False
        if maxi == "True":
            self.main_window.maximize ()
        if top_element.hasAttribute ("pane_position"):
            self.pane_pos = int (top_element.getAttribute ("pane_position"))
        else:
            self.pane_pos = 500
        if top_element.hasAttribute ("view_type"):
            vt = int (top_element.getAttribute ("view_type"))
        else:
            vt = 0
        self.extended_visible = vt == 1

        tmp = top_element.getAttribute ("size")
        (width, height) = utils.parse_coords (tmp)
        tmp = top_element.getAttribute ("position")
        (x, y) = utils.parse_coords (tmp)
        self.main_window.resize (int (width), int (height))

        # Don't know why, but metacity seems to move the window 24 pixels
        # further down than requested.  Compensate by removing 24
        # pixels from the stored size
        y -= 24
        self.main_window.move (int (x), int (y))

        self.MainArea.set_mode (self.mode)
        self.MainArea.load_thyself (top_element, doc)
        if top_element.hasAttribute("scale_factor"):
            self.MainArea.scale_fac = float (top_element.getAttribute ("scale_factor"))
        if top_element.hasAttribute("translation"):
            tmp = top_element.getAttribute("translation")
            (x,y) = utils.parse_coords(tmp)
            self.MainArea.translation = [x,y]
Ejemplo n.º 15
0
    def load (self, node):
        tmp = node.getAttribute ("ul-coords")
        self.ul = utils.parse_coords (tmp)
        tmp = node.getAttribute ("lr-coords")
        self.lr = utils.parse_coords (tmp)
        self.identity = int (node.getAttribute ("identity"))
        try:
            tmp = node.getAttribute ("background-color")
            self.background_color = gtk.gdk.color_parse(tmp)
            tmp = node.getAttribute ("foreground-color")
            self.foreground_color = gtk.gdk.color_parse(tmp)
        except ValueError:
            pass
        self.min_x = float(node.getAttribute ("min_x"))
        self.min_y = float(node.getAttribute ("min_y"))
        self.max_x = float(node.getAttribute ("max_x"))
        self.max_y = float(node.getAttribute ("max_y"))

        self.width = self.lr[0] - self.ul[0]
        self.height = self.lr[1] - self.ul[1]

        self.am_selected = node.hasAttribute ("current_root")
        self.am_primary = node.hasAttribute ("primary_root")

        for n in node.childNodes:
            if n.nodeName == "Extended":
                self.extended_buffer.load(n)
            elif n.nodeName == "point":
                style = int (n.getAttribute ("type"))
                tmp = n.getAttribute ("coords")
                c = utils.parse_coords (tmp)
                col = None
                try:
                    tmp = n.getAttribute ("color")
                    col = gtk.gdk.color_parse (tmp)
                except ValueError:
                    pass
                self.points.append (self.DrawingPoint (c, style, col))
            else:
                print "Unknown node type: "+str(n.nodeName)
Ejemplo n.º 16
0
    def load (self, node):
        tmp = node.getAttribute ("ul-coords")
        self.ul = utils.parse_coords (tmp)
        tmp = node.getAttribute ("lr-coords")
        self.lr = utils.parse_coords (tmp)
        self.filename = node.getAttribute ("file")
        self.identity = int (node.getAttribute ("identity"))
        try:
            tmp = node.getAttribute ("background-color")
            self.background_color = gtk.gdk.color_parse(tmp)
        except ValueError:
            pass
        self.width = float(node.getAttribute ("image_width"))
        self.height = float(node.getAttribute ("image_height"))
        self.am_selected = node.hasAttribute ("current_root")
        self.am_primary = node.hasAttribute ("primary_root")

        for n in node.childNodes:
            if n.nodeName == "Extended":
                self.extended_buffer.load(n)
            else:
                print "Unknown: "+n.nodeName
        margin = utils.margin_required (utils.STYLE_NORMAL)
        self.pic_location = (self.ul[0]+margin[0], self.ul[1]+margin[1])
        self.okay = self.open_image (self.filename)
        self.lr = (self.pic_location[0]+self.width+margin[2], self.pic_location[1]+self.height+margin[3])
        if not self.okay:
            dialog = gtk.MessageDialog (None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                                                    gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE,
                                                                    _("Error loading file"))
            dialog.format_secondary_text (_("%s could not be found.  Associated thought will be empty."%self.filename))
            dialog.run ()
            dialog.hide ()
            self.pic = None
            self.orig_pic = None
        else:
            self.pic = self.orig_pic.scale_simple (int(self.width), int(self.height), gtk.gdk.INTERP_HYPER)
        return
Ejemplo n.º 17
0
    def read_file(self, file_path):
        tar = Tarball(file_path)

        doc = dom.parseString(tar.read(tar.getnames()[0]))
        top_element = doc.documentElement

        self.set_title(top_element.getAttribute("title"))
        self._mode = int(top_element.getAttribute("mode"))

        self._main_area.set_mode(self._mode)
        self._main_area.load_thyself(top_element, doc, tar)

        if top_element.hasAttribute("scale_factor"):
            fac = float(top_element.getAttribute("scale_factor"))
            self._main_area.scale_fac = fac

        if top_element.hasAttribute("translation"):
            tmp = top_element.getAttribute("translation")
            x, y = utils.parse_coords(tmp)
            self._main_area.translation = [x, y]

        tar.close()
    def read_file(self, file_path):
        tar = Tarball(file_path)

        doc = dom.parseString(tar.read(tar.getnames()[0]))
        top_element = doc.documentElement

        self.set_title(top_element.getAttribute("title"))
        self._mode = int(top_element.getAttribute("mode"))

        self._main_area.set_mode(self._mode)
        self._main_area.load_thyself(top_element, doc, tar)

        if top_element.hasAttribute("scale_factor"):
            fac = float(top_element.getAttribute("scale_factor"))
            self._main_area.scale_fac = fac

        if top_element.hasAttribute("translation"):
            tmp = top_element.getAttribute("translation")
            x, y = utils.parse_coords(tmp)
            self._main_area.translation = [x, y]

        tar.close()
Ejemplo n.º 19
0
def tile(zoom, xtile, ytile, image_type):
    if image_type not in ('png', 'jpg'):
        raise
    metasize = 1 if zoom < 2 else 2
    bbox = parse_coords(256, metasize, zoom, xtile, ytile)
    return Response(render(map, bbox, 256, 256), content_type='image/png')