FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Invalid syntax in gui/eight_puzzle.py · Issue #896 · aimacode/aima-python · GitHub

Repository navigation

Invalid syntax in gui/eight_puzzle.py #896

Description

I'm trying to run the Gui examples, with:
python3 -i gui/eight_puzzle.py
And get the next out:

File "gui/eight_puzzle.py", line 88
    b[zero_ix] = Button(root, text=f'{state[index]}', width=6, font=('Helvetica', 40, 'bold'), command=partial(exchange, zero_ix))
                                                   ^
SyntaxError: invalid syntax

I've python 3.5.2 and Ubuntu 16.04.

Activity

  1. apb7 commented on Mar 27, 2018

    Contributor

    Hi @LoboLofi, this isn't a syntax error actually. This feature has been introduced in Python 3.6 and would run smoothly if you update your Python version. Thanks!

  2. LoboLofi commented on Mar 27, 2018

    Author

    Thanks a lot @apb7

  3. thesagarsehgal commented on Dec 15, 2018

    Contributor

    @apb7 @ad71 It has been mentioned in the README that we can run it with Python3.4 and up.
    So we can still make this compatible for lower version of python by using
    b[zero_ix] = Button(root, text=str(state[index]), width=6, font=('Helvetica', 40, 'bold'), command=partial(exchange, zero_ix))
    There is a simmilar isssue in gui/grid_mdp.py and gui/genetic_algorithm_example.py.
    This code is running just fine on my system after this change which has simmilar configurations as mentioned above.
    Shall I go ahead and create a PR for this? Or is there any gap in my solution?

  4. ad71 commented on Dec 15, 2018

    Contributor

    @sagar-sehgal You're right, this will work fine. You can submit a PR.

  5. thesagarsehgal commented on Dec 17, 2018

    Contributor

    @ad71 @MrDupin Sorry for replying late but, I submitted th PR for the changes in gui/eight_puzzle.py and gui/genetic_algorithm_example.py but I didn't do that for gui/grid_mdp.py . Actually on applying the above changes in grid_mdp.py and then running the code, it was fine until I clicked on a cell. On clicking on a cell and providing it a reward/making it a terminal/making it a cell it was showing a new error

    Exception in Tkinter callback
    Traceback (most recent call last):
      File "/usr/lib/python3.5/tkinter/__init__.py", line 1553, in __call__
        return self.func(*args)
      File "grid_mdp.py", line 128, in update_table
        if wall.get() == WALL_VALUE:
      File "/usr/lib/python3.5/tkinter/__init__.py", line 358, in get
        return self._tk.getint(self._tk.globalgetvar(self._name))
    TypeError: getint() argument must be str, not float
    
    

    Further on changing tk.IntVar() to tk.DoubleVar() in line no. 94,96,262 and 264. It was working fine and assigning values on clicking on the cells and changing the color of the cells.
    But on Buiding, it showed another error

    Exception in Tkinter callback
    Traceback (most recent call last):
      File "/usr/lib/python3.5/tkinter/__init__.py", line 1553, in __call__
        return self.func(*args)
      File "grid_mdp.py", line 406, in build
        solve_page.create_graph(gridmdp, terminals, _height, _width)
      File "grid_mdp.py", line 588, in create_graph
        self.canvas.show()
    AttributeError: 'FigureCanvasTkAgg' object has no attribute 'show'
    

    which was again resolved by changing show() to draw().
    And finally it didn't showed up any error.
    Should I submit the PR solving the problem. Or is there anything which I need to do.

    Further I would like to show up some of the GUI things which can be improved like

    It can be made only 1 selectable at a time (if possible). Further this can also be improved

    we can close the previous window, when a new cell is clicked (if possible).
    Should I start working on these things.

  6. ad71 commented on Dec 17, 2018

    Contributor

    @sagar-sehgal Tkinter has been updated since the time this program was written. You can submit a PR with the updates you mentioned. I think the GUI improvements you suggested are also worth implementing. Please go ahead. Thanks!

  7. thesagarsehgal commented on Dec 17, 2018

    Contributor

    Thank You @ad71 !

  8. added a commit that references this issue on Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL