会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 133334个问题
Python 全系列/第二阶段:Python 深入与提高/文件处理 1771楼

from tkinter import *


class Application(Frame):
    def __init__(self,master=None):
        super().__init__(master)
        self.master = master
        self.pack()

        self.createWight()

    def createWight(self):
        btnTEXT = (("MC", "M+", "M-", "MR"),
                   ("C", "±", "/", "*"),
                   (7,8,9,"-"),
                   (4,5,6,"+"),
                   (0,1,2,"="),
                   (0,"."))
        Entry(self).grid(row=0,column=0, columnspan=4,pady=10)
        for rindex,r in enumerate(btnTEXT):
            for cindex,c in enumerate(r):
                if c == "=":
                    Button(self,text=c,width=2).grid(row=1+rindex,column=cindex, rowspan=2,sticky=NSEW)
                elif c == "0":
                    Button(self,text=c,width=2).grid(row=1+rindex,column=cindex, columnspan=2, sticky=NSEW)
                elif c == ".":
                    Button(self,text=c,width=2).grid(row=1+rindex,column=cindex+1, sticky=NSEW)
                else:
                    Button(self,text=c,width=2).grid(row=1+rindex,column=cindex,sticky=NSEW)



if __name__ == '__main__':
    root = Tk()
    root.title("计算器")
    root.geometry("300x300+200+300")
    app = Application(master=root)
    root.mainloop()

老师,和您的一样,0为啥没有跨列

121ef5b2129d5061242c87b7009e7f1.png

Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 1773楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 1774楼
Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 1776楼
Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 1777楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 1779楼

pygame
SCREEN_WIDTH=SCREEN_HIGHT=BG_COLOR=pygame.Color()
MainGame():
    window=():
        ():
        pygame.display.init()
        MainGame.widow=pygame.display.set_mode([SCREEN_WIDTHSCREEN_HIGHT])
        pygame.display.set_caption()
        :
            MainGame.window.fill(BG_COLOR)
            pygame.display.update()
    ():
        Tank():
    ():
        ():
        ():
        ():
        MyTank():
    ():
        EnemyTank(Tank):
    ():
        ().()
Bullet():
    ():
        ():
        ():
        Wall():
    ():
        ():
        Explode():
    ():
        ():
        Music():
    ():
        ():
        __name__==:
    MainGame().startGame()

C:\Users\86137\PycharmProjects\mypro01\venv\Scripts\python.exe C:/Users/86137/PycharmProjects/mypro01/tanke01.py

pygame 2.0.1 (SDL 2.0.14, Python 3.9.2)

Hello from the pygame community. https://www.pygame.org/contribute.html

Traceback (most recent call last):

  File "C:\Users\86137\PycharmProjects\mypro01\tanke01.py", line 101, in <module>

    MainGame().startGame()

  File "C:\Users\86137\PycharmProjects\mypro01\tanke01.py", line 48, in startGame

    MainGame.window.fill(BG_COLOR)

AttributeError: 'NoneType' object has no attribute 'fill'


Process finished with exit code 1

运行的时候为什么是fill错误呀、、、

Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 1780楼
Python 全系列/第二阶段:Python 深入与提高/异常机制 1781楼
Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 1783楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 1785楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637