Thread: py2exe

Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    366
    Rep Power
    10

    py2exe


    can anybody show me how to use py2exe.. im new to programing and cant figure it out
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Sure, if you attach/post your program here then we can see what needs to be done. Though the first thing you'll need to do is download and install it.

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    366
    Rep Power
    10
    Code:
    from livewires import *
    right=0
    wrong=0
    for x in range(10):
    
        first_number=random_between(1,10)
        second_number=random_between(1,10)
        
        print "first number is %d and second number is %d" % (first_number, second_number)
        
        question = "What is %d * %d? " % (first_number, second_number)
        
        quotent=first_number*second_number
        
        if  read_number(question)==quotent:
            print 'good job'
            right=right + 1
        else:
            print 'no try again'
            wrong=wrong + 1
    
    print '   '
    print '           '
    if right == wrong:
        print 'you got 50%'
    elif right == 1:
        print 'you got 10%'
    elif right == 2:
        print 'you got 20%'
    elif right == 3:
        print 'you got 30%'
    elif right == 4:
        print 'you got 40%'
    elif right == 6:
        print 'you got 60%'
    elif right == 7:
        print 'you got 70%'
    elif right == 8:
        print 'you got 80%'
    elif right == 9:
        print 'good job you got 90%'
    elif right == 10:
        print 'wow nice job you got 100%'
    elif right == 0:
        print 'you got 0% try again'
    
    print 'you got', right,'right and', wrong,'wrong'
    thers my prog. very simple. i made it for my aunt (shes a teacher) to give to her students on the comp as a test or somthing
    anyway.. i do have py2exe
    thanks for the help
    Last edited by netytan; October 16th, 2004 at 03:25 PM.
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    This could be me being stupid . But where did the livewires module come from, I usually start this kind of thing by testing the program to see if it works but without the module I'm kinda stumped.

    Oh, also, could you read the thread regarding how to ask a question located at the top of this forum .

    Mark.
    programming language development: www.netytan.com Hula

  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    366
    Rep Power
    10

    livewires


    Originally Posted by netytan
    This could be me being stupid . But where did the livewires module come from, I usually start this kind of thing by testing the program to see if it works but without the module I'm kinda stumped.


    Mark.
    the livewires module came from www.livewires.org.uk
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    366
    Rep Power
    10

    here we go


    and about the how to thing... sorry im new to forums
    so here we go
    Code:
    from livewires import *
    right=0
    wrong=0
    for x in range(10):
    
        first_number=random_between(1,10)
        second_number=random_between(1,10)
        
        print "first number is %d and second number is %d" % (first_number, second_number)
        
        question = "What is %d * %d? " % (first_number, second_number)
        
        quotent=first_number*second_number
        
        if  read_number(question)==quotent:
            print 'good job'
            right=right + 1
        else:
            print 'no try again'
            wrong=wrong + 1
    
    print '   '
    print '           '
    if right == wrong:
        print 'you got 50%'
    elif right == 1:
        print 'you got 10%'
    elif right == 2:
        print 'you got 20%'
    elif right == 3:
        print 'you got 30%'
    elif right == 4:
        print 'you got 40%'
    elif right == 6:
        print 'you got 60%'
    elif right == 7:
        print 'you got 70%'
    elif right == 8:
        print 'you got 80%'
    elif right == 9:
        print 'good job you got 90%'
    elif right == 10:
        print 'wow nice job you got 100%'
    elif right == 0:
        print 'you got 0% try again'
    
    print 'you got', right,'right and', wrong,'wrong'
    im using python 2.3 on win XP
    there we go thats better
  12. #7
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    It's not a problem . Everyone has to be a newbie at some point. Anyway, in the simplest case your setup.py file should look something like:

    Code:
    from distutils.core import setup
    import py2exe
          
    setup(console = ['programname.py'], py_modules = ['livewires'])
    Lets continue this in the morning ok , but first, is this the module in question?

    http://eric_rollins.home.mindspring.com/introProgramming/livewires/livewires.py

    Take care,

    Mark.
    Last edited by netytan; October 16th, 2004 at 06:02 PM. Reason: Livewires
    programming language development: www.netytan.com Hula

  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    366
    Rep Power
    10

    hm..


    hm... when i put in that code(thx by the way),in the begining of the program(takeing out what i had before) and saved it it saved as a unrecognized file and asked me how to open it...
    heres the new code just incase you want it
    Code:
    from distutils.core import setup
    import py2exe
          
    setup(console = ['times2.py'], py_modules = ['livewires'])
    from livewires import *
    right=0
    wrong=0
    for x in range(10):
    
        first_number=random_between(1,10)
        second_number=random_between(1,10)
        
        print "first number is %d and second number is %d" % (first_number, second_number)
        
        question = "What is %d * %d? " % (first_number, second_number)
        
        quotent=first_number*second_number
        
        if  read_number(question)==quotent:
            print 'good job'
            right=right + 1
        else:
            print 'no try again'
            wrong=wrong + 1
    
    print '   '
    print '           '
    if right == wrong:
        print 'you got 50%'
    elif right == 1:
        print 'you got 10%'
    elif right == 2:
        print 'you got 20%'
    elif right == 3:
        print 'you got 30%'
    elif right == 4:
        print 'you got 40%'
    elif right == 6:
        print 'you got 60%'
    elif right == 7:
        print 'you got 70%'
    elif right == 8:
        print 'you got 80%'
    elif right == 9:
        print 'good job you got 90%'
    elif right == 10:
        print 'wow nice job you got 100%'
    elif right == 0:
        print 'you got 0% try again'
    
    print 'you got', right,'right and', wrong,'wrong'
  16. #9
  17. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Make sure you have this script in the same directory as prog.py (your program) and livewires.py. The double click this file to execute it. The script will create build and dist directories. Your excutable will be in the dist directory.
    Code:
    from distutils.core import setup
    import py2exe
    import sys
    sys.argv.append("py2exe")
    setup(console = [{"script": 'prog.py'}])
    You can of course change prog.py for whatever name you called your script.

    This is possibly the most minimal setup script for a console app.

    [I know it works - I was bored enough to download livewires and test it ]

    grim
    Last edited by Grim Archon; October 18th, 2004 at 06:59 PM.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    366
    Rep Power
    10

    Talking Woohoo


    WOOHP DE DOO thx i *finnaly* got it Thx alot you guys
    i think the problem was that i saved it as file. whatever it wanted not file.py i feel noobish(tho i am ) anyway thanks alot
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    366
    Rep Power
    10

    Unhappy Doh


    AWW MAN just when i thought i had this down... my .exe file closes before the user can read the last remarkes printed can you help?
  22. #12
  23. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    13
    Try adding:
    raw_input("Press ENTER to finish")

    grim
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    366
    Rep Power
    10
    odd..... it works for the .py file, but not for the .exe file
  26. #14
  27. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Actually In my experiance we get this with all Python programs; .py files or .exe's. If you seach the forum you should see a few threads that discribe the use of raw_input() for this end .

    It's a little anoying at first, but when you remember that they are command line applications it makes sence that they just run right the way though. In-fact it could pretty get anoying if you had to press enter every time you finished running a script just to get to the next command prompt .

    Mark.
    programming language development: www.netytan.com Hula

  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2004
    Posts
    366
    Rep Power
    10

    i know!


    ill ask the person do you wanna play again? and it wont quit untill they say no im so smart
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo