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.

Slides:



Advertisements
Similar presentations
What Was I Thinking??. Key Terms 1. Control 1. Control 2. Design Mode 2. Design Mode 3. Event 3. Event 4. Form 4. Form 5. Interface 5. Interface 6. Properties.
Advertisements

Chapter 3 – Web Design Tables & Page Layout
Chapter 16 Graphical User Interfaces John Keyser’s Modifications of Slides by Bjarne Stroustrup
Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
Click here to start the game! 20 Points 30 Points 40 Points 50 Points 10 Points 20 Points 30 Points 40 Points 50 Points 30 Points 40 Points 50 Points.
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
CS 280 Data Structures Professor John Peterson. Quiz 4 Recap Consider the following array: {2, 6, 7, 3, 4, 1, 5, 9}. Draw this in tree form and then show.
ObjectDraw and Objects Early Chris Nevison Barbara Wells.
Web Page Development Identify elements of a Web Page Start Notepad
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
Introduction to Visual Basic Chulantha Kulasekere.
Creating Multimedia Student Tutorials Caroline C. Bush Grand Canyon University TEC 539 July 6, 2011.
Graphical User Interfaces A Quick Outlook. Interface Many methods to create and “interface” with the user 2 most common interface methods: – Console –
By: Zaiba Mustafa Copyright ©
Slide 1 Chapter 2 Visual Basic Interface. Slide 2 Chapter 2 Windows GUI  A GUI is a graphical user interface.  The interface is what appears on the.
XP Tutorial 7 New Perspectives on Microsoft Windows XP 1 Microsoft Windows XP Working with Graphics Tutorial 7.
Programming a GUI Hanan sedaghat pisheh. For calling GUI, we need a function with no inputs or outputs First We create a m.file m file has the same name.
COMPSCI 101 Principles of Programming
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 1B Introduction (Tutorial)
Teacher: Ms. Olifer MICROSOFT VISUAL STUDIO 2010: PROPERTIES OF WINDOWS FORM OBJECT.
Guide to Programming with Python Chapter Ten GUI Development: The Mad Lib Program.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
Chapter 2 - More Controls More controls – Text boxes - used for user input – Frames - containers to group items – check boxes - user select an option -
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Computer Science 111 Fundamentals of Programming I Model/View/Controller and Data model design.
Hello, little turtles. Hello, little turtles! There are many modules in Python that provide very powerful feature that we can use in our own program.
PYTHON GUI PROGRAMMING
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 20 Graphical User Interface (GUI)
CC111 Lec7 : Visual Basic 1 Visual Basic(1) Lecture 7.
Chapter 2 – Introduction to the Visual Studio .NET IDE
ITEC 109 Lecture 27 GUI. GUIs Review Sounds –Arrays hold sample values –Creating a keyboard –Sound effects Homework 3 –The big two –Due after break –Lab.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 9 GUI Programming Using Tkinter 1.
Creating Windows. How can we use Java to create programs that use windows (GUI applications)? How can we use Java to create programs that use windows.
How the Session Works Outline Practical on arrival Talk 1 Reflect on practical Clarify concepts Practical exercises at your own pace Talk 2: Further concepts.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 21.1 Test-Driving the Painter Application.
Writing Explorer in EZY Prolog By Serguei Penkov © 2002 EDMGROUP Australia.
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.
SEEM3460 Tutorial GUI in Java. Some Basic GUI Terms Component (Control in some languages) the basic GUI unit something visible something that user can.
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.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Introduction to Java Chapter 8 - Introduction to Java Graphics1 Chapter 8 Introduction to Java Graphics.
Graphics Programming with Python. Many choices Python offers us several library choices:  Tkinter  WxPython  PyQt  PyGTK  Jython  And others...
VB Objects & Events (Exercises) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 3, Friday 1/31/2003)
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Guide to Programming with Python
BBT 10 Visual Basic 03 Enrichment. Tip Before creating any files for your project, first create a new folder Save all of your files in the folder Pieces.
COMPSA Exam Prep Session by Paul Allison On: April 8th from 1:30-3:00 Location TBA Winter 2016CISC101 - Prof. McLeod1.
See Winter 2016CISC101 - Prof. McLeod1.
INTRO2CS Tirgul 13 – More GUI and Optimization. Today:  GUI  Packing  Events  Canvas  OptionMenu  Optimization  Traveling Sales Man  Questions.
Event Binding Make something to react when something happens to it, like pressing a key, it’s called event binding. Events: things that occur while a program.
Topics Graphical User Interfaces Using the tkinter Module
Graphical User Interfaces (GUIs)
Chapter 2 – Introduction to the Visual Studio .NET IDE
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
Tkinter Widgets CS 260 Dick Steflik.
TKinter CS-360 Dick Steflik.
Windows Tutorial 7 Managing Multimedia Files
Fundamentals of Programming I Windows, Labels, and Command Buttons
Whatcha doin'? Aims: Begin to create GUI applications. Objectives:
Let’s begin our game!.
Topics Graphical User Interfaces Using the tkinter Module
Python – Tkinter Windows Application
Presentation transcript:

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 window title”) … Code to setup your window contents … windowVar.mainloop() # runs the window, # issuing events and # callbacks to your code

