How the Session Works

Similar documents
Python Crash Course: GUIs with Tkinter

GUI application set up using QT designer. Sana Siddique. Team 5

Scientific Visualization with wxpython and Matplotlib. Scott Pearse CSCI 5448 Spring 2011

This Skill Builder demonstrates how to define and place sketched symbols in drawings.

Building a Python Plugin

Making Visio Diagrams Come Alive with Data

SHAREPOINT 2010 FOUNDATION FOR END USERS

Rapid Application Development with GNOME and Python

Excel & Visual Basic for Applications (VBA)

Create Charts in Excel

Guide to SAS/AF Applications Development

Table of Contents. 1. Content Approval...1 EVALUATION COPY

In this session, we will explain some of the basics of word processing. 1. Start Microsoft Word 11. Edit the Document cut & move

8 CREATING FORM WITH FORM WIZARD AND FORM DESIGNER

Introduction to MS WINDOWS XP

Adding A Student Course Survey Link For Fully Online Courses Into A Canvas Course

Creating Forms with Acrobat 10

Scientific Graphing in Excel 2010

Getting Started on the Computer With Mouseaerobics! Windows XP

Microsoft Access GUI Building

Adobe Digital Signatures in Adobe Acrobat X Pro

Introduction To Microsoft Office PowerPoint Bob Booth July 2008 AP-PPT5

I ntroduction. Accessing Microsoft PowerPoint. Anatomy of a PowerPoint Window

Creating Interactive PDF Forms

Creating a Test in Blackboard

Microsoft Office 2010: Introductory Q&As PowerPoint Chapter 1

The VB development environment

Word 2007 Unit B: Editing Documents

Maximizing the Use of Slide Masters to Make Global Changes in PowerPoint

Microsoft Office PowerPoint Creating a new presentation from a design template. Creating a new presentation from a design template

What is Microsoft PowerPoint?

Building Applications With DUIM

NIS-Elements Viewer. User's Guide

Advanced Excel 10/20/2011 1

Creating tables of contents and figures in Word 2013

Creating Hyperlinks & Buttons InDesign CS6

DiskPulse DISK CHANGE MONITOR

To Begin Customize Office

Content Author's Reference and Cookbook

Microsoft Access Basics

KaleidaGraph Quick Start Guide

Generating lesson plans with. Adobe Acrobat

Manual English KOI Desktop App 2.0.x

Converting Microsoft Access 2002 to Pipe-Delimited ASCII Text Files

Microsoft Publisher 2010 What s New!

Generating Automated Test Scripts for AltioLive using QF Test

Frog VLE Update. Latest Features and Enhancements. September 2014

EXAMPLE WITH NO NAME EXAMPLE WITH A NAME

Microsoft PowerPoint 2010 Handout

Macros in Word & Excel

Intermediate PowerPoint

ACS Version Check Layout Design

Smart Connection 9 Element Labels

Appendix A How to create a data-sharing lab

Continue reading to learn how to submit your customs documents electronically using FedEx Electronic Trade Documents.

Step-by-Step Help Guide for Freegal Movies and Television

Database File. Table. Field. Datatype. Value. Department of Computer and Mathematical Sciences

Formulas, Functions and Charts

Outlook . User Guide IS TRAINING CENTER. 833 Chestnut St, Suite 600. Philadelphia, PA

MS WORD 2007 (PC) Macros and Track Changes Please note the latest Macintosh version of MS Word does not have Macros.

USER MANUAL (PRO-CURO LITE, PRO & ENT) [SUPPLIED FOR VERSION 3]

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

