Difference between revisions of "Intro to Tkinter"

From oldwiki.scinet.utoronto.ca
Jump to navigation Jump to search
Line 9: Line 9:
 
* GUIs and threads
 
* GUIs and threads
  
=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 can also try <pre>import tkinter</pre>.
* Then download the virtual machine image you want to use:
+
* Python Imaging Library (PIL).  Again, this can be tested by typing <pre>import PIL</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 any of 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)
 
 
 
Then make sure everything is working:
 
* 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.
 
* 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.
 

Revision as of 11:50, 2 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

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 can also try
    import tkinter
    .
  • Python Imaging Library (PIL). Again, this can be tested by typing
    import PIL
    from the Python command line.

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