0

Guys, below is a part of an Object description in an application I am trying to code. I am using Tkinter for GUI. The Tkwindow hangs as soon as the "print self.gs" instruction is executed. Can it be rectified?
Any help will be appreciated

    def while_time(self):

        pass

    def gameplay(self):

        self.gs=self.get_schedule()#Schedule the games

        print self.gs

        self.gen_window()

        for game in self.gs:

            if self.chosen_team==TEAMS[game[0]] or self.chosen_team==TEAMS[game[1]]:

                while(self.play_click==0):

                    self.while_time()

                winner=self.sim_match(game)

                self.post_match(game, winner)

                self.play_click=0

            else:

                winner=self.sim_match(game)

                self.post_match(game, winner)
2
Contributors
2
Replies
31
Views
3 Years
Discussion Span
Last Post by m_ishwar
0

An infinite loop as play_click is not changed within the while loop

            while(self.play_click==0):
                self.while_time()

When testing it is a good idea to limit while loops

            ctr = 0
            while self.play_click==0:
                self.while_time()
                ctr += 1
                if ctr > 99:
                    print "Counter limit exit from while loop"
                    self.play_click=99

Edited by woooee

0

The apllication is a football league simulator. I already got it right in a Textual form. But in GUI form, I want it automatically simulate other games and when the chosen team's match comes up, I want it to wait for the user's button click. Thats why I have an update_click function to set the variable self.play_click to 1 which must exit the infinite loop. Is there a better way of doing it?

Edited by m_ishwar

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.