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

    Join Date
    Sep 2013
    Posts
    19
    Rep Power
    0

    When to start learning Tkinter?


    I'm teaching myself Python 3.3.2 on a Debian 7.1 system. My resources are the free online book _How to Think Like a Computer Scientist_, the official Python tutorial at docs.python.org, and whatever help I can get from more experienced programmers publicly or through email.

    I'm getting the idea that my Python scripts will be kind of useless unless I learn either PyGtk or Tkinter. I can learn PyGtk for Linux use in Python 2.7.x, but my system doesn't seem to provide it for 3.x, while it does provide Tkinter for 3.x, so I'm going to focus on learning Tkinter.

    My question is how advanced I need to be in learning Python itself before I start learning Tkinter. Should I be progressing through Tkinter at the same time as I progress through Python, or should I leave learning Tkinter until after I've become a reasonably proficient Python programmer?
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    I've been learning tkinter for about 15 years now. Lots there. And I started reading the xlib books back in the '80's, wrote a few programs using x11 directly. Many concepts are transferable.

    You can learn the concepts of tkinter by learning and using tcl in parallel with your python studies. In fact, now that I've found this tutorial I might work through it myself.
    Last edited by b49P23TIvg; September 12th, 2013 at 09:03 AM.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    19
    Rep Power
    0
    I had no trouble installing tcl 8.5 on my Debian 7.1 system using the command line. Do I need to add any frontends or libraries for the purpose of that tutorial?

    Also, I don't see a publication or revision date on that tutorial, so does it use the latest and most up-to-date version of tcl?

    It appears that tcl has its own Tk functionality for GUI. What does it do better than Python3.x+Tkinter, and what does it do less well?
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,996
    Rep Power
    481
    tkinter is a front end to tcl.

    I'm pretty sure that creating a top level tkinter widget starts a tcl interpreter.
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    620
    Rep Power
    65
    If you look at a basic program structure:

    Input
    Processing
    Output

    The Python wrapped GUI toolkit gives you the input and output tools and the processing is done with just Python.

    Go with Tkinter, there are a lot of good examples out there.
    Tkinter also comes with some nice expansion tools like ttk:

    Ttk comes with 17 widgets, 11 of which already exist in Tkinter:
    Button, Checkbutton, Entry, Frame, Label, LabelFrame, Menubutton,
    PanedWindow, Radiobutton, Scale and Scrollbar
    The 6 new widget classes are:
    Combobox, Notebook, Progressbar, Separator, Sizegrip and Treeview

    My advice, you should be familiar with Python class objects before you get into GUI programming. All the widgets are based on class.

    You can run TCL code from within Python/Tkinter, but that would be silly since Tkinter does that for you as a wrapper.

    For help look into your Python help file under tkinter or tkinter.ttk

    One of the best Tkinter references is here:
    http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html
    Last edited by Dietrich; September 12th, 2013 at 12:36 PM.
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    19
    Rep Power
    0
    Originally Posted by b49P23TIvg
    tkinter is a front end to tcl.

    I'm pretty sure that creating a top level tkinter widget starts a tcl interpreter.
    Uh-oh! What if the top-level tkinter widget is in a Python script? Would there be conflicts between the Python and tcl interpreters?
  12. #7
  13. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    620
    Rep Power
    65
    See:
    http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/toplevel.html

    Advice:
    Yes, Tkinter has a built-in TCL interpreter. Forget coding in TCL, or you will never learn Python GUI programming.
    Last edited by Dietrich; September 12th, 2013 at 12:49 PM.
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25

IMN logo majestic logo threadwatch logo seochat tools logo