猫史档案馆


【Python作品分享】查看【作品秀】

用户:何乐何乐查看:0 回复:3 评论:0 创建时间:2021-10-13T19:15:11


【作品展示】

center_image

 

【作品介绍】

查看文件

点击暂未开通

 

【作品源代码】

import easygui, pygame, random

def uniform():
    return random.uniform(-2, 2)
class My_word_png(pygame.sprite.Sprite):
    def __init__(self, my_word_name, x, speed):
        pygame.sprite.Sprite.__init__(self)
        self.image = pygame.image.load('D:/何乐学python/png/%s.png' % my_word_name)
        self.rect = self.image.get_rect()
        self.speed = speed
        self.rect.left, self.rect.top = x, 90

    def __str__(self):
        return my_word_name + '.png'

    def move(self, width, height):

        if self.rect.left < 0 or self.rect.height > width:
            self.speed[0] = -self.speed[0]
        if self.rect.top < 0 or self.rect.bottom > height:
            self.speed[1] = -self.speed[1]


def whileeasyguiintegerbox_c():

    while True:
        b = easygui.integerbox('几行?', upperbound=len(a.readlines(), lowerbound=2))
        if b:
            return b
        else:
            easygui.msgbox('''The value that you enterd:
        "None"
is not an integer.''', 'Error')


def pygame1(i):
    pygame.mixer.music.load('D:/何乐学python/声音/9.18/%s.mp3' % i)
    pygame.mixer.music.set_volume(100)
    pygame.mixer.music.play()


def whileeasyguienterbox(a):

    while True:
        a = easygui.enterbox(a)
        if a:
            return a
        else:
            easygui.msgbox('错误')


def Go(whilemath):

    pygame.init()
    size = width, height = 喵0, 480
    speed = [uniform(), uniform()]
    screen = pygame.display.set_mode(size)
    pygame.display.set_caption('查看')
    screen.fill((255, 255, 255))
    Words = []
    for i in ['查看', '追加']:
        Word = My_word_png(my_word_name='查看', speed=speed, x=320-500)
        Words.append(Word)
    for Word in Words:
        screen.blit(Word.image, [Word.rect.left, Word.rect.top])
    pygame.display.flip()
    x = 喵0 / 3
    my_word_list = []
    running = True
    while running:
        for event in pygame.event.get():#event = 按键
            if event.type == pygame.QUIT:#pygame关闭
                running = False
            if event.type == pygame.KEYDOWN or pygame.mouse.get_pressed()[0] == 1:#按下按键
                keys = pygame.key.get_pressed()
                if keys[pygame.K_c] and keys[pygame.K_h] and keys[pygame.K_a] or 0!=0:
                    try:
                        pygame1('查看')#查看
                        b = easygui.choicebox('', choices=['字节', ''])
                        if b == '字节':
                            b = 'b'
                        a = open(whileeasyguienterbox('').split(easygui.enterbox('', default=',')), 'r'+b)
                        print(a)
                        b = easygui.choicebox('你要自己输入行数还是自动', choices=['自动', '手动'])
                        if b == '自动':
                            while True:
                                dushu = a.readline()
                                if dushu:easygui.msgbox(dushu)
                                else:break
                        else:
                            b = easygui.choicebox('', choices=['前', '后','所有'])
                            if b == '前':
                                a.meek(p())
                                while True:
                                    dushu = a.readline()
                                    if dushu:easygui.msgbox(dushu)
                                    else:break
                            elif b == '后':
                                a_list = a.readlines()
                                b = p()
                                dushu = a.readline()
                                while dushu != a_list[b]:
                                    if dushu:
                                        easygui.msgbox(dushu)
                                        dushu = a.readline()
                                    else:break
                            else:
                                a.readline()
                                a.meek(p())
                                b = p()
                                dushu = a.readline()
                                while dushu != a_list[b]:
                                    if dushu:
                                        easygui.msgbox(dushu)
                                        dushu = a.readline()
                                    else:break
                    except OSError:easygui.msgbox('找不到名字')
                    else:a.close()
                else:
                    if keys[pygame.K_PLUS] or (keys[pygame.K_j] and keys[pygame.K_i] and keys[pygame.K_a]) or 0!=0:#按下按键
                        b = easygui.choicebox('追加还是创造', choices=['追加', '新建'])#追加 or 新建
                        pygame1(b)
                        c = easygui.choicebox('', choices=('字节', ''))
                        if c != '':c = 'b'
                        if b == '追加':
                            b = 'a'
                            try:
                                a = open('/'.join(whileeasyguienterbox('').split(whileeasyguienterbox(''))), b + c)
                                b = easygui.choicebox('', choices=['是', '否'])
                                if b == '是':b = '\n'
                                else:b = ''
                                c = whileeasyguienterbox('')
                                d = c.split(whileeasyguienterbox('跳行符'))
                                e = '\n'.join(d)
                                a.write('%s%s' % (b, e))
                                a.close()
                            except OSError:easygui.msgbox('找不到名字')
                        else:
                            b = 'w'
                            a = open('/'.join(whileeasyguienterbox('').split(whileeasyguienterbox(''))), b + c)
                            b = easygui.choicebox('', choices=['是', '否'])
                            if b == '是':b = '\n'
                            else:b = ''
                            c = whileeasyguienterbox('')
                            d = c.split(whileeasyguienterbox('跳行符'))
                            e = '\n'.join(d)
                            a.write('%s%s' % (b, e))
                            a.close()
    if whilemath < 10000:
        if easygui.ynbox('是否继续', '', ('是', '否')):Go(whilemath=whilemath + 1)

#主
Go(whilemath=1)

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
何乐何乐

你千万不要去点查看或追加哦,点了没用

点赞0


评论


何乐何乐

本作品有第三方库模块,请用客户端打开。

点赞0


评论


杉某人杉某人

有bug

点赞0


评论