How To Change Your Site On Drupal Cloud On A Pcode On A Microsoft Powerstone On A Macbook Or Ipad (For Free) On A Freebie (For A Free Download) On An Ipad Or Ipa (For

Specialized Programme on Web Application Development using Open Source Tools

Introduction to Microsoft Excel 2007/2010

Tutorial 13: Object Animation

Chaco: A Plotting Package for Scientists and Engineers. David C. Morrill Enthought, Inc.

Creating Fill-able Forms using Acrobat 8.0: Part 1

Module One: Getting Started Opening Outlook Setting Up Outlook for the First Time Understanding the Interface...

How to create labels using a Microsoft Access data file?

Training Guide Travel & Expenses How to Find an Expense Report Number or an Employee ID. State of Kansas

Data Warehouse Troubleshooting Tips

DataPA OpenAnalytics End User Training

Text Basics. Introduction

Dreamweaver. Introduction to Editing Web Pages

designvue manual v1 Index This document contains the following sections:

CREATE A 3D MOVIE IN DIRECTOR

Workspaces Creating and Opening Pages Creating Ticker Lists Looking up Ticker Symbols Ticker Sync Groups Market Summary Snap Quote Key Statistics

Shipment Label Header Guide

What is OneDrive for Business at University of Greenwich? Accessing OneDrive from Office 365

SnagIt Add-Ins User Guide

Web Ambassador Training on the CMS

Drawing a histogram using Excel

Randy Hyde s Win32 Assembly Language Tutorials (Featuring HOWL) #4: Radio Buttons

Shasta College SharePoint Tutorial. Create an HTML Form

Content Author's Reference and Cookbook

Handout: Word 2010 Tips and Shortcuts

Hildon User Interface Style Guide Summary

Some programming experience in a high-level structured programming language is recommended.

Nintex Forms 2013 Help

Process Document Approve Payable Time

Sales Person Commission

Python programming GUI

Avery Dennison UK Consumer Helpline: Consumer

3F6 - Software Engineering and Design. Handout 9 User Interface Design With Markup. Ed Rosten

6. If you want to enter specific formats, click the Format Tab to auto format the information that is entered into the field.

Generate Android App

Microsoft Excel Basics

McAfee Endpoint Encryption Reporting Tool

Microsoft Word Revising Word Documents Using Markup Tools

Transcription:

How the Session Works Outline Practical on arrival Talk 1 Reflect on practical Clarify concepts Practical exercises at your own pace Talk 2: Further concepts Overall reflection Continue practical exercises at home Getting Started Log-on Find portable Python on L:\ drive Start IDLE Find resources on teachinglondoncomputing.org Exercise sheet (and notes) START NOW Example programs Slides

First Program Click the Button Code provided but not yet explained Use pattern matching (i.e. intelligent guessing) to modify it

Teaching London Computing A Level Computer Science Programming GUI in Python William Marsh School of Electronic Engineering and Computer Science Queen Mary University of London

Outline A first program Concepts in Graphical User Interface Components / widgets and attributes Events / actions Layout Practical examples Challenges of GUI programming Choosing a GUI library Using Object-Oriented programming

Key Concepts Explained Using the Button Example

Key Concepts A widget / component E.g. a button, a frame Attributes e.g. the button text Actions E.g. what happens when you press the button Layout Positioning widgets

AppInventor Code for events Widgets, called components Hierarchy of components Attributes called properties

Widgets A GUI is made up from widgets A widget is created Widget has attributes One widget may contain another: Frame contains the button frame button

Create a Widget Constructor Name same as widget Hierarchy of widget Optional arguments # Create a main frame with # - a title # - size 200 by 200 pixels app = Tk() app.title("gui Example 1") app.geometry('200x200') Constructor Parent widget Optional argument # Create the button # - with suitable text # - a command to call when the button is pressed button1 = Button(app, text="click Here", command=clicked)

Widgets have Attributes E.g. a name, size Any property of the widget that makes it specific # Create a main frame with # - a title # - size 200 by 200 pixels app = Tk() app.title("gui Example 1") app.geometry('200x200') Attributes set by constructor (note use of keyword arguments) Methods to set attributes # Create the button # - with suitable text # - a command to call when the button is pressed button1 = Button(app, text="click Here", command=clicked)

How to Set / Get an Attribute Method 1 (setting): Set value with the constructor Method 2 (setting and getting): Widget is a dictionary # Change button text mtext = button1['text'] button1['text'] = mtext.upper() Method 3 (sometimes) Call a suitable method Other methods exist

Aside: Dictionaries Dictionary: a map from a key to a value Unique key Built in (Python) versus library (many other languages) Standard Array Index by number Indices continuous e.g. 0 à 10 Holds only number, character Python Dictionary Key can be a string, pair, Gaps ok Any value even a dictionary # Change button text mtext = button1['text'] button1['text'] = mtext.upper() Lookup Update

Handle an Event # This method is called when the button is pressed def clicked(): print("clicked") # Create the button with # - a command to call when the button is pressed button1 = Button(app, text="click Here", command=clicked) Events Button, mouse click, key press Action Event bound to function Name of a Method

Layout the Widget # Make the button visible at the bottom of the frame button1.pack(side='bottom') Where does the widget go? Hierarchy Top-level window Layout manager Several available Problem of resizing The pack layout manager is simplest Widget is not visible until packed

A Minimal Application # Import the Tkinter package # Note in Python 3 it is all lowercase from tkinter import * # Create a main frame app = Tk() # Start the application running app.mainloop() Loop to handle events # Import the Tkinter package # Note in Python 3 it is all lowercase import tkinter as tk # Create a main frame app = tk.tk() import with prefix # Start the application running app.mainloop()

(Some) tkinter Widgets Widget Button Canvas Entry Frame Label Menu Radiobutton Scrollbar Text Toplevel Use A button For drawing graphics Entry a line of text A rectangular area containing other widgets Display a single line of text A set of options shown when on a menu bar Select one of a number of choices Horizontal or vertical scrolling of a window A multi-line text entry A top-level frame

Further Practical Exercises See exercise sheet A sequence of exercises introduce other widgets and apply the core concepts probably too many to finish now You may also need to refer to the notes at the end

Further Concepts Dialog Top-level window Control variables

Dialogs You must respond to a dialog Messages File choosing

Top-Level Windows At least one top-level window Conveniently created using Tk()! Like a frame but Menu bar Standard buttons Borders

Control Variables Variables linking Entry widget to its text Choices in a RadioButton These are objects in the framework

Challenges in GUI Which framework? How to design a GUI How much OOP?

GUI Framework A GUI framework defines a set of widgets Windows has it s own GUI framework Python uses a portable GUI framework tkinter, depends on Tk and TCL PyQT, depends on QT Tkinter Pro: simple, easy to install Cons: a bit limited; documentation weak PyQT: more complex

Designing a GUI What am I trying to do? What widgets do I need? Where will they go? How do they behave?

screen. Later we will talk about how to connect the face the front panel of the ap logic behind it. 2. A minimal application The OOP Problem Here is a trivial Tkinter program containing only a Quit button: Why OO and GUI Widgets are classes Default behaviour GUI programs are often organised using classes #!/usr/bin/env python 1 import Tkinter as tk 2 class Application(tk.Frame): 3 def init (self, master=none): tk.frame. init (self, master) 4 self.grid() 5 self.createwidgets() def createwidgets(self): self.quitbutton = tk.button(self, text='quit', command=self.quit) 6 self.quitbutton.grid() 7 app = Application() 8 app.master.title('sample application') 9 app.mainloop() 10 Practical Problem: most examples use OOP 1 This line makes the script self-executing, assuming that your system has Python co 2 This line imports the Tkinter module into your program's namespace, but rename 3 Your application class must inherit from Tkinter's Frame class. 4 Calls the constructor for the parent class, Frame. 5 Necessary to make the application actually appear on the screen. 6 Creates a button labeled Quit. 7 Places the button on the application. 8 The main program starts here by instantiating the Application class.

Summary Core concepts common to all framework Understand principles Learn about available widgets Look up attributes and methods After programming interface design