# arrange Label in parent widget

Size: px
Start display at page:

Download "# arrange Label in parent widget"

Transcription

1 Much of today s software uses a point-and-click graphical user interface (GUI). The standard library modules Tkinter and Tix allow for portable, event-driven, GUI development in Python. A Python/Tkinter program is entirely event-driven, i.e., the program construct tailored GUI widgets via inheritence to suit the program s needs, register associated event-handles (call-back functions) with the Python virtual machine, then wait for the user to generate events (e.g., clicking the mouse on, entering some text into a field, typing some key at the keyboard, etc.) that the event-handles react to A very simple example would be to display a Label that s tailored as: from Tkinter import Label # load Label class widget = Label(None, text= Hellow World ) widget.pack() widget.mainloop() # make a customized Label object # arrange Label in parent widget # start event loop of Tkinter This would look slightly different under MAC or Linux operating system, but it would have the same functionality. Conceptually, the mainloop of Tkinter performs the following algorithm: def mainloop(): while the main window has not been closed: if an event has occurred: run the associated event handler function 1. A Button can have an event-handler associated with it (the command argument) that gets called when it is pressed. def myevent(): print "Button Pressed" # load Tkinter root = Tk() # Tk is the main window of program # make a customized Button object mybutton = Button(root, text= press, command=myevent) mybutton.pack(side=bottom, expand=no) # arrange Button in parent root.mainloop() # start event loop of root After running and pressing the button several times, the window containing the button and IDLE window is: Button Pressed Button Pressed Button Pressed Lecture 22 Page 1

2 2. Below is a simple example that constructs a frame and packs two buttons and a label into a frame # Hello_frameB.py class Hello(Frame): # Extend Frame class def init (self, parent=none): Frame. init (self, parent) # call superclass init self.pack() self.data = 0 self.showdatastring = StringVar() # create a String control variable self.showdatastring.set('data = %d' % (self.data)) self.make_widgets() # attach widgets to self def make_widgets(self): Button(self, text='count Clicks', command=self.message).pack(side=left) quitbutton = Button(self, text='quit', command=self.quit) quitbutton.pack(side=bottom) countlabel = Label(self, textvariable=self.showdatastring, width=50, justify=center) countlabel.pack(side=right) def message(self): self.data += 1 self.showdatastring.set('data = %d' % (self.data)) # end class Hello(Frame) Hello().mainloop() Every time the Count Clicks button is pressed, the Data = # label is updated using the control variable, showdatastring. A control variable is a special object that can be shared by several different widgets and updated automatically on the screen by using the.set( value ) method. Control variables also have a.get() method to return its current value. Control variables of type integer and float can be gotten using using the constructors IntVar() and DoubleVar(), respectively. Some examples where you might want to use control variables are: The Entry widget allows you to enter a line of text, which is normally linked to a control variable. A group of radiobuttons normally share a single control variable that allows them to tell which one gets selected and allows it to be cleared. Checkbuttons use a control variable to hold its current state: on or off. Lecture 22 Page 2

3 3. An example using the Entry widget to allow a line of text to be entered is: # EntryTest.py """Test the Entry widget""" self.name = StringVar() self.name.set("enter name here") self.age = IntVar() self.age.set("enter age here") self.textentry = Entry(self, takefocus=1, textvariable = self.name, width = 40) self.textentry.grid(row=0, sticky=e+w) self.ageentry = Entry(self, takefocus=1, textvariable = self.age, width = 20) self.ageentry.grid(row=1, sticky=w) The corresponding window is: The takefocus=1 allows you to <tab> between these items. The.grid() method is a layout manager for your GUI widgets that allows you to treat every window/frame as a two-dimensional grid of rows and columns. The width of a column is the width of its widest cell, similarly for rows. Widgets too small for their cells can expand (or not) by using the sticky option in the.grid() method, and specifying directions (N+S+E+W) for expansion. Widgets can also span multiple cells by specifying rowspan and columnspan options in the.grid() method. Lecture 22 Page 3

4 4. The following code illustrates a Listbox widget that allows election of several lines of text. # ListboxTest.py """Test the Listbox widget with event handling""" self.prompt = Label(self, text="select your favorite animals (select all \ that apply):") self.prompt.grid(row=0, sticky=w+e) self.yscroll = Scrollbar(self, orient=vertical) self.yscroll.grid(row=1, column=1,sticky=n+s) self.xscroll = Scrollbar(self, orient=horizontal) self.xscroll.grid(row=2, column=0,sticky=e+w) self.mylistbox = Listbox(self, xscrollcommand=self.xscroll.set, yscrollcommand=self.yscroll.set, selectmode=multiple) self.mylistbox.grid(row=1, column=0, sticky=n+s+e+w) self.mylistbox.insert(end, 'cat') self.mylistbox.insert(end, 'dog') self.mylistbox.insert(end, 'mouseeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee') self.mylistbox.insert(end, 'rat') self.mylistbox.insert(end, 'fish') self.xscroll["command"] = self.mylistbox.xview self.yscroll["command"] = self.mylistbox.yview self.donebutton = Button(self, text='click when \n done', command=self.readselections) self.donebutton.grid(row=3) def readselections(self): selectionstuple = self.mylistbox.curselection() print selectionstuple print "Favorite Animals:" for i in selectionstuple: print i, self.mylistbox.get(i) For the selections shown in the window, the Click when done button causes the following output to IDLE: ('0', '1', '4') Favorite Animals: 0 cat 1 dog 4 fish Lecture 22 Page 4

5 5. The Menubutton and Menu widgets allow you to build pull-down menus, for example: # MenuTest.py """Test the Menu widget with event handling""" self.breadmenubutton = Menubutton(self, text="bread", relief=raised) self.breadmenubutton.grid(row=0, column=0, sticky=n+w+e) self.rowconfigure(0, pad=100) self.breadmenubutton.menu = Menu(self.breadMenubutton, tearoff=0) self.breadmenubutton["menu"] = self.breadmenubutton.menu self.breadvar = StringVar() self.breadmenubutton.menu.add_radiobutton(label="white", variable=self.breadvar) self.breadmenubutton.menu.add_radiobutton(label="wheat", variable=self.breadvar) self.breadmenubutton.menu.add_radiobutton(label="rye", variable=self.breadvar) self.condimentsmenubutton = Menubutton(self, text="condiments", relief=raised) self.condimentsmenubutton.grid(row=0, column=1, sticky=n+w+e) self.condimentsmenubutton.menu = Menu(self.condimentsMenubutton, tearoff=0) self.condimentsmenubutton["menu"] = self.condimentsmenubutton.menu self.mayovar = IntVar() self.ketchupvar = IntVar() self.condimentsmenubutton.menu.add_checkbutton( label="mayo", variable=self.mayovar) self.condimentsmenubutton.menu.add_checkbutton( label="ketchup", variable=self.ketchupvar) self.donebutton = Button(self, text='click when done', command=self.readselections) self.donebutton.grid(row=3, column=0, columnspan=2,sticky=w+e) def readselections(self): print "Bread: ", self.breadvar.get() print "Condiments: ", if self.mayovar.get() == 1: print "mayo", if self.ketchupvar.get() == 1: print "ketchup", print The output of selecting rye and both mayo and ketchup would be: Bread: rye Condiments: mayo ketchup How would you add a Meat Menubutton with selections of beef, ham, turkey, and salami? Lecture 22 Page 5

6 6. A canvas can be used to draw objects and text as in: # CanvasTest.py """Test the Canvas widget and mouse events""" import sys self.dragging = False self.currentshapeid = None # end init self.shapemenubutton = Menubutton(self, text="shape", relief=raised) self.shapemenubutton.grid(row=0, column=0, sticky=n) self.shapemenubutton.menu = Menu(self.shapeMenubutton, tearoff=0) self.shapemenubutton["menu"] = self.shapemenubutton.menu self.shapevar = StringVar() self.shapemenubutton.menu.add_radiobutton( label="oval", command=self.shapeselection, value = "circle", variable=self.shapevar) self.shapemenubutton.menu.add_radiobutton( label="rectangle", command=self.shapeselection, value = "top_left_corner", variable=self.shapevar) self.shapevar.set("circle") self.mycanvas = Canvas(self, cursor=self.shapevar.get(),borderwidth=4, height='5i', width='7i') self.mycanvas.grid(row=1, column=0, columnspan=2) self.mycanvas.bind("<button-1>", self.startshape) self.mycanvas.bind("<motion>", self.sizeshape) self.mycanvas.bind("<buttonrelease-1>", self.endshape) self.donebutton = Button(self, text='click when done', command=self.doneselections) self.donebutton.grid(row=3, column=0, columnspan=2,sticky=w+e) # end createwidgets def shapeselection(self): print "Shape selected:", self.shapevar.get() self.mycanvas["cursor"] = self.shapevar.get() # end shapeselection def startshape(self, event): print "startshape: shape =", self.shapevar.get(),"x =", event.x, "y =", event.y self.dragging = True if self.shapevar.get() == "circle": self.currentshapeid = self.mycanvas.create_oval(event.x, event.y, event.x, event.y) elif self.shapevar.get() == "top_left_corner": self.currentshapeid = self.mycanvas.create_rectangle(event.x, event.y, event.x, event.y) # end startshape (Continued on Next Page) Lecture 22 Page 6

7 def sizeshape(self, event): if self.dragging: oldcoords = self.mycanvas.coords(self.currentshapeid) self.mycanvas.delete(self.currentshapeid) if self.shapevar.get() == "circle": self.currentshapeid = self.mycanvas.create_oval(oldcoords[0], oldcoords[1], event.x, event.y) elif self.shapevar.get() == "top_left_corner": self.currentshapeid = self.mycanvas.create_rectangle(oldcoords[0], oldcoords[1], event.x, event.y) # end if # end if # end sizeshape def endshape(self, event): self.dragging = False # end endshape def doneselections(self): print "Done" self.mycanvas.postscript(file="simpledrawout.eps") sys.exit # end doneselections Has a menu to select the Shape of either an oval or rectangle. The cursor changes accordingly, and a postscript file is written when the done button is clicked. Add a line shape to the drawing program. startshape: shape = circle x = 125 y = 60 Shape selected: top_left_corner startshape: shape = top_left_corner x = 225 y = 149 Done Lecture 22 Page 7

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

CS2021 Week #6. Tkinter structure. GUI Programming using Tkinter CS2021 Week #6 GUI Programming using Tkinter Tkinter structure Requires integra>on with Tk a GUI library Python program makes widgets and registers func>ons to handle widget events Program consist of theses

More information

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

Programming Training. This Week: Tkinter for GUI Interfaces. Some examples Programming Training This Week: Tkinter for GUI Interfaces Some examples Tkinter Overview Set of widgets designed by John K. Ousterhout, 1987 Tkinter == Tool Kit Interface Mean to be driven by Tcl (Toolkit

More information

CS 112: Intro to Comp Prog

CS 112: Intro to Comp Prog CS 112: Intro to Comp Prog Tkinter Layout Managers: place, pack, grid Custom Frames Widgets In-depth StringVar tkfont Upcoming Tk To use Tkinter Widgets (components: buttons, labels, etc). You must import

More information

Selected GUI elements:

Selected GUI elements: Selected GUI elements: Element tkinter Class Description Frame Frame Holds other GUI elements Label Label Displays uneditable text or icons Button Button Performs an action when the user activates it Text

More information

Tkinter: Input and Output Bindings. Marquette University

Tkinter: Input and Output Bindings. Marquette University Tkinter: Input and Output Bindings Marquette University Tkinter Variables Tkinter contains a useful mechanism to connect widgets to variables This allows us to have variables change when widgets do and

More information

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

Lecture 3 - Overview. More about functions Operators Very briefly about naming conventions Graphical user interfaces (GUIs) Lecture 3 - Overview More about functions Operators Very briefly about naming conventions Graphical user interfaces (GUIs) Function parameters Passed by reference, but the standard implication that the

More information

ENGR/CS 101 CS Session Lecture 15

ENGR/CS 101 CS Session Lecture 15 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

More information

Graphical User Interfaces

Graphical User Interfaces to visualize Graphical User Interfaces 1 2 to visualize MCS 507 Lecture 12 Mathematical, Statistical and Scientific Software Jan Verschelde, 19 September 2011 Graphical User Interfaces to visualize 1 2

More information

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

This text is used together with Mark Pilgrims book Dive Into Python 3 for the Arthead course Python Fundamentals. 2 About this text This text is used together with Mark Pilgrims book Dive Into Python 3 for the Arthead course Python Fundamentals. The first part is written for Python 2 and at the end there is a section

More information

""" helloio.py illustrate form IO (still procedural) works, but bad design: no main function """ from Tkinter import *

 helloio.py illustrate form IO (still procedural) works, but bad design: no main function  from Tkinter import * helloio.py illustrate form IO (still procedural) works, but bad design: no main function app = Tk() lbloutput = Label(app, text = "type your name") lbloutput.grid() txtinput = Entry(app) txtinput.grid()

More information

Teaching London Computing

Teaching London Computing 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 How the Session Works Outline

More information

Tkinter Part II: Buttons, Lambda & Dynamic Content

Tkinter Part II: Buttons, Lambda & Dynamic Content Tkinter Part II: Buttons, Lambda & Dynamic Content July 8, 2015 Brian A. Malloy Slide 1 of 11 1. We further investigate Labels and Buttons and hook Python actions to these widgets. We present lambda functions,

More information

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

Mid Unit Review. Of the four learning outcomes for this unit, we have covered the first two. 1.1 LO1 2.1 LO2 LO2 Lecture 8 Mid Unit Review Of the four learning outcomes for this unit, we have covered the first two. LO Learning outcome (LO) AC Assessment criteria for pass The learner can: LO1 Understand the principles

More information

Level 3 Computing Year 2 Lecturer: Phil Smith

Level 3 Computing Year 2 Lecturer: Phil Smith Level 3 Computing Year 2 Lecturer: Phil Smith We looked at: Debugging Previously BTEC Level 3 Year 2 Unit 16 Procedural programming Now Now we will look at: GUI applications. BTEC Level 3 Year 2 Unit 16

More information

Easy Graphical User Interfaces

Easy Graphical User Interfaces Easy Graphical User Interfaces with breezypythongui Types of User Interfaces GUI (graphical user interface) TUI (terminal-based user interface) UI Inputs Outputs Computation Terminal-Based User Interface

More information

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

Introduction to Programming Using Python Lecture 6. Dr. Zhang COSC 1437 Spring, 2018 March 01, 2018 Introduction to Programming Using Python Lecture 6 Dr. Zhang COSC 1437 Spring, 2018 March 01, 2018 Chapter 9 GUI Programming Using Tkinter Getting started with Tkinter with a simple example. Code example:

More information

Graphical User Interfaces

Graphical User Interfaces Graphical User Interfaces 1 User Interfaces GUIs in Python with Tkinter object oriented GUI programming 2 Mixing Colors specification of the GUI the widget Scale 3 Simulating a Bouncing Ball layout of

More information

CAS London CPD Day February 16

CAS London CPD Day February 16 Practical Sheet: GUI Programming This sheet is a set of exercises for introducing GUI programming in Python using Tkinter, assuming knowledge of basic Python programming. All materials are at http://www.eecs.qmul.ac.uk/~william/cas-london-2016.html

More information

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

Chapter 9 GUI Programming Using Tkinter. Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 9 GUI Programming Using Tkinter 1 Motivations Tkinter is not only a useful tool for developing GUI projects, but also a valuable pedagogical tool for learning object-oriented programming. 2 Objectives

More information

Python for Scientific Computations and Control

Python for Scientific Computations and Control Python for Scientific Computations and Control 1 Python for Scientific Computations and Control Project Report Georg Malte Kauf Python for Scientific Computations and Control 2 Contents 1 Introduction

More information

Outline. general information policies for the final exam

Outline. general information policies for the final exam Outline 1 final exam on Tuesday 5 May 2015, at 8AM, in BSB 337 general information policies for the final exam 2 some example questions strings, lists, dictionaries scope of variables in functions working

More information

Lecture 3 - Overview. Object-oriented programming and classes Operators Very briefly about naming conventions Graphical user interfaces (GUIs)

Lecture 3 - Overview. Object-oriented programming and classes Operators Very briefly about naming conventions Graphical user interfaces (GUIs) Lecture 3 - Overview Object-oriented programming and classes Operators Very briefly about naming conventions Graphical user interfaces (GUIs) Object-oriented philosophy Object = Data + Algorithm An object

More information

When to use the Grid Manager

When to use the Grid Manager 第 1 页共 5 页 2015/6/8 8:02 back next The Grid geometry manager puts the widgets in a 2-dimensional table. The master widget is split into a number of rows and columns, and each cell in the resulting table

More information

Part 3. Useful Python

Part 3. Useful Python Part 3 Useful Python Parts one and two gave you a good foundation in the Python language and a good understanding of software design. You ve built some substantial applications, and hopefully you ve built

More information

Getting Started p. 1 Obtaining Tcl/Tk p. 1 Interactive Execution p. 1 Direct Execution p. 4 Reading this Book p. 6 Requirements for Networking

Getting Started p. 1 Obtaining Tcl/Tk p. 1 Interactive Execution p. 1 Direct Execution p. 4 Reading this Book p. 6 Requirements for Networking Foreword p. xi Acknowledgments p. xiii Getting Started p. 1 Obtaining Tcl/Tk p. 1 Interactive Execution p. 1 Direct Execution p. 4 Reading this Book p. 6 Requirements for Networking Examples p. 7 Requirements

More information

huey: Internal maintenance specification

huey: Internal maintenance specification : Internal maintenance specification John W. Shipman 2013-08-29 21:30 Abstract Describes the implementation of, a graphical application for selecting colors and fonts, using the Python programming language

More information

Objects. say something to express one's disapproval of or disagreement with something.

Objects. say something to express one's disapproval of or disagreement with something. Objects say something to express one's disapproval of or disagreement with something. class Person: def init (self, name, age): self.name = name self.age = age p1 = Person("John", 36) class Person: def

More information

Noughts and Crosses. Step 1: Drawing the grid. Introduction

Noughts and Crosses. Step 1: Drawing the grid. Introduction 6 Noughts and Crosses These projects are for use inside the UK only. All Code Clubs must be registered. You can check registered clubs at www.codeclub.org.uk/. This coursework is developed in the open

More information

Question Possible Points Earned Points Graded By GUI 22 SQL 24 XML 20 Multiple Choice 14 Total Points 80

Question Possible Points Earned Points Graded By GUI 22 SQL 24 XML 20 Multiple Choice 14 Total Points 80 CS 1803 Spring 2011 Exam 3 KEY Name: Section: Grading TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking

More information

CS 2316 Exam 2 Summer 2011

CS 2316 Exam 2 Summer 2011 CS 2316 Exam 2 Summer 2011 Name : Grading TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam

More information

Outline. making colors with scale widgets entering parameter values using the variables in Scale. sliding canvas coordinates animating a random walk

Outline. making colors with scale widgets entering parameter values using the variables in Scale. sliding canvas coordinates animating a random walk Outline 1 The Widget Scale making colors with scale widgets entering parameter values using the variables in Scale 2 Building an Animation sliding canvas coordinates animating a random walk 3 Summary +

More information

PYTHON FOR KIDS A Pl ayfu l I ntrodu ctio n to Prog r am m i ng J a s o n R. B r i g g s

PYTHON FOR KIDS A Pl ayfu l I ntrodu ctio n to Prog r am m i ng J a s o n R. B r i g g s PYTHON FO R K I D S A P l ay f u l I n t r o d u c t i o n to P r o g r a m m i n g Jason R. Briggs Index Symbols and Numbers + (addition operator), 17 \ (backslash) to separate lines of code, 235 in strings,

More information

CMSC201 Computer Science I for Majors

CMSC201 Computer Science I for Majors CMSC201 Computer Science I for Majors Lecture 25 Classes All materials copyright UMBC and Dr. Katherine Gibson unless otherwise noted Run time Last Class We Covered Run time of different algorithms Selection,

More information

CS 2316 Exam 3 Fall 2011

CS 2316 Exam 3 Fall 2011 CS 2316 Exam 3 Fall 2011 Name : 1. (2 points) Grading TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking

More information

Review for Second Midterm Exam

Review for Second Midterm Exam Review for Second Midterm Exam 1 Policies & Material 2 Questions modular design working with files object-oriented programming testing, exceptions, complexity GUI design and implementation MCS 260 Lecture

More information

Learning outcomes. COMPSCI 101 Principles of Programming. Drawing 2D shapes using Characters. Printing a Row of characters

Learning outcomes. COMPSCI 101 Principles of Programming. Drawing 2D shapes using Characters. Printing a Row of characters Learning outcomes At the end of this lecture, students should be able to draw 2D shapes using characters draw 2D shapes on a Canvas COMPSCI 101 Principles of Programming Lecture 25 - Using the Canvas widget

More information

predator-prey simulations

predator-prey simulations predator-prey simulations 1 Hopping Frogs an object oriented model of a frog animating frogs with threads 2 Frogs on Canvas a GUI for hopping frogs stopping and restarting threads 3 Flying Birds an object

More information

CS 2316 Individual Homework 5 Joint Probability Out of 100 points

CS 2316 Individual Homework 5 Joint Probability Out of 100 points CS 2316 Individual Homework 5 Joint Probability Out of 100 points Files to submit: 1. HW5.py This is an INDIVIDUAL Assignment: Collaboration at a reasonable level will not result in substantially similar

More information

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

Graphical User Interfaces with Perl/Tk. Event Driven Programming. Structure of an Event-Driven Program. An introduction Graphical User Interfaces with Perl/Tk An introduction Event Driven Programming In functional programming, what happens when is determined (almost) entirely by the programmer. The user generally has a

More information

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

User Interfaces. getting arguments of the command line a command line interface to store points fitting points with polyfit of numpy User Interfaces 1 Command Line Interfaces getting arguments of the command line a command line interface to store points fitting points with polyfit of numpy 2 Encapsulation by Object Oriented Programming

More information

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

Application Note: Creating a Python Graphical User Interface. Matthew Roach March 31 st, 2014 Application Note: Creating a Python Graphical User Interface Matthew Roach March 31 st, 2014 Abstract: This document contains 2 portions. First, it provides an introduction into phase and the use of phase

More information

Object Oriented Programming

Object Oriented Programming Classes and Objects Object Oriented Programming Represent self-contained things using classes. A class consists of: Data (stored in variables) Operations on that data (written as functions) Represent individual

More information

PTN-202: Advanced Python Programming Course Description. Course Outline

PTN-202: Advanced Python Programming Course Description. Course Outline PTN-202: Advanced Python Programming Course Description This 4-day course picks up where Python I leaves off, covering some topics in more detail, and adding many new ones, with a focus on enterprise development.

More information

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

This homework has an opportunity for substantial extra credit, which is described at the end of this document. CS 2316 Pair Homework Box Packer Due: Tuesday, June 17th, before 11:55 PM Out of 100 points Files to submit: 1. boxpacker.py For Help: - TA Helpdesk Schedule posted on class website. - Email TA's or use

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Graphical User Interfaces Robert Rand University of Pennsylvania November 19, 2015 Robert Rand (University of Pennsylvania) CIS 192 November 19, 2015 1 / 20 Outline 1 Graphical

More information

Your (printed!) Name: CS 1803 Exam 2. Grading TA / Section: Monday, Oct 25th, 2010

Your (printed!) Name: CS 1803 Exam 2. Grading TA / Section: Monday, Oct 25th, 2010 Your (printed!) Name: CS 1803 Exam 2 Grading TA / Section: Monday, Oct 25th, 2010 INTEGRITY: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate

More information

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created. + Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create

More information

Table of Contents. Preface... xxi

Table of Contents. Preface... xxi Table of Contents Preface... xxi Chapter 1: Introduction to Python... 1 Python... 2 Features of Python... 3 Execution of a Python Program... 7 Viewing the Byte Code... 9 Flavors of Python... 10 Python

More information

Syllabus- Java + Android. Java Fundamentals

Syllabus- Java + Android. Java Fundamentals Introducing the Java Technology Syllabus- Java + Android Java Fundamentals Key features of the technology and the advantages of using Java Using an Integrated Development Environment (IDE) Introducing

More information

UNIT 10A Visualizing Data: Graphics in Python. Drawing using Python. We will be using Python's interface to Tcl/Tk, a cross-plaoorm graphics library.

UNIT 10A Visualizing Data: Graphics in Python. Drawing using Python. We will be using Python's interface to Tcl/Tk, a cross-plaoorm graphics library. UNIT 10A Visualizing Data: Graphics in Python 1 Drawing using Python We will be using Python's interface to Tcl/Tk, a cross-plaoorm graphics library. To use this, you should be logged in directly into

More information

CS 112 Project Assignment: Visual Password

CS 112 Project Assignment: Visual Password CS 112 Project Assignment: Visual Password Instructor: Dan Fleck Overview In this project you will use Python to implement a visual password system. In the industry today there is ongoing research about

More information

CS 2316 Exam 3 Summer 2014

CS 2316 Exam 3 Summer 2014 CS 2316 Exam 3 Summer 2014 Name : Grading TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam

More information

CS 2316 Exam 3 Fall 2012

CS 2316 Exam 3 Fall 2012 CS 2316 Exam 3 Fall 2012 Name : Section TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam in

More information

MITOCW watch?v=flgjisf3l78

MITOCW watch?v=flgjisf3l78 MITOCW watch?v=flgjisf3l78 The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To

More information

Review 2. Classes and Subclasses

Review 2. Classes and Subclasses Review 2 Classes and Subclasses Class Definition class (): """Class specification""" class variables (format: Class.variable) initializer ( init ) special method definitions

More information

Python GUI Programming (Tkinter)

Python GUI Programming (Tkinter) Python GUI Programming (Tkinter) Python provides various options for developing graphical user interfaces (GUIs). Most important are listed below: 1. Tkinter: Tkinter is the Python interface to the Tk

More information

Outline. Outline. 1 Chapter 2: Data Abstraction

Outline. Outline. 1 Chapter 2: Data Abstraction Outline Outline 1 Chapter 2: Data Abstraction From Data Type to ADT Values A value is a unit of information used in a program. It can be associated with a constant or variable (a name) by an assignment

More information

User Interfaces. MCS 507 Lecture 11 Mathematical, Statistical and Scientific Software Jan Verschelde, 16 September Command Line Interfaces

User Interfaces. MCS 507 Lecture 11 Mathematical, Statistical and Scientific Software Jan Verschelde, 16 September Command Line Interfaces User 1 2 MCS 507 Lecture 11 Mathematical, Statistical and Scientific Software Jan Verschelde, 16 September 2011 User 1 2 command line interfaces Many programs run without dialogue with user, as $ executable

More information

First Python examples

First Python examples PONG written in First Python examples print hello > hello x = 42 print x > 42 x = 41+1 print x try also * / x = input() print x < salut > salut # This is a comment 3 * Cha Official Python page: http://www.python.org/

More information

Clip Art and Graphics. Inserting Clip Art. Inserting Other Graphics. Creating Your Own Shapes. Formatting the Shape

Clip Art and Graphics. Inserting Clip Art. Inserting Other Graphics. Creating Your Own Shapes. Formatting the Shape 1 of 1 Clip Art and Graphics Inserting Clip Art Click where you want the picture to go (you can change its position later.) From the Insert tab, find the Illustrations Area and click on the Clip Art button

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming User Interfaces (Graphical and Text) Eric Kutschera University of Pennsylvania March 20, 2015 Eric Kutschera (University of Pennsylvania) CIS 192 March 20, 2015 1 / 23 Final Project

More information

Refreshing last time

Refreshing last time Refreshing last time The Big Idea A hash table is an array of buckets To store something in table: Hash key, then put value in bucket To look up Hash key, go to bucket and find value Empty An empty hash

More information

Introduction To Python

Introduction To Python Introduction To Python Week 8: Program Dev: Graphical Game of Life Dr. Jim Lupo Asst Dir Computational Enablement LSU Center for Computation & Technology 16 Jul 2015, Page 1 of 27 Intro To Tkinter Tcl/Tk

More information

A GUI for DFT and Orthogonal DWT in Tkinter

A GUI for DFT and Orthogonal DWT in Tkinter A GUI for DFT and Orthogonal DWT in Tkinter Tariq Javid Ali, Pervez Akhtar, Muhammad Faris Hamdard Institute of Engineering & Technology Hamdard University Karachi-74600, Pakistan Email: {tariq.javid pervez.akhtar

More information

An introduction to writing plugins for Sigil

An introduction to writing plugins for Sigil Introduction When I scan books or articles that are no longer published into a PDF document and then convert them to an epub a range of formatting errors arise in the epub file. Over time, I wrote a range

More information

Python Scripting for Computational Science

Python Scripting for Computational Science Hans Petter Langtangen Python Scripting for Computational Science Third Edition With 62 Figures 43 Springer Table of Contents 1 Introduction... 1 1.1 Scripting versus Traditional Programming... 1 1.1.1

More information

GUI Output. Adapted from slides by Michelle Strout with some slides from Rick Mercer. CSc 210

GUI Output. Adapted from slides by Michelle Strout with some slides from Rick Mercer. CSc 210 GUI Output Adapted from slides by Michelle Strout with some slides from Rick Mercer CSc 210 GUI (Graphical User Interface) We all use GUI s every day Text interfaces great for testing and debugging Infants

More information

Al al-bayt University Prince Hussein Bin Abdullah College for Information Technology Computer Science Department

Al al-bayt University Prince Hussein Bin Abdullah College for Information Technology Computer Science Department Al al-bayt University Prince Hussein Bin Abdullah College for Information Technology Computer Science Department 0901212 Python Programming 1 st Semester 2014/2015 Course Catalog This course introduces

More information

CS 2316 Exam 1 Practice ANSWER KEY

CS 2316 Exam 1 Practice ANSWER KEY CS 2316 Exam 1 Practice ANSWER KEY Signing signifies you are aware of and in accordance with the Academic Honor Code of Georgia Tech. Calculators and cell phones are NOT allowed. This is a Python programming

More information

Java Programming Lecture 6

Java Programming Lecture 6 Java Programming Lecture 6 Alice E. Fischer Feb 15, 2013 Java Programming - L6... 1/32 Dialog Boxes Class Derivation The First Swing Programs: Snow and Moving The Second Swing Program: Smile Swing Components

More information

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

Tcl/Tk lecture. What is the Wish Interpreter? CIS 410/510 User Interface Programming Tcl/Tk lecture CIS 410/510 User Interface Programming Tool Command Language TCL Scripting language for developing & using GUIs Allows generic programming variables, loops, procedures Embeddable into an

More information

How to create a prototype

How to create a prototype Adobe Fireworks Guide How to create a prototype In this guide, you learn how to use Fireworks to combine a design comp and a wireframe to create an interactive prototype for a widget. A prototype is a

More information

2.6 Graphics SIMPLE DRAWINGS 9/9/16 74

2.6 Graphics SIMPLE DRAWINGS 9/9/16 74 2.6 Graphics SIMPLE DRAWINGS 9/9/16 74 Drawing Simple Graphics To help you create simple drawings, we have included a graphics module with the book that is a simplified version of Python s more complex

More information

Contents. Table of Contents. Table of Contents... iii Preface... xvii. Getting Started iii

Contents. Table of Contents. Table of Contents... iii Preface... xvii. Getting Started iii Contents Discovering the Possibilities... iii Preface... xvii Preface to the First Edition xvii Preface to the Second Edition xviii Getting Started... 1 Chapter Overview 1 Philosophy Behind this Book 1

More information

Python Scripting for Computational Science

Python Scripting for Computational Science Hans Petter Langtangen Python Scripting for Computational Science Third Edition With 62 Figures Sprin ger Table of Contents 1 Introduction 1 1.1 Scripting versus Traditional Programming 1 1.1.1 Why Scripting

More information

Thinking in Tkinter. Thinking in Tkinter. by Stephen Ferg ferg.org) revised:

Thinking in Tkinter. Thinking in Tkinter. by Stephen Ferg ferg.org) revised: 1 of 53 Thinking in Tkinter by Stephen Ferg (steve@ ferg.org) revised: 2005-07-17 This file contains the source code for all of the files in the Thinking in Tkinter series. If you print this file with

More information

Word 3 Microsoft Word 2013

Word 3 Microsoft Word 2013 Word 3 Microsoft Word 2013 Mercer County Library System Brian M. Hughes, County Executive Action Technique 1. Insert a Text Box 1. Click the Insert tab on the Ribbon. 2. Then click on Text Box in the Text

More information

GUI Components: Part 1

GUI Components: Part 1 1 2 11 GUI Components: Part 1 Do you think I can listen all day to such stuff? Lewis Carroll Even a minor event in the life of a child is an event of that child s world and thus a world event. Gaston Bachelard

More information

Asynchronous Programming

Asynchronous Programming Asynchronous Programming Turn-in Instructions A main file, called gui.py See previous slides for how to make it main I ll run it from the command line Put in a ZIP file, along with any additional needed

More information

Technology Assignment: Scatter Plots

Technology Assignment: Scatter Plots The goal of this assignment is to create a scatter plot of a set of data. You could do this with any two columns of data, but for demonstration purposes we ll work with the data in the table below. You

More information

CS378 -Mobile Computing. User Interface Basics

CS378 -Mobile Computing. User Interface Basics CS378 -Mobile Computing User Interface Basics User Interface Elements View Control ViewGroup Layout Widget (Compound Control) Many pre built Views Button, CheckBox, RadioButton TextView, EditText, ListView

