Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TypeError:\uuuu init\uuuu()至少接受3个参数(给定2个)_Python_Pygame_Wxpython - Fatal编程技术网

Python TypeError:\uuuu init\uuuu()至少接受3个参数(给定2个)

Python TypeError:\uuuu init\uuuu()至少接受3个参数(给定2个),python,pygame,wxpython,Python,Pygame,Wxpython,我是Python面向对象编程的新手,因此,我有以下代码: #!/usr/bin/python # -*- coding: utf-8 -*- import wx, pygame, sys, random, os from pygame.locals import * from random import choice from block import O, I, S, Z, L, J, T class Example(wx.Frame): def __init__(self, paren

我是Python面向对象编程的新手,因此,我有以下代码:

#!/usr/bin/python
# -*- coding: utf-8 -*-
import wx, pygame, sys, random, os
from pygame.locals import *
from random import choice
from block import O, I, S, Z, L, J, T

class Example(wx.Frame):


def __init__(self, parent, id, *args, **kwargs):
    super(Example, self).__init__(self, parent, id,*args, **kwargs)  
    self.InitUI()
    image_file = "roses.jpg"
    bmp1 = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
    self.bitmap1 = wx.StaticBitmap(self, -1, bmp1, (0, 0))
[more stuffs...]
它是用来打开一个窗口与一些按钮的背景图像。但当我执行它时,它会给我一个错误:

File "C:\mytetris\aaa.py", line 472, in main
Example(None)
TypeError: __init__() takes at least 3 arguments (2 given)
所以请帮帮我…

我只能猜测

class Example(wx.Frame):
    def __init__(self, parent, id, *args, **kwargs):
示例
要求至少有3个参数
self
parent
id
。对象名称作为
self
传递,因此您必须创建具有2个参数的对象-例如:

my_example = Example(some_parent, some_id)

缩进不正确。主缩进中的第472行在哪里。。。这些程序只有471行。。。