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

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 深入与提高/游戏开发-坦克大战 1787楼
Python全系列/第二阶段:Python 深入与提高/异常机制 1788楼
Python全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 1790楼
Python全系列/第二阶段:Python 深入与提高/文件处理 1792楼

#coding=utf-8   checkbutton可以多选
from tkinter import *
from tkinter import messagebox
class Application(Frame):
    def __init__(self,master=None):
        super().__init__(master)
        self.master=master
        self.pack()
        self.creatWidget()
    def creatWidget(self):
        self.v1=StringVar()
        self.v2=StringVar()
        self.r1=Checkbutton(self,text="敲代码",onvalue=1,offvalue=0,variable=self.v1)
        self.r2=Checkbutton(self,text="看视频",onvalue=1,offvalue=0,variable=self.v2)
        self.r1.pack()
        self.r2.pack()
        Button(self,text="确定",command=self.confirm).pack(side="left")
    def confirm(self):
        if self.v1.get()==1:
            messagebox.showinfo("测试","是更喜欢敲代码哟!")
        if self.v2.get()==1:
            messagebox.showinfo("测试","是更喜欢看视频哟!")
if __name__=='__main__':
    root=Tk()
    root.geometry("200x300+100+260")
    app=Application(master=root)
    root.mainloop()

老师,帮忙看看我的代码哪里出问题了,一运行就是两个都选上了,然后只选一个没有反应。还有就是不太理解pack后面设置的side到底定义的是谁的位置,那个单选里面我写女性那里side=right是图1,写side=left是图2,到底是相对于谁right和left呀image.pngimage.png我的确定没有加side

Python全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 1793楼
Python全系列/第二阶段:Python 深入与提高/异常机制 1795楼
Python全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 1796楼
Python全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 1798楼
Python全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 1799楼
Python全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 1800楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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