More information

Chapter 0 : MVC review / Threading & Concurrency. CSCI 251 Android App Development

Chapter 0 : MVC review / Threading & Concurrency. CSCI 251 Android App Development Chapter 0 : MVC review / Threading & Concurrency CSCI 251 Android App Development Part I: Model / View / Controller Review (courtesy of Prof. Lambert) TUI vs GUI Text-based I/O Sequential process Direct

More information

A Comprehensive Introduction to Python Programming and GUI Design Using Tkinter. Bruno Dufour. McGill Univeristy SOCS

A Comprehensive Introduction to Python Programming and GUI Design Using Tkinter. Bruno Dufour. McGill Univeristy SOCS A Comprehensive Introduction to Python Programming and GUI Design Using Tkinter Bruno Dufour McGill Univeristy SOCS Contents 1 Overview of the Python Language 2 1.1 Main Features..............................

More information

Microsoft Word 2007 on Windows

Microsoft Word 2007 on Windows 1 Microsoft Word 2007 on Windows Word is a very popular text formatting and editing program. It is the standard for writing papers and other documents. This tutorial and quick start guide will help you

More information

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science

PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science PLEASE HAND IN UNIVERSITY OF TORONTO Faculty of Arts and Science AUGUST EXAMINATIONS CSC 108H1Y Instructor: Daniel Zingaro Duration three hours PLEASE HAND IN Examination Aids: None. Student Number: Last

