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.

Slides:



Advertisements
Similar presentations
Introduction to Computers Section 6A. home The Operating System (OS) The operating system (OS) is software that controls the interaction between hardware.
Advertisements

Windows Test Review.
Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
Introducing Microsoft PowerPoint 2010 John Matthews (ITS)
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
Office XP Introductory Concepts and Techniques Windows XP Edition M i c r o s o f t Windows XP Project An Introduction to Windows XP Professional and Office.
Graphical User Interfaces in Haskell Koen Lindström Claessen.
I210 review (for final exam) Fall 2011, IUB. What’s in the Final Exam Multiple Choice (5) Short Answer (5) Program Completion (3) Note: A single-sided.
Slide 1 Chapter 2 Visual Basic Interface. Slide 2 Chapter 2 Windows GUI  A GUI is a graphical user interface.  The interface is what appears on the.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
1 iSee Player Tutorial Using the Forest Biomass Accumulation Model as an Example ( Tutorial Developed by: (
An Introduction to Visual Basic
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Guide to Programming with Python Chapter Ten GUI Development: The Mad Lib Program.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
PC204 Lecture 9 Conrad Huang Genentech Hall, N453A x
PYTHON GUI PROGRAMMING
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
Computer Science 112 Fundamentals of Programming II Command Buttons and Responding to Events.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 20 Graphical User Interface (GUI)
Python Programming Graphical User Interfaces Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Computing Science 1P Lecture 17: Friday 23 rd February Simon Gay Department of Computing Science University of Glasgow 2006/07.
Chapter Two Creating a First Project in Visual Basic.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
CC111 Lec7 : Visual Basic 1 Visual Basic(1) Lecture 7.
CS130 Project 1 A simple VB application ("project" or program): user enters amount of sales then clicks the "Calculate button", the application displays.
MS Visual Basic 6 Walter Milner. VB 6 0 Introduction –background to VB, A hello World program 1 Core language 1 –Projects, data types, variables, forms,
Graphical User Interface You will be used to using programs that have a graphical user interface (GUI). So far you have been writing programs that have.
SEEM3460 Tutorial GUI in Java. Some Basic GUI Terms Component (Control in some languages) the basic GUI unit something visible something that user can.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Graphics Programming with Python. Many choices Python offers us several library choices:  Tkinter  WxPython  PyQt  PyGTK  Jython  And others...
Creating visual interfaces in python
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
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.
Guide to Programming with Python
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces.
VB.NET and Databases. ADO.NET VB.Net allows you many ways to connect to a database. The technology used to interact with a database or data source is.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 2 The Visual Basic.NET Integrated Development Environment.
COMPSA Exam Prep Session by Paul Allison On: April 8th from 1:30-3:00 Location TBA Winter 2016CISC101 - Prof. McLeod1.
XP New Perspectives on Creating Web Pages With Word Tutorial 1 1 Creating Web Pages With Word Tutorial 1.
CSC 108H: Introduction to Computer Programming Summer 2011 Marek Janicki.
Fundamentals of Windows Mouse n 4 Basic Operations: –Pointing –Clicking –Double Clicking –Dragging.
Visual Basic .NET BASICS
Topics Graphical User Interfaces Using the tkinter Module
Graphical User Interfaces (GUIs)
Microsoft Visual Basic 2005 BASICS
Computer Science 111 Fundamentals of Programming I
Visual Basic Code & No.: CS 218
Introduction to Computer CC111
Program and Graphical User Interface Design
1. Introduction to Visual Basic
GUI Using Python.
Fundamentals of Python: From First Programs Through Data Structures
Chapter 2 Visual Basic Interface
Program and Graphical User Interface Design
This Week: Tkinter for GUI Interfaces Some examples
Tkinter GUIs Computer Science and Software Engineering
Tutorial 6 Creating Dynamic Pages
GTK + Programming.
Fundamentals of Programming I Windows, Labels, and Command Buttons
Topics Graphical User Interfaces Using the tkinter Module
Fundamentals of Using Microsoft Windows XP
A Level Computer Science Topic 6: Introducing OOP
WEEK 8 COURSE PROJECT PRESENTATION NAME: ALEXANDER WEISS CLASS: CIS115.
Presentation transcript:

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 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

A Level Computer Science Programming GUI in Python T eaching L ondon C omputing 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 Widgets, called components Attributes called properties Code for events Hierarchy of components

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

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') # Create the button # - with suitable text # - a command to call when the button is pressed button1 = Button(app, text="Click Here", command=clicked) Constructor Parent widget Optional argument

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') # Create the button # - with suitable text # - a command to call when the button is pressed button1 = Button(app, text="Click Here", command=clicked) Attributes set by constructor (note use of keyword arguments) Methods to set attributes

How to Set / Get an Attribute Method 1 (setting): Set value with the constructor Method 2 (setting and getting): Widget is a dictionary Method 3 (sometimes) Call a suitable method # Change button text mText = button1['text'] button1['text'] = mText.upper() 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 ArrayPython Dictionary Index by numberKey can be a string, pair, … Indices continuous e.g. 0  10 Gaps ok Holds only number, characterAny value – even a dictionary # Change button text mText = button1['text'] button1['text'] = mText.upper() Lookup Update

Handle an Event Events Button, mouse click, key press Action Event ‘bound’ to function # 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) Name of a Method

Layout the Widget 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 # Make the button visible at the bottom of the frame button1.pack(side='bottom')

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() # Import the Tkinter package # Note in Python 3 it is all lowercase import tkinter as tk # Create a main frame app = tk.Tk() # Start the application running app.mainloop() Loop to handle events import with prefix

(Some) tkinter Widgets WidgetUse ButtonA button CanvasFor drawing graphics EntryEntry a line of text FrameA rectangular area containing other widgets LabelDisplay a single line of text MenuA set of options shown when on a menu bar RadiobuttonSelect one of a number of choices ScrollbarHorizontal or vertical scrolling of a window TextA multi-line text entry ToplevelA 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?

The OOP Problem Why OO and GUI Widgets are classes Default behaviour GUI programs are often organised using classes Practical Problem: most examples use OOP

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