I want to open .py file - that i have found out - and than from opened file run new frame. This is code in file MenuWindow:
def OnNewGame(self,event):
play = False
nameofplr = wx.GetTextFromUser('Enter your name:', 'NEW GAME')
subor=open("Save/savegame.txt","a")
subor.write( "\n" + nameofplr)
subor.close()
savegame=open("Save/" + nameofplr + ".prjct", "w+")
savegame.close()
play = True
if (play == True):
sys.path.insert(0, './bin')
import game
new = GameFrame(parent=None, id=-1)
new.Show()
self.Close()
And This is code from game.py:
print "game.py opened"
import wx
class GameFrame(wx.Frame):
def __init__(self,parent,id):
wx.Frame.__init__(self, parent, id, "Project", size=(860, 640))
wx.Frame.CenterOnScreen(self)
Output prints game.py opened so it open the file, but why it doesn´t create new frame?
This is output:
game.py opened
Traceback (most recent call last):
File "D:\Python\Python Projects\Project\MenuWindow.py", line 48, in OnNewGame
new = GameFrame(parent=None, id=-1)
NameError: global name 'GameFrame' is not defined
You import game, and GameFrame is a part of game, so you should type
new = game.GameFrame(parent=None, id=-1)