More information

OCTAVO An Object Oriented GUI Framework

OCTAVO An Object Oriented GUI Framework OCTAVO An Object Oriented GUI Framework Federico de Ceballos Universidad de Cantabria federico.ceballos@unican.es November, 2004 Abstract This paper presents a framework for building Window applications

More information

Sliders. If we start this script, we get a window with a vertical and a horizontal slider:

Sliders. If we start this script, we get a window with a vertical and a horizontal slider: Sliders Introduction A slider is a Tkinter object with which a user can set a value by moving an indicator. Sliders can be vertically or horizontally arranged. A slider is created with the Scale method().

More information

Java Programming Layout

Java Programming Layout Java Programming Layout Alice E. Fischer Feb 22, 2013 Java Programming - Layout... 1/14 Application-Stage-Scene-Pane Basic GUI Construction Java Programming - Layout... 2/14 Application-Stage-Scene Application

More information

CS 2316 Homework 9a GT Room Reservation Login

CS 2316 Homework 9a GT Room Reservation Login CS 2316 Homework 9a GT Room Reservation Login Due: Wednesday November 5th Out of 100 points Files to submit: 1. HW9.py This is an INDIVIDUAL assignment! Collaboration at a reasonable level will not result

More information

How to receive codes from a wireless remote on your Raspberry Pi.

