various widget enhancements and self- explanatory widgets applications of tcl/tk gui author:rahul...

18
Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author: Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor Graphics

Upload: elaine-holland

Post on 23-Dec-2015

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

Various widget enhancements and self-explanatory widgets applications of Tcl/Tk GUI

Author: Rahul DashoreMentor Graphics

Presenter: Tony JohnsonMentor Graphics

Page 2: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Agenda

Overview Enhanced Entry Widget (Flow Chart) Enhanced Entry Widget (Integer/Real/Binary/Time/String) Foldable Widget Dynamic Row Modification Widget Self-explanatory Tree Widget Summary

Tessent Shell Overview

Page 3: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Overview

Tcl/Tk entry widget has basic functionality Sophisticated GUI environment requires fancier and ease to

use widgets Enhanced entry widgets provides validation of various data

types— Integer— Real— Binary— Time— String

A folding widget provides capability of hide/unhide long list of children widgets

Dynamic row widget has capability to add/delete rows on demand basis

Tessent Shell Overview

Page 4: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Enhanced Entry Widget (Flow Chart)

Enhanced entry widget provides ability to insert user’s key-press only if it’s valid for specific data type. Such as— Integer— Real— Binary etc.

Tessent Shell Overview

Page 5: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Enhanced Entry Widget (Integer)

Allows to insert numeric values only. Range or list of integers can be provided.

— “0 .. 100” or { 1, 2, 4, 8, 16 }

Pre defined non integer enum values are allowed. Which will be shown at the top of selection list.

A developer can plug enhanced widget using following syntax:

Tessent Shell Overview

advwidgets::entry .frame_path \ -labeltext “input” \ -type “integer” \ -allowed “-5 .. 100” -negative 1 \ -enum { x, auto, on, off }

Page 6: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Enhanced Entry Widget (Real)

Allows to insert real values only.— 4, 1.2, 6.123 …

Pre defined enum values are allowed. Developer syntax to plug in any frame:

Tessent Shell Overview

advwidgets::entry .frame_path \ -labeltext “weight” \ -type “real” \ -enum { x, auto, on, off

}

Page 7: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Enhanced Entry Widget (Binary)

Allows to insert binary, octal and hexadecimal values.— o777, h8ade, b1010, 111, 4’b1010 …

Default base is binary, but user can specify octal or hex (o or h) prefix for supporting base. User can also specify expected number of bits (e.g. 4’b1010)

Pre defined enum values are also allowed. Developer syntax to plug in any frame:

Tessent Shell Overview

advwidgets::entry .frame_path \ -labeltext “weight” \ -type “binary” \ -allowed { binary, octal,

hexadecimal } -enum { x, auto, on, off }

Page 8: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Enhanced Entry Widget (Time)

Allows only non negative time units.— 10ns, 4ms, 2s …

Pre defined enum values are allowed. Developer syntax to plug in any frame:

Tessent Shell Overview

advwidgets::entry .frame_path \ -labeltext “time” \ -type “time” \ -allowed { s, ms, us, ps

} \ -enum { x, auto, on, off

}

Page 9: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Enhanced Entry Widget (String)

Similar to basic entry widget. It allows any key-press.

It also supports pre defined enum values are allowed.

Developer syntax to plug in any frame:

Tessent Shell Overview

advwidgets::entry .frame_path \ -labeltext “weight” \ -allowed enum \ -default on \ -enum { auto, on, off }

Page 10: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Enhanced Entry Widget (Pseudo Code)

