Lesson 3 - The Entry Box.. Last week We produced a Tkinter window with a label and a button Now we are going to create a new program that creates a Button.

Slides:



Advertisements
Similar presentations
EasyGUI “Probably the Easiest GUI in the world”. Assumptions (Teachers’ Notes) This resources sets out an introduction to using easyGUI and Python
Advertisements

Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
How to maketh a Shakespearean fig generator in python
Text Box controls are used when users are required to type some input (during program execution), or output is displayed on the form (known as the user-
Microsoft Access 2007 Microsoft Access 2007 Introduction to Database Programs.
PYTHON: LESSON 1 Catherine and Annie. WHAT IS PYTHON ANYWAY?  Python is a programming language.  But what’s a programming language?  It’s a language.
JavaScript Events and Event Handlers 1 An event is an action that occurs within a Web browser or Web document. An event handler is a statement that tells.
An Introduction to Textual Programming
Using Dreamweaver. Slide 1 Dreamweaver has 2 screens that do different things The Document window where you create your WebPages The Site window where.
Getting started (For the absolute beginner: download and install python) Task 1: Creating 3 widgets: a label, text entry and a button (and ‘PACK’) Task.
MAIL MERGE Designing Documents with. Terms Mail Merge: A process that inserts variable information into a standardized document to produce a personalized.
Python Programming Introduction to programming using python.
Peter Andreae Python for Level 3 CS4HS see website: ecs.vuw.ac.nz/Main/PythonForSchools.
Python File Handling. In all the programs you have made so far when program is closed all the data is lost, but what if you want to keep the data to use.
1 Lab of COMP 319 Lab tutor : Yao Zhang, Shenghua ZHONG Lab 4: Nov 30, 2011 Final Project: Image Compression.
Tutorial 11 Five windows included in the Visual Basic Startup Screen Main Form Toolbox Project Explorer (Project) Properties.
SYSTEMSDESIGNANALYSIS 1 OO: Chapter 9 Visual Basic: Building Components Jerry Post Copyright © 1999.
PC204 Lecture 9 Conrad Huang Genentech Hall, N453A x
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
PYTHON GUI PROGRAMMING
Make a blank window This is a starter activity and should take 5 minutes [ slide 1 ] 1.Log in to your computer 2.Open IDLE 3.In script mode create a file.
UNIT 7 Describing how an item functions [2] (infinitive with or without ‘to’)
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 20 Graphical User Interface (GUI)
Controls. Adding Controls to Form -You can pick controls from the toolbox. -To add the controls from Toolbox to the Form You have be in design view. -To.
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Learning Targets:  Develop code blocks that use arithmetic operations  Develop programs that use subtotals and final totals 1.
CISB434: VisiRule 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.
Objects and Classes Procedural Programming A series of functions performing specific tasks Data items are passed from one function to another by arguments.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Excel Macros 1 Macros or, How to Automate Part of Your Spreadsheet or Worksheet.
Creating visual interfaces in python
SUPPLIER MODULE User’s Guide. Step 1. Click Files Step 2. Click Supplier.
Guide to Programming with Python
Python Lesson 1 1. Starter Create the following Excel spreadsheet and complete the calculations using formulae: 2 Add A1 and B1 A2 minus B2 A3 times B3.
Introduction to Programming Python Lab 5: Strings and Output 05 February PythonLab5 lecture slides.ppt Ping Brennan
Calculator Program Explained by Arafa Hamed. First Designing The Interface Ask yourself how many places are there that will be used to input numbers?
Creating and Using Modules Sec 9-6 Web Design. Objectives The student will: Know how to create and save a module in Python Know how to include your modules.
See Winter 2016CISC101 - Prof. McLeod1.
DEPARTMENT MODULE User’s Guide. Step 1. Click Files Step 2. Click Department.
Introducing Python 3 Introduction to Python. Introduction to Python L1 Introducing Python 3 Learning Objectives Know what Python is and some of the applications.
Using TKINTER For Better Graphic Tkinter module offers more functions: Button Widget: from tkinter import * tk =Tk() btn=Button(tk, text=‘Click me’) btn.pack()
Multimedia Summer Camp
Introduction to Programming
Bbc microbit Lesson 3 – Temperature hot medium.
Introduction to Programming
Topics Graphical User Interfaces Using the tkinter Module
My Final Project: Calorie Counter
CISC101 Reminders Grading of Quiz 4 underway.
GUI Using Python.
Tkinter Python User Interface
Tkinter GUIs Computer Science and Software Engineering
Today’s lesson – Python next steps
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Programming In Lesson 3.
Chapter 1 Minitab Recipe Card
Using AMOS With SPSS Files.
Introduction to Programming
Whatcha doin'? Aims: Begin to create GUI applications. Objectives:
I dragged over the label tool (A icon) and put it on the form.
Topics Graphical User Interfaces Using the tkinter Module
Lesson 3.1 Variables.
Python Lesson’S 1 & 2 Mr. Kalmes.
Using Script Files and Managing Data
Introduction to Python
Introduction to Programming
Tkinter User Input Form
Python Creating a calculator.
Presentation transcript:

Lesson 3 - The Entry Box.

Last week We produced a Tkinter window with a label and a button Now we are going to create a new program that creates a Button and an Entry Box. The user writes in the box. When the button is pressed that input is made into a new label To do this we must write or define a function And then call (execute) that function when the button is pressed

The New Program Open Python Then go File > New window In the new untitled window Go File > Save As Save the file tkentry.py in your area

import sys from tkinter import * mGui = Tk() mGui.geometry (‘400 x400’) mGui.title(‘My Window’) mlabel=Label(text=‘Testwood School’).pack() mbutton=Button(mGui,text=“OK”).pack() mGui.mainloop()

First lets create the Entry Box – underneath the label Testwood School import sys from tkinter import* mGui = Tk() ment = Stringvar() mGui.geometry (‘400 x400’) mGui.title(‘My Window’) mlabel=Label(text=‘Testwood School’).pack() mEntry = Entry(mGui,textvariable = ment).pack() mbutton=Button(mGui,text=“OK”).pack() mGui.mainloop() # ment is a variable which stores what is typed in the entry box

Now lets write our function. import sys from tkinter import* def myinput(): mtext = ment.get() mlabel2= Label(mGui,text=mtext).pack() mGui = Tk() mGui.geometry (‘400 x400’) mGui.title(‘My Window’) mlabel=Label(text=‘Testwood School’).pack() mEntry = Entry(mGui,textvariable = ment).pack() mbutton=Button(mGui,text=“OK”).pack() mGui.mainloop() # ment is a variable which stores what is typed in the entry box

And finally lets get the button to call (execute) the function. import sys from tkinter import* def myinput(): mtext = ment.get() mlabel2= Label(mGui,text=mtext).pack() mGui = Tk() mGui.geometry (‘400 x400’) mGui.title(‘My Window’) mlabel=Label(text=‘Testwood School’).pack() mEntry = Entry(mGui,textvariable = ment).pack() mbutton=Button(mGui,text=“OK”,command=myinput).pack() mGui.mainloop() # ment is a variable which stores what is typed in the entry box

Extension Task – Try this code what’s changed and why? import sys from tkinter import* def mentry(): mtext=ment.get() ytext=yent.get() mlabel2=Label(mGui,text=mtext+ytext).pack() mGui =Tk() ment=IntVar() yent=IntVar() mGui.geometry("450x ") mGui.title ("Testwood Calculator") mlabel=Label(mGui,text="Testwood Calculator").pack() mEntry=Entry(mGui,textvariable=ment,width=5).pack() yEntry=Entry(mGui,textvariable=yent).pack() mbutton=Button(mGui,text="OK",command=mentry).pack() mGui.mainloop()

Next week we will create a canvas and place an image in our window.