How to receive codes from a wireless remote on your Raspberry Pi. How to receive codes from a wireless remote on your Raspberry Pi. This guide will show you how to receive signals from most remote control gadgets that use the 433MHz (Europe) and 315MHz (North America)

More information

[CHAPTER] 1 INTRODUCTION 1

[CHAPTER] 1 INTRODUCTION 1 FM_TOC C7817 47493 1/28/11 9:29 AM Page iii Table of Contents [CHAPTER] 1 INTRODUCTION 1 1.1 Two Fundamental Ideas of Computer Science: Algorithms and Information Processing...2 1.1.1 Algorithms...2 1.1.2

More information

BASIC GRAPHICAL USER INTERFACE (GUI) OBJECTS

BASIC GRAPHICAL USER INTERFACE (GUI) OBJECTS BASIC GRAPHICAL USER INTERFACE (GUI) OBJECTS Background or Desktop Image Picture object only that can be changed to suit the user's preferences. This object is designed to help the user not become bored

More information

Object-oriented programming in Java (2)

Object-oriented programming in Java (2) Programming Languages Week 13 Object-oriented programming in Java (2) College of Information Science and Engineering Ritsumeikan University plan last week intro to Java advantages and disadvantages language

More information

Model-view-controller View hierarchy Observer

Model-view-controller View hierarchy Observer -view-controller hierarchy Fall 2004 6831 UI Design and Implementation 1 Fall 2004 6831 UI Design and Implementation 2!"# Separation of responsibilities : application state Maintains application state

