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

    Join Date
    Apr 2005
    Location
    USA
    Posts
    4
    Rep Power
    0

    Creating additional windows with python+tkinter


    Hello. I'm going through "Learning Python" and "Programming Python" both by O'Reilly. I'm trying to create a fairly simple program. I have a main file "login.py" which asks for a username and then I want it to open up another window where the majority of the program will be. What is the best way to do this? Would it be easiest to create separate .py files/programs for each of the windows I'm going to need? Thanks in advance!
  2. #2
  3. Mini me.
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Location
    Cambridge, UK
    Posts
    783
    Rep Power
    14
    I'm sure you will get a lot of advice on this one - here's mine

    If your program is going to have several dialogs it is a good idea to put each dialog in it's own module - particularly if there will be some event code to process user actions. This will have a benefit in that it forces some structure to your coding. It's good practice even if the code in each module is small.

    Define a module that imports the other modules. This would normally be the main entry point of the program so you can call it login.py. The main module does not have to have GUI stuff at all it can just co-ordinate the other modules that do have GUI stuff (like a module for your login dialog).

    Define a module for the frequently used but small chunks of code for things like error reports or yes/no dialogs.

    grim
  4. #3
  5. 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
    How about using classes as well very helpful

    and ofcourse you would use a login in window and then a executtion window.

    But make it so that the login is a toplevel widget in Tkinter depends
    Those people who think they know everything are a great annoyance to those of us who do.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2005
    Location
    USA
    Posts
    4
    Rep Power
    0
    Ok, thanks for the suggestions. I'll look into it.

IMN logo majestic logo threadwatch logo seochat tools logo