當前位置: 首頁>>代碼示例>>Python>>正文


Python inkex.errormsg方法代碼示例

本文整理匯總了Python中inkex.errormsg方法的典型用法代碼示例。如果您正苦於以下問題:Python inkex.errormsg方法的具體用法?Python inkex.errormsg怎麽用?Python inkex.errormsg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在inkex的用法示例。


在下文中一共展示了inkex.errormsg方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: query

# 需要導入模塊: import inkex [as 別名]
# 或者: from inkex import errormsg [as 別名]
def query(port_name, cmd):
    if port_name is not None and cmd is not None:
        response = ''
        try:
            port_name.write(cmd.encode('ascii'))
            response = port_name.readline().decode('ascii')
            n_retry_count = 0
            while len(response) == 0 and n_retry_count < 100:
                # get new response to replace null response if necessary
                response = port_name.readline()
                n_retry_count += 1
            if cmd.strip().lower() not in ["v", "i", "a", "mr", "pi", "qm"]:
                # Most queries return an "OK" after the data requested.
                # We skip this for those few queries that do not return an extra line.
                unused_response = port_name.readline()  # read in extra blank/OK line
                n_retry_count = 0
                while len(unused_response) == 0 and n_retry_count < 100:
                    # get new response to replace null response if necessary
                    unused_response = port_name.readline()
                    n_retry_count += 1
        except:
            inkex.errormsg(gettext.gettext("Error reading serial data."))
        return response 
開發者ID:evil-mad,項目名稱:axidraw,代碼行數:25,代碼來源:ebb_serial.py

示例2: command

# 需要導入模塊: import inkex [as 別名]
# 或者: from inkex import errormsg [as 別名]
def command(port_name, cmd):
    if port_name is not None and cmd is not None:
        try:
            port_name.write(cmd.encode('ascii'))
            response = port_name.readline().decode('ascii')
            n_retry_count = 0
            while len(response) == 0 and n_retry_count < 100:
                # get new response to replace null response if necessary
                response = port_name.readline().decode('ascii')
                n_retry_count += 1
            if response.strip().startswith("OK"):
                # Debug option: indicate which command:
                # inkex.errormsg( 'OK after command: ' + cmd )
                pass
            else:
                if response:
                    inkex.errormsg('Error: Unexpected response from EBB.')
                    inkex.errormsg('   Command: {0}'.format(cmd.strip()))
                    inkex.errormsg('   Response: {0}'.format(response.strip()))
                else:
                    inkex.errormsg('EBB Serial Timeout after command: {0}'.format(cmd))
        except:
            if cmd.strip().lower() not in ["rb"]: # Ignore error on reboot (RB) command
	            inkex.errormsg('Failed after command: {0}'.format(cmd)) 
開發者ID:evil-mad,項目名稱:axidraw,代碼行數:26,代碼來源:ebb_serial.py

示例3: show_messages

# 需要導入模塊: import inkex [as 別名]
# 或者: from inkex import errormsg [as 別名]
def show_messages(self):
        import sys
        version_is_good = (2, 7) <= sys.version_info < (3, 0)
        if version_is_good:
            import inkex
            """show messages to user and empty buffer"""
            inkex.errormsg("\n".join([self.format(record) for record in self.buffer]))
        else:
            sys.stderr.write("\n".join([self.format(record) for record in self.buffer]))
        self.flush() 
開發者ID:textext,項目名稱:textext,代碼行數:12,代碼來源:utility.py

示例4: text_log

# 需要導入模塊: import inkex [as 別名]
# 或者: from inkex import errormsg [as 別名]
def text_log(self,text_to_add):
        if not self.Secondary:
            inkex.errormsg(text_to_add)
        else:
            self.text_out = self.text_out + '\n' + text_to_add 
開發者ID:evil-mad,項目名稱:axidraw,代碼行數:7,代碼來源:axidraw.py

示例5: error_log

# 需要導入模塊: import inkex [as 別名]
# 或者: from inkex import errormsg [as 別名]
def error_log(self,text_to_add):
        if not self.Secondary:
            inkex.errormsg(text_to_add)
        else:
            self.error_out = self.error_out + '\n' + text_to_add 
