TKinter CS-360 Dick Steflik.

Slides:



Advertisements
Similar presentations
Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
Advertisements

Instruction: Use mouses left button. Use mouses left button. If mouse buttons dont work, use arrow keys of keyboard for slide show. If mouse buttons dont.
Tk. Toolkit n Wish - windowing shell –touch fileName –chmod +x fileName –xedit fileName & –#!/usr/local/bin/wish n Widgets - eg Buttons, Labels, Frames.
Mouse Tutorial for Win XP In this tutorial you will learn to: Move the mouse Click and double click Make selections Manage windows Use menus Click the.
Tk Widgets This material is best on several sources –Slides by Dr. Ernest J. Friedman-Hill –various Tcl/Tk books.
Windows Basics: The Mouse. The Mouse Before you can explore the Desktop and Taskbar, you must know how to use your mouse. Your mouse is a pointing device.
Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
CS7026 jQuery Events. What are Events?  jQuery is tailor-made to respond to events in an HTML page.  Events are actions that can be detected by your.
19-Jun-15 Ruby GUI Toolkits. Available GUI toolkits The Tk GUI toolkit is a part of the Ruby distribution Tk is badly documented, does not support native.
CS0004: Introduction to Programming Events. Review  Event Procedure  A set of instructions to be executed when a certain event happens.  Many event-driven.
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.
Computer Science 111 Fundamentals of Programming I User Interfaces Introduction to GUI programming.
XP Tutorial 5 Buttons, Behaviors, and Sounds. XP New Perspectives on Macromedia Flash MX Buttons Interactive means that the user has some level.
WEEK Introduction to GUI programming. Introduction Each data type can represent a certain set of values, and each had a set of associated operations.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
The University of Texas – Pan American
Guide to Programming with Python Chapter Ten GUI Development: The Mad Lib Program.
PYTHON GUI PROGRAMMING
CS350 – Windows Programming Formerly and more properly named: Event Driven Programming Dr. Randy Ribler.
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.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 9 GUI Programming Using Tkinter 1.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Tkinter Basics. Initial Stuff To get the package: from tkinter import * To make a window, give it a title and operate it: windowVar = Tk() windowVar.title(“your.
Graphics Programming with Python. Many choices Python offers us several library choices:  Tkinter  WxPython  PyQt  PyGTK  Jython  And others...
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Events Programming with Alice and Java First Edition by John Lewis.
INTRO2CS Tirgul 12 – Networks and GUI. Today:  Network and Communication  GUI - tkinter.
Guide to Programming with Python
Application software- programs that let you do things What are some computer programs that you or your parents use on the computer?
1 Excel Lesson 1 Microsoft Excel Basics Microsoft Office 2010 Introductory Pasewark & Pasewark.
Implement User Input Windows Development Fundamentals LESSON 2.4A.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
CS2021- Week 7 Tkinter Tour. Core tkinter concepts Widget Classes: Label Button Frame Toplevel, Tk Message, Entry, Checkbutton, Radiobutton Menubutton,
INTRO2CS Tirgul 13 – More GUI and Optimization. Today:  GUI  Packing  Events  Canvas  OptionMenu  Optimization  Traveling Sales Man  Questions.
T. Meyer ROD Software Workshop July 2002 Scripting and Interpreted Languages Tom Meyer Iowa State University
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()
THE MOUSE Left Click THE MOUSE Right Click.
Events and Event Handling
CS345 – Event-driven Programming
Scratch for Interactivity
Steps to Build Frame Window Recipe Application
Topics Graphical User Interfaces Using the tkinter Module
Event Loops and GUI Intro2CS – weeks
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.
Event Driven Programming Dick Steflik
The User Interface Lecture 2 Mon, Aug 27, 2007.
CISC101 Reminders Grading of Quiz 4 underway.
Ruby GUI Toolkits 21-Sep-18.
GUI Using Python.
Fundamentals of Python: From First Programs Through Data Structures
Tkinter Python User Interface
Event Driven Programming
This Week: Tkinter for GUI Interfaces Some examples
Tkinter GUIs Computer Science and Software Engineering
Tkinter Widgets CS 260 Dick Steflik.
Fundamentals of Programming I Windows, Labels, and Command Buttons
Computer Science 111 Fundamentals of Programming I User Interfaces
Moving the Insertion Point
Topics Graphical User Interfaces Using the tkinter Module
Event Driven Programming Anatomy – Handle
Constructors, GUI’s(Using Swing) and ActionListner
Lesson 2: Selecting Cells, Rows, and Columns
Tkinter Button import tkinter as tk root = tk.Tk()
Tkinter Label תווית The Label widget is a standard Tkinter widget used to display a text or image on the screen. import tkinter as tk root = tk.Tk() lb.
Tkinter Event. אירוע. Events and Bindings widget.bind(event, handler)
CS7026 jQuery Events.
Skills Sheet: ‘Using the 3D viewer’
Presentation transcript:

TKinter CS-360 Dick Steflik

Hello World from Tkinter import Label # get a widget widget = Label(None, text=‘Hello World’) # make a Label widget.pack() # arrange it in its parent widget.mainloop() # start the event loop Load a widget class from Tkinter Make an instance of it (repeat 1 and 2 as needed) Arrange the widget in its parent widget Enter the event loop

Geometry Managers Geometry managers allow us to organize widgets inside of a container Pack geometry manager http://effbot.org/tkinterbook/pack.htm Grid geometry manager http://effbot.org/tkinterbook/grid.htm Place geometry manager http://effbot.org/tkinterbook/place.htm

Tkinter Events and Binding <Button-1> - left mouse button <Button-2> - middle mouse button (on 3 button mouse) <Button-3> - rightmost mouse button <B1-Motion> - mouse moved with left button depressed <ButtonRelease-1> - left button released <Double-Button-1> - double click on button 1 <Enter> - mouse pointer entered widget <Leave> - mouse pointer left the widget <FocusIn> - Keyboard focus moved to a widget <FocusOut> - Keyboard focus moved to another widget <Return> - Enter key depressed <Key> - A key was depressed <Shift-Up> - Up arrow while holding Shift key <Configure> - widget changed size or location http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm

Event Handling Event sources (widgets) can specify their handlers command handlers callbacks

Command Handlers use the ‘command=‘ keyword followed by the command you want executed ex from Tkinter import * root = Tk() Button (root, text=‘Press Me’ , command=root.quit).pack(side=LEFT) root.mainloop()

Callbacks A callback is the name of the function that is to be run in response of an event Callbacks can be defined as a free standing function in our program or as a class member. ex. from Tkinter import * def quit(): print ‘Hello, getting out of here’ import sys; sys.exit() widget = Button(None, text=‘Press me to quit’ , command=quit) widget.pack() widget.mainloop()

Bound Method Callbacks Lets make a Hello Class and use it: from Tkinter import * class HelloClass; # create the window in the class constructor def __init__(self): widget = Button(None, text=‘Press Me to quit’, command=self.quit) widget.pack() def quit(self): print ‘leaving now’ import sys ; sys.exit() HelloClass() # create a HelloClass object mainloop()

Binding Events from Tkinter import * def hello(event): print ‘Double click to exit’ def quit(event); print ‘caught a double click, leaving’ import sys ; sys.exit() widget = Button(None, text=‘Hello Event World’) widget.pack() widget.bind(‘<Button-1>’ , hello) widget.bind(‘<Double-1>’ , quit) widget.mainloop()