Tk Widgets This material is best on several sources –Slides by Dr. Ernest J. Friedman-Hill –various Tcl/Tk books.

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.
MS® PowerPoint.
Tk. Toolkit n Wish - windowing shell –touch fileName –chmod +x fileName –xedit fileName & –#!/usr/local/bin/wish n Widgets - eg Buttons, Labels, Frames.
Step-by-Step: Add a Graphical Hyperlink USE the Special Events Final presentation that is still open from the previous exercise. 1.Go to slide 4, and click.
Lesson 12 Getting Started with Excel Essentials
 Use the Left and Right arrow keys or the Page Up and Page Down keys to move between the pages. You can also click on the pages to move forward.  To.
FrontPage Express By John G. Summerville Ph.D.©, RN.
1 Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software.
Building User Interfaces with Tk/Tcl Outline –Basic Structures –Widget Creation –Geometry Management –Widget Commands –Event Bindings –Interprocess Communication.
Text, Masks, and Live Effects – Lesson 41 Text, Masks, and Live Effects Lesson 4.
Introduction To Form Builder
1 Chapter 5: Introduction To Form Builder. 2 Forms  Why Do We Use Form Builder?  Why Don’t We Use SQL Only?!
Lecture 1 Introduction to Excel OVERVIEW Introduction Basics of Cells Modifying Columns and Rows Formatting Cells Saving Working with Formulas Basics.
Graphical User Interfaces with Perl/Tk An introduction.
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
Advanced Forms Lesson 10.
Web Technologies Website Development Trade & Industrial Education
Key Applications Module Lesson 16 — Excel Essentials Computer Literacy BASICS.
COMPSCI 101 Principles of Programming
Website Development with Dreamweaver
Tcl/Tk package in R Yichen Qin
The University of Texas – Pan American
Guide to Programming with Python Chapter Ten GUI Development: The Mad Lib Program.
IC 3 BASICS, Internet and Computing Core Certification Key Applications Lesson 10 Creating and Formatting an Excel Worksheet.
Tcl/Tk: An introduction D. Kim, K. Kundu, and M. Siegel November 26, 2002 CMSC 631.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Information Technology Word Processing. Word Processing is the preparation of documents such as letters, reports, memos, books, or any other type of correspondences.
 2002 Prentice Hall. All rights reserved. 1 Chapter 10 – Graphical User Interface Components: Part 1 Outline 10.1 Introduction 10.2 Tkinter Overview 10.3.
Key Applications Module Lesson 21 — Access Essentials
Interaction Models II Marti Hearst (UCB SIMS) SIMS 213, UI Design & Development March 11, 1999.
Building User Interfaces With Tcl And Tk John Ousterhout Sun Microsystems Laboratories Tcl/Tk Tutorial, Part III.
Basic Editing Lesson 2.
Microsoft PowerPoint Tutorial Created by L. George 2006.
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Lecture 10: Toolkits: Intrinsics, Callbacks, Resources, Widget hierarchies, Geometry management Brad Myers Advanced User Interface Software 1© 2013.
PERL TK. 4.Use an IDE 3. Use the documentation! 2. Experiment. 1.Learn the basics.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 9 GUI Programming Using Tkinter 1.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
IWorks Pages. Word Processing  Software that is designed for the entry, editing, and printing of documents.  Mac Version = iWorks Pages  As with Microsoft.
COMPUTER APPLICATIONS COURSE LEARN HOW TO USE COMPUTERS.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
FIRST COURSE PowerPoint Tutorial 2 Applying and Modifying Text and Graphic Objects.
Creating visual interfaces in python
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective.
Guide to Programming with Python
Introduction to Technology. Parts of MSWord Screen Title Bar Quick Access Toolbar Button Ribbon Status Bar (views and zoom)
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
COMPSA Exam Prep Session by Paul Allison On: April 8th from 1:30-3:00 Location TBA Winter 2016CISC101 - Prof. McLeod1.
MS WORD INFORMATION TECHNOLOGY MANAGEMENT SERVICE Training & Research Division.
Day 1: MS Excel for Beginners Aniko Balogh CEU Computer & Statistics Center
Programming Using Tcl/Tk Week 3 Seree Chinodom
COMPSA Exam Prep Session On: April 8th from 1:30-3:00 Location TBA Winter 2016CISC101 - Prof. McLeod1.
Word processing is the software package that enables you to create,edit, print and save documents for future retrieval reference. creating a document.
Innovation Intelligence ® Feb Copyright © 2012 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved. GUI design Controls Toplevel.
Working with Data Blocks and Frames
Topics Graphical User Interfaces Using the tkinter Module
Building a User Interface with Forms
Working with Tabs and Tables
Quickr Places & Templates Introduction
GUI Using Python.
Fundamentals of Python: From First Programs Through Data Structures
This Week: Tkinter for GUI Interfaces Some examples
Chapter 2 – Introduction to the Visual Studio .NET IDE
NexTk/NtkWidget A replacement for Tk ?! 1.
Fundamentals of Programming I Windows, Labels, and Command Buttons
Topics Graphical User Interfaces Using the tkinter Module
University of Warith AL-Anbiya’a
Welcome To Microsoft Word 2016
Presentation transcript:

Tk Widgets This material is best on several sources –Slides by Dr. Ernest J. Friedman-Hill –various Tcl/Tk books

Building User Interfaces With Tk u You build interfaces with –Widget commands  buttons, labels, list boxes, text widgets, canvases, etc.  often includes callbacks –Geometry management  widget layout tools  place, pack and grid –Bindings  bind user actions to widgets / objects to invoke commands –Window Manager commands  to control your window

