ENGR/CS 101 CS Session Lecture 15

Similar documents
ENGR/CS 101 CS Session Lecture 12

When to use the Grid Manager

Mid Unit Review. Of the four learning outcomes for this unit, we have covered the first two. 1.1 LO1 2.1 LO2 LO2

Part 3. Useful Python

Level 3 Computing Year 2 Lecturer: Phil Smith

Programming Training. This Week: Tkinter for GUI Interfaces. Some examples

Application Note: Creating a Python Graphical User Interface. Matthew Roach March 31 st, 2014

ENGR/CS 101 CS Session Lecture 4

Tkinter Part II: Buttons, Lambda & Dynamic Content

Outline. general information policies for the final exam

CS 112: Intro to Comp Prog

Microsoft Word 2013 Working with tables

This text is used together with Mark Pilgrims book Dive Into Python 3 for the Arthead course Python Fundamentals.

Lecture 3 - Overview. More about functions Operators Very briefly about naming conventions Graphical user interfaces (GUIs)

# arrange Label in parent widget

ENGR/CS 101 CS Session Lecture 13

CS 2316 Exam 2 Summer 2011

CS 2316 Homework 9b GT Thrift Shop Due: Wednesday, April 20 th, before 11:55 PM Out of 100 points. Premise

Unit 10: Data Structures CS 101, Fall 2018

Word 3 Microsoft Word 2013

CS 2316 Exam 3 Fall 2011

CS 2316 Individual Homework 5 Joint Probability Out of 100 points

How to lay out a web page with CSS

How to set up a local root folder and site structure

Graphical User Interfaces

Tcl/Tk lecture. What is the Wish Interpreter? CIS 410/510 User Interface Programming

Selected GUI elements:

Easy Graphical User Interfaces

Excel 2013 Part 2. 2) Creating Different Charts

CAS London CPD Day February 16

ENGR/CS 101 CS Session Lecture 9

CS2021 Week #6. Tkinter structure. GUI Programming using Tkinter

Using Adobe Contribute 4 A guide for new website authors

Using SymPrint to Make Overlays, Templates & More...

This homework has an opportunity for substantial extra credit, which is described at the end of this document.

Graphical User Interfaces with Perl/Tk. Event Driven Programming. Structure of an Event-Driven Program. An introduction

ADOBE DREAMWEAVER CS4 BASICS

Week 5 Creating a Calendar. About Tables. Making a Calendar From a Table Template. Week 5 Word 2010

Chapter 9 GUI Programming Using Tkinter. Copyright 2012 by Pearson Education, Inc. All Rights Reserved.

Introduction to Programming Using Python Lecture 6. Dr. Zhang COSC 1437 Spring, 2018 March 01, 2018

CIS192 Python Programming

Python GUIs. $ conda install pyqt

User Interfaces. getting arguments of the command line a command line interface to store points fitting points with polyfit of numpy

Joomla! 2.5.x Training Manual

Budget Exercise for Intermediate Excel

Reference Services Division Presents. Microsoft Word 2

Spreadsheet View and Basic Statistics Concepts

CROMWELLSTUDIOS. Content Management System Instruction Manual V1. Content Management System. V1

Microsoft Word ext Saving your documents. Formatting your document. Formatting your text. Working with images

CS 2316 Homework 9a GT Room Reservation Login

SIMPLE TEXT LAYOUT FOR COREL DRAW. When you start Corel Draw, you will see the following welcome screen.

Teach Yourself Microsoft Excel Topic 5: Revision, Headers & Footers, Metadata

Creating & Modifying Tables in Word 2003

Driver Installation. 111 Please uninstall the other tablet drivers before installing the driver of this product.

Mach4 CNC Controller Screen Editing Guide Version 1.0

Using Dreamweaver. 4 Creating a Template. Logo. Page Heading. Home About Us Gallery Ordering Contact Us Links. Page content in this area

Introduction To Python

Object-Oriented Programming

