Esempio n. 1
0
    def __init__(self, master):
        #Establish the width and height of the First Window
        self.width = 1100
        self.height = 600

        #Initialize the city matrix, get the number of rows of the city and the number of columns of the city
        self.city = MapParser.createMapParser()
        self.rows = len(self.city)
        self.columns = len(self.city[0])

        #This is used to save the old coordinates of the taxi
        self.oldCoordinates = []
        self.taxiNode = 0

        #Create a City Graph Object
        self.cityGraph = CityObjects.createCityGraph(self.city)

        #Initialize the matrix of Labels that are going to compose the Window
        self.matrixOfLabels = self.city

        #Set all of the images
        self.taxiRightImage = Image.open("ProjectImages/taxiDerecha.png")
        self.taxiLeftImage = Image.open("ProjectImages/taxiIzquierda.png")
        self.taxiUpImage = Image.open("ProjectImages/taxiArriba.png")
        self.taxiDownImage = Image.open("ProjectImages/taxiAbajo.png")
        self.wallHorizontalImage = Image.open(
            "ProjectImages/barreraHorizontal2.png")
        self.wallVerticalImage = Image.open(
            "ProjectImages/barreraVertical2.png")
        self.streetImage = Image.open("ProjectImages/calle.png")
        self.waterImage = Image.open("ProjectImages/rio.png")
        self.clientImage = Image.open("ProjectImages/cliente1.jpg")
        self.routeImage = Image.open("ProjectImages/ruta1.png")
        self.cuadraSinIdentificacionImage = Image.open(
            "ProjectImages/cuadraSinIdentificacion.png")
        self.cuadraIdentificada = ""

        #Set the master as the root
        self.master = master
        self.widthOfEachFrame = 0
        self.heightOfEachFrame = 0

        #This is going to be the Frame with the Button and Label that shows: Calculating route or Taxi on the way!
        self.taxiStateFrame = Frame(self.master,
                                    width=self.width,
                                    height=(self.height + 50) - (self.height),
                                    background="White")
        self.taxiStateFrame.place(x=0, y=(self.height))
        self.taxiStateButton = Button(self.taxiStateFrame,
                                      text="Taxi State",
                                      width=20,
                                      height=1,
                                      bg="Black",
                                      fg='White',
                                      font=('Kalinga', '16'),
                                      relief='sunken')
        self.taxiStateButton.place(x=10, y=5)
        self.taxiStateLabel = Label(self.taxiStateFrame,
                                    width=50,
                                    height=1,
                                    bg="Black",
                                    text='Welcome to the Taxi Simulation',
                                    fg='White',
                                    font=('Kalinga', '16'),
                                    relief='sunken')
        self.taxiStateLabel.place(x=350, y=10)

        #Here, we call the function in charge of build the city
        self.buildCity()
    def __init__(self, master):
        #Establish the width and height of the First Window
        self.width = 1100
        self.height = 600

        #Initialize the city matrix, get the number of rows of the city and the number of columns of the city
        self.city = MapParser.createMapParser()
        self.rows = len(self.city)
        self.columns = len(self.city[0])

        #This contains the actual instruction
        self.actualInstruction = ""

        #This is used to save the old coordinates of the taxi
        self.oldCoordinates = []
        self.taxiNode = 0

        #This indicates to do the animation
        self.doAnimation = False
        self.updateTime = 1000
        self.sameInstruction = False

        #List with the travel of the taxi
        self.travelList = []

        #This variable is need it for the search instruction
        self.searchIndex = 0
        self.searchList = []
        self.clientsList = []
        self.p = 0
        self.soundFilePath = "ProjectSounds/taxi_call.wav"

        #This indicates if there is an instruction executing at the time
        self.executingInstruction = False

        #This indicates not to perform again the search algorithm
        self.routeAlreadyExecute = False

        #Establish all the possible instructions
        self.travelInstruction = "pasear"
        self.searchInstruction = "buscar"
        self.showInstruction = "mostrar"
        self.animateInstruction = "animar"
        self.routeInstruction = "ruta"
        self.randomClientsInstruction = "clientes"
        self.specificClientInstruction = "cliente"
        self.parkInstruction = "parquear"

        #Create a City Graph Object
        self.cityGraph = CityObjects.createCityGraph(self.city)

        #Initialize the matrix of Labels that are going to compose the Window
        self.matrixOfLabels = self.city

        #Set all of the images
        self.taxiRightImage = Image.open("ProjectImages/taxiDerecha.png")
        self.taxiLeftImage = Image.open("ProjectImages/taxiIzquierda.png")
        self.taxiUpImage = Image.open("ProjectImages/taxiArriba.png")
        self.taxiDownImage = Image.open("ProjectImages/taxiAbajo.png")
        self.wallHorizontalImage = Image.open(
            "ProjectImages/barreraHorizontal2.png")
        self.wallVerticalImage = Image.open(
            "ProjectImages/barreraVertical2.png")
        self.streetImage = Image.open("ProjectImages/calle.png")
        self.waterImage = Image.open("ProjectImages/rio.png")
        self.clientImage = Image.open("ProjectImages/cliente1.jpg")
        self.routeImage = Image.open("ProjectImages/ruta1.png")
        self.cuadraSinIdentificacionImage = Image.open(
            "ProjectImages/cuadraSinIdentificacion.png")
        self.cuadraIdentificada = ""

        #Set the master as the root
        self.master = master
        self.widthOfEachFrame = 0
        self.heightOfEachFrame = 0

        #This is going to be the Frame with the Button and Label that shows: Calculating route or Taxi on the way!
        self.taxiStateFrame = Frame(self.master,
                                    width=self.width,
                                    height=(self.height + 50) - (self.height),
                                    background="White")
        self.taxiStateFrame.place(x=0, y=(self.height))
        self.taxiStateButton = Button(self.taxiStateFrame,
                                      text="Taxi State",
                                      width=20,
                                      height=1,
                                      bg="Black",
                                      fg='White',
                                      font=('Kalinga', '16'),
                                      relief='sunken')
        self.taxiStateButton.place(x=10, y=5)
        self.taxiStateLabel = Label(self.taxiStateFrame,
                                    width=50,
                                    height=1,
                                    bg="Black",
                                    text='Welcome to the Taxi Simulation',
                                    fg='White',
                                    font=('Kalinga', '16'),
                                    relief='sunken')
        self.taxiStateLabel.place(x=350, y=10)

        #Here, we call the function in charge of build the city
        self.buildCity()

        #This instruction is in constant review for the instruction of the console
        self.getConsoleInstruction()