示例#1
0
 def displayevent(self, i):
     if i.normalized != None:
         msg = input.input_text(i.type, i.normalized)
         if msg not in (self.status, None):
             self.status = msg
             self.clearstatus()
             self.buildstatus()
             self.drawstatus()
示例#2
0
 def displayevent(self, i):
     if i.normalized != None:
         msg = input.input_text(i.type, i.normalized)
         if msg not in (self.status, None):
             self.status = msg
             self.clearstatus()
             self.buildstatus()
             self.drawstatus()
示例#3
0
    def buildactionlist(self):
        clr = 160, 200, 250
        clr2 = 200, 200, 200
        offsety = 90
        sizey = 75
        sizex = 800
        self.actionlist = []
        self.display = input.getdisplay()
        for a in input.actions_order:
            if gfx.surface.get_bitsize() > 8:
                img = pygame.Surface((sizex, sizey))
            else:
                img = pygame.Surface((sizex, sizey), 0, 32)

            subimgs = []

            subimgs.append((namefont.render(input.actions_text[a], 1,
                                            clr), (80, 0)))

            for l in range(len(self.display[a])):
                text = input.input_text(self.display[a][l][0],
                                        self.display[a][l][1])
                subimg = textfont.render(text, 1, clr2)
                r = subimg.get_rect()
                r.topleft = self.controlrectlist[l].topleft
                subimgs.append((subimg, r))

            for b in self.buttonlist:
                subimgs.append(b)

            bgd = 0, 0, 0
            img.fill(bgd)
            for sub, pos in subimgs:
                img.blit(sub, pos)
            img.set_colorkey(bgd, RLEACCEL)
            #img = img.convert()
            rect = img.get_rect().move(0, offsety)

            self.actionlist.append((img, rect))
            offsety += sizey
示例#4
0
    def buildactionlist(self):
        clr = 160, 200, 250
        clr2 = 200, 200, 200
        offsety = 90
        sizey = 75
        sizex = 800
        self.actionlist = []
        self.display = input.getdisplay()
        for a in input.actions_order:
            if gfx.surface.get_bitsize() > 8:
                img = pygame.Surface((sizex, sizey))
            else:
                img = pygame.Surface((sizex, sizey), 0, 32)

            subimgs = []

            subimgs.append((namefont.render(input.actions_text[a], 1, clr), (80, 0)))

            for l in range(len(self.display[a])):
                text = input.input_text(self.display[a][l][0],self.display[a][l][1])
                subimg = textfont.render(text, 1, clr2)
                r = subimg.get_rect()
                r.topleft = self.controlrectlist[l].topleft
                subimgs.append((subimg, r))

            for b in self.buttonlist:
                subimgs.append(b)

            bgd = 0, 0, 0
            img.fill(bgd)
            for sub, pos in subimgs:
                img.blit(sub, pos)
            img.set_colorkey(bgd, pygame.RLEACCEL)
            rect = img.get_rect().move(0, offsety)

            self.actionlist.append((img, rect))
            offsety += sizey
示例#5
0
           [Sg.Text('Text'),
            Sg.InputText(),
            Sg.FileBrowse()], [Sg.Submit("Code text")], [outInfo],
           [outCodedText], [Sg.Submit("Decode text")], [outDecodedText],
           [Sg.Cancel()]]
 window = Sg.Window('Lab №2, Hafman\'s code', layout)
 dict_coded = {}
 while True:  # The Event Loop
     event, values = window.read()
     try:
         if event in (None, 'Exit', 'Cancel'):
             break
         elif event == "Code text":
             if values[0] and values[1]:
                 p, a = input.input_probability_and_alphabet(values[0])
                 text = input.input_text(values[1])
                 dict_coded = f.hafman(p, a)
                 outInfo.update(
                     char_out.format(
                         dict_coded,
                         f.entropy(p),
                         f.redundancy(p),
                         f.average_codeword(dict_coded.values()),
                         f.crafting_inequality(dict_coded.values()),
                     ))
                 text = f.code_text(text, dict_coded)
                 outCodedText.update(text)
                 output.output("ResultCode.txt", text)
         elif event == "Decode text":
             with open("ResultCode.txt", 'r') as result_code:
                 text = result_code.read()