itcl::class ::advwidgets::entry { #variable list (internal variables used by class) #define variables with default values

#constructor code #parses and assign values to corresponding variables #constructs entry widget with following components #top frame #label widget #entry widget #dropdown button #popup listbox #pack label widget, entry widget, dropdown button (left to right order in top frame) #bindings on keypress, select values from listbox etc #validation proc #validate based on different types and specified options }

Tessent Shell Overview

#validation proc for different types

::itcl::body ::advwidgets::entry::validate { args } { #parse arg

#if selected from the listbox it’s always valid #return true

#set current_entered_text (which is appended current keypress to entrywidget text)

#validate for enum values #set current_entered_length to length of current_enetered_text #foreach specified enumvalues #if current_entered_text is matched with first current_entered_legth of enum_value #return true

Page 11: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Enhanced Entry Widget (Pseudo Code) …

#based on type different validation: #switch type { #integer: #if allowed_negative and first keypress is ‘–‘ #return true #if current keypress is not an integer #return false #if current_entered_text is not in allowed list or not in range #return false #return true #real: #if keypress is neither an integer nor ‘.’ #return false #if already a ‘.’ present and keypress is ‘.’ #return false #return true

#time: #set time_end 0 #if keypress is integer and not time_end #return true #if keypress is in allowed time symbol (s|ms|us|ps) #set time_end 1 #return true #return false

Tessent Shell Overview

#binary: #if [b|o|h] not specified keypress neither 0 nor 1 #return false

#now only for allowed b|o|h binary only is considered above #if keypress is integer and allowed is [b|o|h] #return true #if ‘ is not present in the entry_box_text and keypress is ‘ #set bits_count entry_box_text #return true #if ‘ present already and keypress ‘ #return false #if keypress is not [b|o|h] #retun false #else #set base b|o|h #if keypress is in range of base (b|o|h) set in the above step #return true #else #return false

#string: #return true (enum is already considered before) } }

Page 12: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Foldable Widget

In EDA tools a frame may have huge number of children which may have some common properties.

Group of similar children widgets can be visible or hidden using folding widget. (+ or – indicates hidden and visible frame)

Syntax:

Tessent Shell Overview

advwidgets::foldablewidget .frame_path \ -labeltext “DataInPort” \ -default collapse \ -foreground “gray”

Page 13: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Foldable Widget (Pseudo Code)

itcl::class ::advwidgets::foldablewidget { #variable list (internal variables used by class) #define variables with default values

#constructor code #parses and assigns values to corresponding variables #constructs following components #top frame #label widget #child site frame #append [+] or [-] in the label text based on –default option #places label at appropriate coordinates (top left corner of widget) #if default is collapse #set visible 0 #else #set visible 1

#binding on mouse-click to show/hide children widgets # proc declaration #showhide proc to collapse/expand children }

Tessent Shell Overview

#show/hide proc

::itcl::body ::advwidgets::foldablewidget::showhide { } {

#if visible is 0 #modify label_text to label_text [-] #pack child site #set visible 1 #else #modify label_text to label_text [+] #packfoget child site #set visible 0 }

Page 14: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Dynamic Row Modification Widget

Rows can be added and deleted from the widget on demand basis. + & - button can be used to add or delete a row.

Any enhanced entry widget can be plugged with this widget.

Syntax:

Tessent Shell Overview

advwidgets::rowidget .frame_path \ -labeltext “decoded_values” \ -default_rows 3 \ -default_values { 3’b100, “”, “” }

Page 15: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Dynamic Row Modification Widget(Pseudo Code)

itcl::class ::advwidgets::rowwidget{

#variable list (internal variables used by class) #define variables with default values

#constructor code #parses and assigns values to corresponding variables #constructs following components #top frame #label widget #child frame #for 0 to –default_rows #create row frame #pack + button – button and enhanced entry widget in row frame #insert default_value for each row #pack row frame in child frame #pack label widget and child frame inside top frame #various widget methods #addrow #deleterow }

Tessent Shell Overview

::itcl::body ::advwidgets:: rowwidget::addrow { current_row_path } {

#create a new row frame #create + button with associated command #create – button with associated command #created enhanced entry widget #pack + button – button and enhanced entry widget #pack new row frame below current_row_path #adjust indices of each available row (indices required for other functionality) }

::itcl::body ::advwidgets:: rowwidget::deleterow { current_row_path } {

#if number of rows in child frame is 1 #return (minimum one row is required)

#destroy current row #adjust indices of each available row (indices required for other functionality) }

Page 16: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

A Self-explanatory Tree Widget

Coloring mechanism to indicate different signal on each node:— Red for error— Orange for ancestor of

error node

Similarly image color can be used for different status:— Green for fail, Red for fail,

Grey for default …

Tessent Shell Overview

Page 17: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential

Summary

Fancier widgets and ease to use. Modular and reusable. Can be plugged with existing Tcl/Tk widgets. Makes developers task easy.

Tessent Shell Overview

Page 18: Various widget enhancements and self- explanatory widgets applications of Tcl/Tk GUI Author:Rahul Dashore Mentor Graphics Presenter: Tony Johnson Mentor

www.mentor.com© 2011 Mentor Graphics Corp. Company Confidential