Reputation: 718
I'm Having an issue when Importing a series of modules and acessing classes within them.
This is my code:
import sys, os
for path, name, files in os.walk(os.getcwd()[:os.getcwd().rindex("Mario")+5]):
sys.path.insert(0, os.path.join(path))
from pygame.locals import *
import pygame, Screen
WIDTH, HEIGHT = SIZE = 1200, 675
running = True
screen = pygame.display.set_mode(SIZE, SRCALPHA)
current = None
screen_menu = Screen.Menu().add_widget(Widget.Button(WIDTH/2-25, HEIGHT/2-25, 50, 30))
When running I get:
Traceback (most recent call last):
File "I:\Computing\Python\Mario\Global.py", line 5, in <module>
import pygame, Screen
File "I:\Computing\Python\Mario\screen\Screen.py", line 5, in <module>
import pygame, Global
File "I:\Computing\Python\Mario\Global.py", line 11, in <module>
screen_menu = Screen.Menu().add_widget(Widget.Button(WIDTH/2-25, HEIGHT/2-25, 50, 30))
AttributeError: 'module' object has no attribute 'Menu'
[Finished in 2.9s with exit code 1]
Does anyone have any idea on why this is happening, I have imported it and Menu is just a class within Screen, I can give you the Screen class if required!
Upvotes: 1
Views: 1139
Reputation: 76653
You have a circular dependency--Screen
uses Global
and Global
uses Screen
. Revise your code not to have any circular imports.
Upvotes: 3