Results 1 to 8 of 8

Thread: double click game_over.py

  1. #1
    Join Date
    Nov 2004
    Location
    Kuala Lumpur, Malaysia
    Beans
    885
    Distro
    Xubuntu 14.04 Trusty Tahr

    Question double click game_over.py

    I'm new to programming. Bought a book "Python Programming For Absolute Beginner" by Michael Dawson.

    One example he gave in the book is a simple program:

    Code:
    print "Game Over"
    raw_input("\n\nPress the enter key to exit.")
    and I save it as game_over.py on my desktop.

    Problem is, on my windows XP I can double click the file and the program will run (sort of a DOS prompt windows pops up). But on my Ubuntu desktop double clicking it will open the file in Gedit.

    What do I have to do to be able to run the file by double clicking? Any help for a linux & python newbie like me?
    Last edited by Buffalo Soldier; January 13th, 2005 at 01:49 PM.

  2. #2
    Join Date
    Nov 2004
    Location
    ARAD, ROMANIA
    Beans
    113

    Re: double click game_over.py

    it's very simple
    you should set your python script as executable.
    How to do that:
    right click on the file and on the permision tab check 'execute' for all.
    That's it!

  3. #3
    Join Date
    Nov 2004
    Location
    Kuala Lumpur, Malaysia
    Beans
    885
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: double click game_over.py

    Thanx gheorghe. Feel like id!@t for not thinking of that first before posting.

    Anyway, your suggestion works. But now the problem is the window pop-up and then dissappear very quickly. It did not wait for me to press the ENTER key.

  4. #4
    Join Date
    Nov 2004
    Location
    Kuala Lumpur, Malaysia
    Beans
    885
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: double click game_over.py

    Found the solution to my problem. I found out that I need to add "#!/usr/bin/python" to the script.

    Code:
    #!/usr/bin/python
    print "Game Over"
    raw_input("\n\nPress the enter key to exit.")
    And if I want to keep the window terminal open after pressing ENTER, I just go to the terminal window settings.

    Edit -> Current Profile -> Title and Command -> When command exits: Hold the terminal open

  5. #5
    Join Date
    Jan 2005
    Location
    Portland, Oregon U.S.A.
    Beans
    1,050
    Distro
    Ubuntu Mate 15.04 Vivid Vervet

    Re: double click game_over.py

    Bufallo Soldier,

    Hey, I too am fairly new to Python and trying to figure it out one step at a time. How's that book treating you? Is it any good and what kind of price tag came with it?

  6. #6
    Join Date
    Nov 2004
    Location
    Kuala Lumpur, Malaysia
    Beans
    885
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: double click game_over.py

    DirtDawg,

    For someone who has experience in Python or any other programming languages may find the book too simple. It's definitely not something an experienced programmer would buy for as a reference book.

    But for a beginner/newbie I think the book is perfect. I'll quote something from an introduction paragraph which I find very true about the lessons throught the book.

    "The goal of this book is to teach you the Python programming language, learning to program the same way I did: by creating simple games. There's something more exciting about learning to program by writing software that's fun."

    The price of the book is (in Ringgit Malaysia) RM96. I guess that's about US Dollar 25.

  7. #7
    Join Date
    Jan 2005
    Location
    Portland, Oregon U.S.A.
    Beans
    1,050
    Distro
    Ubuntu Mate 15.04 Vivid Vervet

    Re: double click game_over.py

    Sounds awsome. Thanks alot!

  8. #8
    Join Date
    Nov 2004
    Location
    ARAD, ROMANIA
    Beans
    113

    Re: double click game_over.py

    When you have enought of txt python programming you should try glade+python. You can build really nice apps with that.
    Gheorghe's projects:
    www.roroid.ro

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •