Creating visual interfaces in python

Slides:



Advertisements
Similar presentations
Chapter 3 – Web Design Tables & Page Layout
Advertisements

Chapter 9 Working with Tabs and Tables. Chapter Objectives Work with tabs Create and format a table Format text in a table Place graphics in a table.
Objectives Build and modify an organization chart.
Tk. Toolkit n Wish - windowing shell –touch fileName –chmod +x fileName –xedit fileName & –#!/usr/local/bin/wish n Widgets - eg Buttons, Labels, Frames.
Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
1 Microsoft Access 2002 Tutorial 9 – Automating Tasks With Macros.
Automating Tasks With Macros
Create slices and hotspots Create links in Web pages Create rollovers from slices Create basic animation Add tweening symbol instances to create animation.
PowerPoint Lesson 3 Working with Visual Elements
Creating Web Page Forms
Spreadsheet. Objectives Create a new blank workbook. Create a new blank workbook. Identify user interface elements that you can use to accomplish basic.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Lesson 6: Working with Layout and Graphics
COMPSCI 101 Principles of Programming
Microsoft PowerPoint Getting Started Guide Prepared for Towson University Dr. Jeff M. Kenton Amy Chase Martin 2007.
Lehigh University Introduction to Flash MX Sharmeen Mecklai.
IE 411/511: Visual Programming for Industrial Applications
Creating a PowerPoint Presentation
BIM211 – Visual Programming Objects, Collections, and Events 1.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
CREATING A POWERPOINT PRESENTATION. Planning a presentation Create a presentation Rearrange and delete text and slides Add animations Add transitions.
Key Applications Module Lesson 21 — Access Essentials
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
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.
Chapter Two Creating a First Project in Visual Basic.
Key Applications Module Lesson 20 — Enhancing Presentations with Multimedia Effects Computer Literacy BASICS.
Creating a poster is easier than you think.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 9 GUI Programming Using Tkinter 1.
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.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Chapter Three The UNIX Editors.
Oct 021 Outline What is a widget? Buttons Combo boxes Text components Message boxes.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Key Applications Module Lesson 14 — Working with Tables Computer Literacy BASICS.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Guide to Programming with Python
Oct 091 Example Program DemoInputValidation1.java DemoInputValidation2.java.
Chapter 3 I Need a Tour Guide (Introduction to Visual Basic 2010) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Paint Tutorial Created February 2006 Start Paint: Start>Programs>Accessories>Paint.
GUI Controls for Input Design Introduction –Most new applications being developed today include a GUI. This approach is influenced by a new trend in.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Chapter 3: I Need a Tour Guide (Introduction to Visual Basic 2012)
Excel Tutorial 8 Developing an Excel Application
Creating a Presentation
MOM! Phineas and Ferb are … Aims:
Working in the Forms Developer Environment
Topics Graphical User Interfaces Using the tkinter Module
Graphical User Interfaces (GUIs)
Chapter 21 – Graphics/Tk Outline 21.1 Introduction 21.2 GD Module: Creating Simple Shapes 21.3 GD Module: Image Manipulation 21.4 Chart Module 21.5 Introduction.
Introduction to Microsoft publisher
Working with Tabs and Tables
My Final Project: Calorie Counter
GUI Using Python.
Fundamentals of Python: From First Programs Through Data Structures
This Week: Tkinter for GUI Interfaces Some examples
Tkinter GUIs Computer Science and Software Engineering
Learning Objective LO: We’re learning to understand when it is appropriate to use particular data types.
Applications Software
Whatcha doin'? Aims: Begin to create GUI applications. Objectives:
POWER POINT WHY HAVE WE USE THIS PROGRAM? TO SHOW YOUR STUDY..
Topics Graphical User Interfaces Using the tkinter Module
Computer Literacy BASICS
Lab 08 Introduction to Spreadsheets MS Excel
Chapter 4 Enhancing the Graphical User Interface
Presentation transcript:

Creating visual interfaces in python By, Chase Fortier

What is visual python? -Visual Python is a 3D graphics module that acts in unison with the normal python programming language. -Visual python has features that can create a variety of graphs and shapes which can be manipulated and moved. -Visual Python is helpful in creating real life animations, both for playful and educational uses. -It is especially helpful in creating examples of simple laws of physics.

