printer.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:Bigglesworth 作者: MaurizioB 项目源码 文件源码
def compute(self, cols=1, vertical=False):
        text = 'Blofeld preset list:\n\n'
        for b, bank in enumerate(self.main.blofeld_library.data):
            if b not in self.bank_selection: continue
            sounds = []
            for sound in bank:
                sounds.append('{}{:03}\t{}'.format(uppercase[sound.bank], sound.prog+1, sound.name))
            if sounds:
                text += 'Bank {}:\n=======\n'.format(uppercase[sound.bank])
                if cols == 1:
                    text += '\n'.join(sounds)
                else:
                    if vertical:
                        div = len(sounds)/cols
                        if div*cols < len(sounds):
                            div += 1
                        for d in range(div):
                            for col in range(cols):
                                try:
                                    text += sounds[d + div*col]
                                    if col == cols-1:
                                        text += '\n'
                                    else:
                                        text += '\t\t'
                                except:
                                    text += '\n'
                                    break
                    else:
                        col = 0
                        for txt in sounds:
                            text += txt
                            col += 1
                            if col == cols:
                                text += '\n'
                                col = 0
                            else:
                                text += '\t\t'
                text += '\n\n'
        self.text = text
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号