Difference between revisions of "Intro to Tkinter"

From oldwiki.scinet.utoronto.ca
Jump to navigation Jump to search
 
(10 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
* Pop-up windows
 
* Pop-up windows
 
* Menus, bindings
 
* Menus, bindings
* Thread use.
+
* GUIs and threads
 +
Please note that beginner-intermediate experience with Python will be assumed.  If you are new to Python, be sure to brush-up before class.
  
=VM Instructions=
+
=Laptop-preparation Instructions=
  
This course will feature hands-on work with a 1-node Hadoop cluster running on your laptop.  The VMs are created with [http://www.vagrantup.com Vagrant].  Before the course, ensure this is up and running:
+
This course will feature in-class hands-on work, to be performed on your laptop.  Before coming to the class, please ensure that the following are installed on your laptop:
  
* Install [https://www.virtualbox.org VirtualBox] on your laptop and start it.
+
* Some version of Python. The class will be taught using Python 2.7.X, but any more-recent version of Python (2.6.X, 3.3.X) should work.
* Under Settings or Preferences, go to Network, then Host-only networks, and add/create two host-only networks.
+
* Tkinter.  Be sure to test the installation to make sure that it works correctly.  This can be done by typing <pre>import Tkinter</pre> from a Python command line.  If that doesn't work you are probably running Python 3.3.X. Try the following instead: <pre>import tkinter</pre>.
* Then download the virtual machine image you want to use:
+
* Pillow. This package is a friendly fork of the Python Imaging Library (PIL), which is no longer being maintained. Again, this can be tested by typing <pre>import PIL</pre> and if you are using Windows: <pre>import _imaging</pre> from the Python command line.  
** [https://support.scinet.utoronto.ca/~ljdursi/Hadoop/VMs/GUI/GUI-VM.ova Full Size VM with GUI (require peak of ~8GB free disk space)]
 
** [https://support.scinet.utoronto.ca/~ljdursi/Hadoop/VMs/text/Text-VM.ova Smaller, Text-only (require peak of ~6GB free disk space)]
 
* "Import Appliance", and select the downloaded image; this will uncompress the image which will take some minutes.
 
* Start the new virtual machine.
 
  
The GUI VM will start up a console with a full desktop environment; you can open a terminal and begin working.  For the text VM, you will have to login to the console; the username/password is vagrant/vagrant.  For either machine, you can also ssh into the VM from your laptop from the terminal: <pre>ssh vagrant@192.168.33.10</pre> or to the laptop from the VM with <pre>ssh [username]@192.168.33.1</pre>
+
If you can't get the aforementioned software working on your laptop, please contact us and we will assist you.
  
(If that particular address pair doesn't work, from a window within the VM, type "ifconfig | grep 192" to find a line like "inet addr: 192.168...."; that's the VMs IP address)
+
=Helpful links=
 
+
* [http://www.effbot.org/tkinterbook/tkinter-index.htm An introduction to Tkinter]
Then make sure everything is working:
+
* [http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html Tkinter 8.5 reference]
* From a terminal, start up the hadoop cluster by typing <pre>~/bin/init.sh</pre>  You may have to answer "yes" a few times to start up some servers.
+
* [http://cs.mcgill.ca/~hv/classes/MS/TkinterPres Another introduction to Tkinter]
* Go to one of the example directories by typing <pre>cd ~/examples/wordcount/streaming</pre>
 
* Then start the example by typing <pre>make</pre>
 
 
 
You've now run your (maybe) first Hadoop job!
 
 
 
If you'd like, you can also create the virtual machine image yourself by downloading [http://www.vagrantup.com Vagrant] and the Vagrantfile for the [https://support.scinet.utoronto.ca/~ljdursi/Hadoop/VMs/GUI/Vagrantfile GUI] or [https://support.scinet.utoronto.ca/~ljdursi/Hadoop/VMs/text/Vagrantfile text] image and running "vagrant up".  If you vagrant-up the GUI VM, you will have to "vagrant reload" after installation is completed to restart with all the software installed.
 
 
 
If you can't get the VM working for whatever reason, please contact us and we will make alternate arrangements.
 

Latest revision as of 13:15, 9 September 2014

Overview

This is a ~2 hour class that will introduce Graphical User Interface (GUI) programming using the Python Tkinter module. Topics covered will include:

  • The creation of widgets
  • Geometry Managers
  • Pop-up windows
  • Menus, bindings
  • GUIs and threads

Please note that beginner-intermediate experience with Python will be assumed. If you are new to Python, be sure to brush-up before class.

Laptop-preparation Instructions

This course will feature in-class hands-on work, to be performed on your laptop. Before coming to the class, please ensure that the following are installed on your laptop:

  • Some version of Python. The class will be taught using Python 2.7.X, but any more-recent version of Python (2.6.X, 3.3.X) should work.
  • Tkinter. Be sure to test the installation to make sure that it works correctly. This can be done by typing
    import Tkinter
    from a Python command line. If that doesn't work you are probably running Python 3.3.X. Try the following instead:
    import tkinter
    .
  • Pillow. This package is a friendly fork of the Python Imaging Library (PIL), which is no longer being maintained. Again, this can be tested by typing
    import PIL
    and if you are using Windows:
    import _imaging
    from the Python command line.

If you can't get the aforementioned software working on your laptop, please contact us and we will assist you.

Helpful links