Thread: WxPython

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Location
    Missouri
    Posts
    59
    Rep Power
    9

    Question user input questions


    I'm new to python(I normally program in C++ and Java). I was just wondering what is wxPython?

    Also, I'd like to know how to get keyboard input from the user.
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Google is a wondeful thing What is WxPython?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Location
    Missouri
    Posts
    59
    Rep Power
    9
    ok thanks, that explains wsPython, but how can I get keyboard input from the user(at the command line)?
  6. #4
  7. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    Originally Posted by Nathan87
    ok thanks, that explains wsPython, but how can I get keyboard input from the user(at the command line)?
    The usual way is to use raw_input:

    Code:
    ans = raw_input("What is your name?: ")
    print "Your name is",ans
    There are several python tutorials available - a good place to start is http://www.python.org/doc/

    Have fun and come back if you get stuck, we will be happy to help you

    grim
  8. #5
  9. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    620
    Rep Power
    65

    Smile


    You might be familiar with the wxWidget GUI library for C++. Well, wxPython is the corresponding library/wrapper for Python. This way you can write Windows GUI or xWindows (on Linux) programs.

    The console input for Python is usually this:
    Code:
    string1 = raw_input("Enter a string: ")
    integer1 = int(raw_input("Enter an integer number: ")
    float1 = float(raw_input("Enter a floating point number: ")
    For numbers you could use:
    Code:
    number1 = input("Enter a number: ")
    But here is the but, input actually uses the string input from raw_input() and then the function eval() to convert it to a number, this is somewhat dangerous because some rare clown can enter a commandline and eval() will excute it and potentially erase something on your disk.

    It's easy to write your own function using raw_input() for any numeric value, figure out if its an integer or float and then convert appropriately. Could be your first project! Have fun with Python, I do!

    Comments on this post

    • Nathan87 agrees : Awsome. Just what I wanted. Thanks.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Location
    Missouri
    Posts
    59
    Rep Power
    9
    This way you can write Windows GUI or xWindows (on Linux) programs.
    so wxPython, just lets you program a gui? that's it?
    where can I download it? (and get a good tutorial on it?)
  12. #7
  13. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    155
    Originally Posted by Nathan87
    so wxPython, just lets you program a gui? that's it?
    where can I download it? (and get a good tutorial on it?)
    wxPython, as well as wxWidgets comes with other libraries as well. IIRC, it also has its own Socket library.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2004
    Location
    There where the rabbits jump
    Posts
    556
    Rep Power
    12
    btw Nathan if you have not realized after your extensive serch on google about wxPython...

    Then www.wxpython.org may help you with all things about WxPython. And yes wxpython is a library for GUI programming (a LARGE one)
    Those people who think they know everything are a great annoyance to those of us who do.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Location
    Missouri
    Posts
    59
    Rep Power
    9
    Thanks a lot everyone, I think I got it

IMN logo majestic logo threadwatch logo seochat tools logo