Window Operation Make a frame in the window: frameVar = Frame(windowVar) frameVar.pack() Destroy/Shutdown the window: windowVar.destroy()# exits windowVar.mainloop() Schedule a call to a procedure: windowVar.after(mSec,procedureName) # schedules mainloop to call # procedureName() after a # delay of mSec milliseconds Redrawing/updating the window windowVar.update()

Widgets Button buttonVar = Button(frameVar,text=”Quit Game", \ fg="green”,command=self.newGame) # Makes a Button widget in frameVar, displaying # assigned text and using foreground color indicated # when Button is clicked, command is called Scale scaleVar = Scale(frameVar, \ orient=HORIZONTAL, \ showvalue=0,to=7,length=200, \ label="Difficulty -->”, \ command=callbackProcedure) # Makes a “slider-type” bar inside # frameVar, horizontal, numbered from 0 – 7, # gives it a text label and calls back # callBackProcedure(num) giving new value in num

Canvas Widget To make one: canvasVar = Canvas(windowVar, width=w, height=h,bg="yellow",borderwidth=0, \ highlightbackground="black", \ highlightthickness=2) # Makes a canvas in windowVar with size # w x h pixels, sets highlight and border # characteristics canvasVar.bind(" ”,mouseProc) # arrange to call mouseProc() when user # clicks left mouse button inside the canvas canvasVar.pack()

Drawing Objects in the Canvas Draw a circle: circleVar = canvasVar.create_oval(llx,lly,urx,ury, \ fill="white") # draws circle/ellipse in box (llx,lly), # (urs,ury) with fill color “fill” Draw a line: lineVar = canvasVar.create_line(x1,y1,x2,y2, \ width=15,fill="blue") # Line from (x1,y1) to (x2,y2) with # thickness of “width” and fill color “fill” Write text: textVar = canvasVar.create_text(x,y,\ text=string,anchor="w”,font="Courier 24") # Place text into canvasVar at location(x,y) # “string” is the text, set the font and # (in this example) anchor text to the “w”est

Changing a Canvas item To modify an existing item in the canvas: draw.itemconfig(item,fill=newColor) Where: draw is the Canvas object (returned by the Canvas constructor) And item is a reference to something created in the Canvas by a draw.create_???? method Any named attribute (such as “fill”) can be modified with the Canvas itemconfig method.

Net Resources for tkinter Try this as a complete reference: Here is a decent tutorial:

GUI Startup Code I would expect your startup code to look something like this: root = Tk() root.title("Connect4”) bd = Board(7, 6, root) aiPlayer = Player('o', 'Random', 5) bd.playGUI(aiPlayer) root.mainloop()