Widgets implemented by Tk FrameMenubuttonCanvas LabelMenuScrollbar ButtonMessageScale CheckbuttonEntryListbox RadiobuttonTextToplevel Try the Widget Tour on the PCs to get an overview Start/Tcl/Widget Tour

The Widget Hierarchy..menu.file.scroll.menu.help.menu.listbox

Creating Widgets u Each widget has a class: button, listbox, scrollbar, etc. u One class command for each class, used to create instances: button.b -text Quit -command exit scrollbar.x -orient horizontal class name window name configuration options

Configuration Options u Defined by class. For buttons: -activebackground-disabledforeground-justify-underline -activeforeground-font-padx-width -anchor-foreground-pady-wraplength -background-height-relief -bitmap-highlightbackground-state -borderwidth-highlightcolor-takefocus -command-highlightthickness-text -cursor-image-textvariable u Default provided by class. button.b -text Hello -command exit button.c grid.b.c u Advanced: may be specified in an options database

Widget Commands u Tcl command for each widget, named after widget. u Used to reconfigure, manipulate widget: button.b -text "Hello".b configure -text Goodbye u Configurations are readable and modifiable, anytime –very powerful, as can change anything u Widget command is deleted when widget is destroyed. –destroy.b

Geometry Management u Widgets don't control their own positions and sizes: geometry managers do. u Widgets don't even appear on the screen until managed by a geometry manager. u Geometry manager = algorithm for arranging slave windows relative to a master window. u Constraint-based system i.e., what to do when widgets / windows change size Geometry Manager Requested size from slave Parameters from application designer Geometry of master Size and location of slave Requested size for master

The Placer u Simple but not very powerful u Each slave placed individually relative to its master. u Avoid using it button.b -text X place.b -x 0 -y 0

The Grid u Lays out objects in virtual grid of rows and columns u powerful, but good for most simple placements entry.e.e insert 0 "Type text here" button.b1 -text "Wow!" button.b2 -text "Ho Hum" grid.e -row 0 -column 0 -columnspan 2 -sticky ew grid.b1 -row 1 -column 0 grid.b2 -row 1 -column 1

The Grid u Another example label.to_label -text "To:" entry.to label.from_label -text "From:" entry.from text.t -width 24 -height 10 grid.to_label -row 0 -column 0 -sticky e grid.to -row 0 -column 1 -sticky ew grid.from_label -row 1 -column 0 -sticky e grid.from -row 1 -column 1 -sticky ew grid.t -row 2 -column 0 -columnspan 2 -sticky nsew

The Packer u More powerful than the placer, but more complex u Arranges groups of slaves together (packing list). u Packs slaves around edges of master's cavity. u For each slave, in order: 1. Pick side of cavity. 2.Slice off parcel for slave. 4.Position slave in parcel. 3.Optionally grow slave to fill parcel.

The Packer: Choosing Sides button.ok -text OK button.cancel -text Cancel button.help -text Help pack.ok.cancel.help -side left.cancel configure -text "Cancel Command" pack.ok.cancel.help -side top

The Packer: Padding pack.ok.cancel.help -side left \ -padx 2m -pady 1m pack.ok.cancel.help -side left \ -ipadx 2m -ipady 1m pack.ok.cancel.help -side left \ -padx 2m -pady 1m -ipadx 2m -ipady 1m

The Packer: Filling Stretch widgets to fill parcels: pack.ok.cancel.help -side top pack.ok.cancel.help -side top -fill x

The Packer: Filling, cont'd pack.menu -side top pack.scrollbar -side right pack.listbox pack.menu -side top -fill x pack.scrollbar -side right -fill y pack.listbox

The Packer: Expansion Increase parcel size to absorb extra space in master: pack.ok.cancel.help -side left pack.ok.cancel -side left pack.help -side left \ -expand true -fill x pack.ok.cancel -side left pack.help -side left -expand true

The Packer: Expansion, cont'd pack.ok.cancel.help -side left \ -expand true pack.ok.cancel.help -side left \ -expand 1 -fill both

Hierarchical Packing Use additional frames to create more complex arrangements: frame.left pack.left -side left -padx 3m -pady 3m frame.right pack.right -side right -padx 3m -pady 3m foreach size { } { radiobutton.pts$size -variable pts \ -value $size -text "$size points" } pack.pts8.pts10.pts12.pts18.pts24 \ -in.left -side top -anchor w checkbutton.bold -text Bold \ -variable bold checkbutton.italic -text Italic \ -variable italic checkbutton.underline -text Underline \ -variable underline pack.bold.italic.underline \ -in.right -side top -anchor w

Callbacks u How to make widgets work together with application, other widgets? Tcl scripts. u Widget actions are Tcl commands: button.a.b -command exit exit button release

Bindings u Associate Tcl scripts with user events: bind.e {backspace.t} Window(s)EventScript

Bindings: Specifying Events u Specifying events: a Modifiers Event Type Button or Keysym

Bindings: Substitutions u % substitutions in binding scripts: –Coordinates from event: %x and %y. –Window: %W. –Character from event: %A. –Many more... u Examples: bind.c {move %x %y} bind.t {insert %A}

Example: Context sensitive help button.b -text "Hello World" -command exit button.c -text "Lazy Boy" label.help pack.b.c.help -side top bind.b {.help configure -text "Press to exit"} bind.c {.help configure -text "i do nothing"} bind Button {.help configure -text ""}

Access To Other Facilities u Keyboard focus: focus.x.y u Communication with window manager: wm title. "Editing main.c" wm geometry. 300x200 wm iconify. u Deleting windows: destroy.x

Summary u Creating interfaces with Tk is easy: –Create widgets. –Arrange with geometry managers. –Bind if necessary (rarely need to, except for text and canvas objects) –window management