More information

Lecture 21. Programming with Subclasses

Lecture 21. Programming with Subclasses Lecture 21 Programming with Subclasses Announcements for Today Reading Today: See reading online Tuesday: Chapter 7 Prelim, Nov 9 th 7:30-9:00 Material up to Today Review has been posted Recursion + Loops

More information

Fundamentals of Programming. Functions Redux. Event-based Programming. File and Web IO. November 4th, 2014

Fundamentals of Programming. Functions Redux. Event-based Programming. File and Web IO. November 4th, 2014 15-112 Fundamentals of Programming Functions Redux. Event-based Programming. File and Web IO. November 4th, 2014 Today Briefly show file and web IO. Revisit functions. Learn a bit more about them. Event-based

More information

Unit 21 - Creating a Navigation Bar in Macromedia Fireworks

Unit 21 - Creating a Navigation Bar in Macromedia Fireworks Unit 21 - Creating a Navigation Bar in Macromedia Fireworks Items needed to complete the Navigation Bar: Unit 21 - House Style Unit 21 - Graphics Sketch Diagrams Document ------------------------------------------------------------------------------------------------

More information

Package widgettools. R topics documented: May 7, Title Creates an interactive tcltk widget Version Date Author Jianhua Zhang

Package widgettools. R topics documented: May 7, Title Creates an interactive tcltk widget Version Date Author Jianhua Zhang Title Creates an interactive tcltk widget Version 1.58.0 Date 2008-10-28 Author Jianhua Zhang Package widgettools May 7, 2018 Description This packages contains tools to support the construction of tcltk

More information

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Application Components Hold the content of a message (E.g. convey a request for an activity to present an image) Lecture 2: Android Programming

More information

OBJECT ORIENTED PROGRAMMING 7

OBJECT ORIENTED PROGRAMMING 7 OBJECT ORIENTED PROGRAMMING 7 COMPUTER SCIENCE 61A July 10, 2012 1 Overview This week you were introduced to the programming paradigm known as Object Oriented Programming. If you ve programmed in a language

More information