開發者ID:evil-mad,項目名稱:axidraw,代碼行數:7,代碼來源:axidraw.py

示例6: effect

# 需要導入模塊: import inkex [as 別名]
# 或者: from inkex import errormsg [as 別名]
def effect(self):
        """Convert the SVG to an Android Vector XML object."""
        # get inkscape root element
        svg = self.document.getroot()
        
        # initialize android root element
        vector = et.Element('vector')
        
        # handle root attributes
        vector.set(_ns('name'), svg.get('id', 'svgimage'))
        
        width = svg.get('width')
        height = svg.get('height')
        if width is None:
            inkex.errormsg(_('The document width attribute is missing.'))
            return
        if height is None:
            inkex.errormsg(_('The document height attribute is missing.'))
            return
        # width and height are the only attributes using non-user units in the vector tag
        vector.set(_ns('width'), str(self.uutounit(self.__unittouu(width), 'px')) + 'dp')
        vector.set(_ns('height'), str(self.uutounit(self.__unittouu(height), 'px')) + 'dp')
        
        view_box = svg.get('viewBox')
        if view_box is None:
            inkex.errormsg(_('The document viewBox attribute is missing.'))
            return
        view_box_split = view_box.split()
        if len(view_box_split) != 4:
            inkex.errormsg(_('The document viewBox attribute is not formatted correctly.'))
            return
        
        # determine scale factor
        view_width = float(view_box_split[2])
        view_height = float(view_box_split[3])
        scale_fact = 1000.0/max(view_width, view_height)
        # set scale (remove need for scientific notation)
        svg.set('transform', 'scale(%f %f)' % (scale_fact, scale_fact))
        
        vector.set(_ns('viewportWidth'), str(view_width * scale_fact))
        vector.set(_ns('viewportHeight'), str(view_height * scale_fact))
        
        # parse child elements
        self.unique_id = 0
        ancestors = [svg]
        for el in svg:
            tag = self._get_tag_name(el)
            # ignore root's incompatible children
            if tag == 'g' or tag == 'path':
                subel = self._parse_child(el, ancestors)
                if subel is not None:
                    vector.append(subel)
        
        # save element tree
        self.etree = et.ElementTree(vector) 
開發者ID:owenfromcanada,項目名稱:inkscape-androidvector,代碼行數:57,代碼來源:androidvector.py

示例7: effect

# 需要導入模塊: import inkex [as 別名]
# 或者: from inkex import errormsg [as 別名]
def effect(self):
        """
        Apply the transformation. If an element already has a transformation
        attribute, it will be combined with the transformation matrix for the
        requested conversion.
        """

        if self.options.reverse == "true":
            conversion = "from_" + self.options.conversion
        else:
            conversion = "to_" + self.options.conversion

        if len(self.svg.selected) == 0:
            inkex.errormsg(_("Please select an object to perform the " +
                             "isometric projection transformation on."))
            return

        # Default to the flat 2D to isometric top down view conversion if an
        # invalid identifier is passed.
        effect_matrix = self.transformations.get(
            conversion, self.transformations.get('to_top'))

        for id, node in self.svg.selected.items():
            bbox = node.bounding_box()
            midpoint = [bbox.center_x, bbox.center_y]
            center_old = self.getTransformCenter(midpoint, node)
            transform = node.get("transform")
            # Combine our transformation matrix with any pre-existing
            # transform.
            tr = Transform(transform) * Transform(effect_matrix)

            # Compute the location of the transformation center after applying
            # the transformation matrix.
            center_new = center_old[:]
            #Transform(matrix).apply_to_point(center_new)
            tr.apply_to_point(center_new)
            tr.apply_to_point(midpoint)

            # Add a translation transformation that will move the object to
            # keep its transformation center in the same place.
            self.translateBetweenPoints(tr, center_new, center_old)

            node.set('transform', str(tr))

            # Adjust the transformation center.
            self.moveTransformationCenter(node, midpoint, center_new)

# Create effect instance and apply it. 
開發者ID:jdhoek,項目名稱:inkscape-isometric-projection,代碼行數:50,代碼來源:isometric_projection.py


注:本文中的inkex.errormsg方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。