CS Multimedia and Communications. Lab 06: Webpage Tables and Image Links (Website Design part 3 of 3)

Getting Started Quick Start Guide

COMPUTER SKILLS LECTURE Dr. Ali Kattan Mr. Tooraj Hassan Mr. Mohamed Nasseh

Introduction to Programming

Dreamweaver MX Overview. Maintaining a Web Site

Part 3. Operating Systems

Microsoft Word 2007 on Windows

How To Series Roland DisplayStudio Split Screen Layout Guide

Formatting, Saving and Printing in Word 2013

HO-1: BASIC SPREADSHEET SKILLS - CREATING A WORKBOOK

Sun VirtualBox Installation Tutorial

13. Albums & Multi-Image Printing

Teaching London Computing

Rich Text Editor Quick Reference

Basic Computer Course

Using Microsoft Word. Tables

Objectives. Structure. Munster Programming Training

1.0 Overview For content management, Joomla divides into some basic components: the Article

Course Outline - COMP150. Lectures and Labs

Changing Table Size and Layout

FORMS. The Exciting World of Creating RSVPs and Gathering Information with Forms in ClickDimensions. Presented by: John Reamer

CS 2316 Homework 9a GT Pizza Login Due: Wednesday November 6th Out of 100 points. Premise

CIS192 Python Programming

Working With Microsoft Word 2013

Eng 110, Spring Week 03 Lab02- Dreamwaver Session

Modified Distribution Method

Microsoft Excel can be run on any computer which meets these requirements:

Cisco UCS Diagnostics User Guide for B-Series Servers, Release 1.0

Unit 12. Electronic Spreadsheets - Microsoft Excel. Desired Outcomes

Overview of the Adobe Dreamweaver CS5 workspace

Beginners Guide to Snippet Master PRO

Sema Foundation ICT Department. Lesson - 18

Creating Reports in Access 2007 Table of Contents GUIDE TO DESIGNING REPORTS... 3 DECIDE HOW TO LAY OUT YOUR REPORT... 3 MAKE A SKETCH OF YOUR

Accessing Rhino Page Layouts

VHIMS UPGRADE VERSION

Using the Homepage. For RiskMan Version Last reviewed 10 Jun Copyright 2016 Page RiskMan 1 of International 10 Pty Ltd

Graphical User Interfaces

CS123. Programming Your Personal Robot. Part 2: Event Driven Behavior

Basic Excel 2010 Workshop 101

Part I: Creating a Simple Text Entry on a Web Page

Creating a Website in Schoolwires

Adobe Dreamweaver CS5 Tutorial

Transcription:

ENGR/CS 101 CS Session Lecture 15 Log into Windows/ACENET (reboot if in Linux) Use web browser to go to session webpage http://csserver.evansville.edu/~hwang/f14-courses/cs101.html Right-click on lecture15.py link. Save link/target to folder where your other CS 101 programs are. Browse to lecture15.py, right-click on it and select Edit with IDLE. Lecture 15 ENGR/CS 101 Computer Science Session 1

Outline Homework 3 out, due on Wednesday, December 3 (i.e. after Thanksgiving) Building GUIs in Python Widgets Layouts Lecture 15 ENGR/CS 101 Computer Science Session 2

Windowing Systems WIMP interface: Window, Icons, Menus, Pointers Abstract actual hardware into concepts of screen, keyboard, and mouse Device drivers translate abstract commands into actual hardware commands USB has become a meta-abstraction for many peripherals Lecture 15 ENGR/CS 101 Computer Science Session 3

Window Management Several ways to organize windows Each application could be responsible for its own windows. Not efficient. Operating system manages windows. E.g. Windows, old MacOS Separate management server, e.g. X Windows. Generic across operating systems, e.g. Unix, MacOS X. Generally, client-server architecture; often network-based Lecture 15 ENGR/CS 101 Computer Science Session 4

