当前位置: 首页>>代码示例>>Python>>正文


Python QTextStream.pos方法代码示例

本文整理汇总了Python中PyQt4.QtCore.QTextStream.pos方法的典型用法代码示例。如果您正苦于以下问题:Python QTextStream.pos方法的具体用法?Python QTextStream.pos怎么用?Python QTextStream.pos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtCore.QTextStream的用法示例。


在下文中一共展示了QTextStream.pos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_gcode_file

# 需要导入模块: from PyQt4.QtCore import QTextStream [as 别名]
# 或者: from PyQt4.QtCore.QTextStream import pos [as 别名]
    def load_gcode_file(self):
        file = QFile(self.filename)
        file.open(QIODevice.ReadOnly | QIODevice.Text)
        in_stream = QTextStream(file)
        file_size = file.size()
        counter = 0
        line = 0
        line_number = 0
        while not in_stream.atEnd() and self.is_running is True:

            if self.update_progressbar:
                if counter==10000:
                    #in_stream.pos() je hodne pomala funkce takze na ni pozor!!!
                    progress = (in_stream.pos()*1./file_size*1.) * 100.
                    self.set_update_progress.emit(int(progress))
                    counter=0
                else:
                    counter+=1

            line = in_stream.readLine()
            bits = line.split(';', 1)
            bits_len = len(bits)

            if bits[0] == '':
                line_number+=1
                if bits_len > 1:
                    if bits[0] == '' and bits[1] == "END gcode for filament":
                        break
                continue

            if 'G1 ' in bits[0]:
                self.parse_g1_line_new(bits, line_number)
            elif 'G4' in bits[0]:
                self.parse_g4_line(bits, line_number)
            elif 'T0' in bits[0] or 'T1' in bits[0] or 'T2' in bits[0] or 'T3' in bits[0]:
                self.parse_t_line(bits, line_number)
            elif 'G90' in bits[0]:
                self.absolute_coordinates = True
            elif 'G91' in bits[0]:
                self.absolute_coordinates = False
            elif 'G92' in bits[0]:
                self.parse_g92_line(bits, line_number)
            else:
                if DEBUG:
                    print("Nezpracovano: " + str(bits))
                line_number += 1
                continue
            line_number += 1

        if self.is_running is False and self.update_progressbar is True:
            self.set_update_progress.emit(0)

        self.printing_time = self.calculate_time_of_print()
        self.filament_length = 0.0  # self.calculate_length_of_filament()

        ###
        self.non_extruding_layers = []
        for i in self.data:
            layer_flag = 'M'
            for l in self.data[i]:
                _start, _end, flag, _speed, _extrusion, _extruder, _line = l
                if flag in ['E', 'E-sk', 'E-su', 'E-i', 'E-p']:
                    layer_flag = 'E'
                    break
            if layer_flag == 'M':
                self.non_extruding_layers.append(i)

        for i in self.non_extruding_layers:
            self.data.pop(i, None)

        self.data_keys = set()
        self.data_keys = set(self.data)
        self.data_keys = sorted(self.data_keys, key=float)


        self.set_data_keys.emit(self.data_keys)
        self.set_data.emit(self.data)
        self.set_all_data.emit(self.all_data)
        self.set_printing_time.emit(self.printing_time)

        self.finished.emit()
开发者ID:DakotaMcCutch,项目名称:PrusaControl,代码行数:83,代码来源:gcode.py


注:本文中的PyQt4.QtCore.QTextStream.pos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。