Creating shapes Creating a shape in visual python is quite simple. The formatting looks like: From visual import * Shape() The shape can either be 2-D or 3-D, depending on the variable called. The shape must be stored in the visual python library! The picture on the right is an example of a sphere created using visual python.

Other 3-D objects in python The above images were taken from http://vpython.org/contents/docs/primitives.html

2-d shaped in the vpython library Rectangle Circle Ellipse Line Arc Triangle Pentagon Hexagon Ngon Star Trapezoid Cross Pointlist Text Gear

Changing object attributes The object’s attributes can also be changed. Notice the differences between this sphere and the one on the first slide. In this example, the position of the center of the circle is moved to (1, 2, 0), the radius of the circle is changed to 0.5 and the color is changed to blue.

Different objects have different attributes The position of an arrow specifies its starting point rather than its center. It also has an axis attribute that determines the direction in which it points. Like the circle, the position refers to the center of the shape. The box also allows one to specify its length, width and height.

Moving the objects Without motion, the shapes and 3D objects created don’t serve too much of a purpose. BUT DON’T WORRY… visual python also allows one to set these objects into motion and create animation!

Creating moving objects One can use a loop to continuously change the motion of an object, which therefore creates movement.

Creating moving objects: running the program

Relative object motion A function can also be edited as to move two objects in relation to one another. In this example, the arrow is programmed to continue pointing at the green ball as it moves.

Relative object motion: running the program

What isn’t in visual python? Visual python allows the user to create and manipulate many interesting objects and animations, but it does not provide interactive visual interfaces for the user to enter input or control a function. This is where Tk Interface comes in!

What is tk interface? -Tk interface is Python’s Graphic User Interface (GUI) toolkit -Tk creates GUI applications with user-friendly window interfaces to help the user navigate and control a program. -The specific methods that I will be teaching are the Entry Box and Button widgets, which work to create an easier way for the user to input data into a function.

Tk widgets Button Canvas Checkbutton Entry Frame Lable Listbox Menu Menubutton Message Radiobutton Scale Scrollbar Text Toplevel

Creating a plain window Function explained Outcome of function

ADDING A BUTTON TO THE WINDOW Once the initialization function for the window has been defined, it is fairly easy to add to it to create a button widget. Store button object as a variable. Set parent window, button display text and command. In order for the button command to work, the command (printMessage) must be defined. When the button is pressed the command will print the message ‘The button was pressed!”. This function is necessary to make the button appear. The row and column define where it will be displayed within the window.

Pressing the button When the button is pressed, the command printMessage is run, which has been defined to print “The button was pressed!”

Enlarging button window The size of the window that the button is displayed on can be changed by adding height and width to the button attributes. 50 and 100 were chosen arbitrarily- these can be set to any number to change the size.

Enlarged window Notice the difference in size between the original button window and edited button window!

Object attributes In addition to size, there are many other object attributes that can be edited in Tkinter. Each object has attributes that are specific to that object. For example, one would not be able to change the font on a scrollbar, which does not have any text. Attributes in Tkinter include background color, font, border width, text color and more! Each object has default attributes that will be displayed if a change is not specified.

Adding an entry box to the window Another useful widget is the entry method. This allows the user to enter text into a text box. This sets a variable to hold the text that the user inputs. StringVar() stores a string of what the user types. Store the entry object as a variable. self.master: defines parent window Textvar=self.usertext : defines where to store user text This function makes the entry box appear and specifies where on the window it is located.

using the two together Without a button, the entry has no way of being input into the program. Combining the two widgets allows one to enter text and then push the button to signal the program that the entry is complete and should be printed. Notice that the variables entered from the text box and button have simply been entered together, but the definition of the printMessage function has changed to call the user text.

outcome After pressing the go button, the user text is printed as was called to do in the program.

conclusion Adding visual elements creates another whole set of functions and that can be created and tasks that can be performed. Visual Python allows one to use python to create animations that emulate real life situations and movement. The visual elements created in Tk interface are slightly different in that they are more for the improvement of the user experience. The various widgets allow for an interactive visual interface in which one can input text and data. Both supplement the python programming language and help to strengthen and broaden its capabilities.