Event-Driven Programming Modern GUIs are notification-based Each program registers a handler function for events it is interested in. E.g., keypress, mouse click, mouse move... Handlers also are called callback functions Lecture 15 ENGR/CS 101 Computer Science Session 5

Graphical User Interface (GUI) User interface design is separate from computational design Want to create a GUI for the program from Lecture 4 that computes a monthly loan payment. Function to compute the monthly loan payment is the same. Lecture 15 ENGR/CS 101 Computer Science Session 6

Python GUIs There are several different libraries for creating a GUI in Python. The Tkinter library is built into the Python system and is an interface to the Tcl/Tk language. It needs to be imported. from Tkinter import * The main window is created and started using topwindow = Tk() topwindow.mainloop() Lecture 15 ENGR/CS 101 Computer Science Session 7

Widgets GUI elements are called widgets. When widgets are created, they are given a parent GUI element and any options. The options are passed using keywords. Common options include text, foreground(fg), background (bg), width, height, padx, pady Lecture 15 ENGR/CS 101 Computer Science Session 8

Labels A Label is a widget that holds text. lbl = Label(root, text="hello!") Lecture 15 ENGR/CS 101 Computer Science Session 9

Entries An Entry is used for data entry. One of its options is justification of the text displayed in the entry. The text itself must be inserted starting at a particular index. inputentry = Entry(root, justify=right) inputentry.insert(0, "0") Lecture 15 ENGR/CS 101 Computer Science Session 10

Buttons A Button has a command option that is a function that is executed when the button is clicked. submitbtn = Button(root, text='calculate', command=submithandler, bg='purple', fg='orange', padx=20) Lecture 15 ENGR/CS 101 Computer Science Session 11

Layout Management Widgets are arranged using a layout manager. Python has several, but we will be using the grid manager, since it is the easiest to understand. As the name implies, the grid manager lays out widgets in a grid. A row and a column index is given. E.g. submitbtn.grid(row=0, column=0) # (0,0) is upper-left corner Lecture 15 ENGR/CS 101 Computer Science Session 12

Layout Management The size of the rows and columns depend on the largest widget being placed in the row/column. When a widget is smaller than its cell, the sticky option can be used to justify it. lbl.grid(row=rownum, column=0, sticky='w') Widgets also can span rows/columns submitbtn.grid(row=rownum, column=0, columnspan=2) Lecture 15 ENGR/CS 101 Computer Science Session 13

makeform Function The function makeform in lecture15.py will create the GUI for the program. Each row consists of a Label (in column 0) and an Entry (in column 1). The Label texts are the field names that come from the inputfields and outputfields lists. A dictionary is created with the field names as keys and the Entry widgets as the corresponding values, so that the button handler can access the Entry widgets. Lecture 15 ENGR/CS 101 Computer Science Session 14

makeform Design, Part 1 1. Start rownum at 0 and create an empty dictionary 2. For each field name in the input field list a. Create a Label with the field name b. Put the Label in grid location (rownum, 0), left justified c. Create an Entry with right justified text d. Set the Entry text to "0" e. Put the Entry in grid location (rownum, 1) f. Put <Label, Entry> pair into the dictionary g. Increment rownum Lecture 15 ENGR/CS 101 Computer Science Session 15

makeform Design, Part 2 3. Create a Button connected to a handler 4. Put the Button into the grid (e.g. location (rownum, 0)) updating rownum as appropriate 5. For each field name in the output field list a. Do the same as for the input fields 6. Return the dictionary Lecture 15 ENGR/CS 101 Computer Science Session 16

In-class Exercise Implement the body of the first for-loop in the makeform function. That is, for each row, create a Label and an Entry, and place them into the grid of the root widget. Create a Button with handler function submithandler and place it between the input and output fields. Lecture 15 ENGR/CS 101 Computer Science Session 17

In-class Exercise Run the program. It should create a window, but since there's no handler, it does not compute anything. Experiment with the colors and placement of the button. See if you can put the button to the right of the entries in the middle of the column. Lecture 15 ENGR/CS 101 Computer Science Session 18