Hi i am new to python and i am trying to create a GUI application which will hold different games aimed for autistic children, from where these games can be played.
I have imported the scripts to the Gui application area as follows
from tkinter import *
from tkinter.messagebox import *
from tkinter import Image
from Tetrisino import *
from colorfill import *
from Simulation import *
import os
On the Gui each game is listed with an image, its name and a play button for each one as follows
#Placing of the fouth Activity game name
img3 = PhotoImage(file=imgdir +'tetris(1).gif')
can.create_image(1, 200, image=img3, anchor=NW)
can.image = img3 # reference to keep image
can.create_text(170, 220, text='Tetrisino Activity Game', fill='blue', font=('Arial',14))
button3 = Button(Gui, text = "Play", anchor = NW)
button3.configure(activebackground = "#33B5E5", fg='red', font=('Arial', 14), relief = RAISED, command = Button3CallBack)
button3_window = can.create_window(320, 200, anchor=NW, window=button3)
My problem is that of when i press the play button the same game is being run for any button pressed. what i am trying to do is to code different callback command functions so that when the button command is used this will open the required game, but unfortunately i am stuck and cannot find a way to code the fucntion, till now the below is the code i came up with and it is giving me an error as follows
def Button3CallBack():#Caling the main function of the Tetrisino game
#import Tetrisino
global Tetrisino
Tetrisino = Tetrisino.main ()
Error given
Exception in Tkinter callback
Traceback (most recent call last):
File "D:\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "C:\Users\Etienne\Desktop\Python activity games\test gui prototype\Activity Gui.py", line 16, in Button3CallBack
Tetrisino = Tetrisino.main ()
NameError: global name 'Tetrisino' is not defined
I am sorry if this is a bit long but i need to try to explain what i am doing and happening. I would appreciate it if anyone could help me out as i am stuck and cannot move on to put all the package toghether and test it out.