Running the shell. Tcl/Tk demo. Tcl stuff. Starting Tcl/Tk. If-then-else



Similar documents
THE WHIM WINDOW MANAGER

Introduction to Operating Systems

ESPResSo Summer School 2012

Lotus Notes 6.x Client Installation Guide for Windows. Information Technology Services. CSULB

You must have at least Editor access to your own mail database to run archiving.

Scheduling in SAS 9.3

A This panel lists all the IVR queues you have built so far. This is where you start the creation of a IVR

Scheduling in SAS 9.4 Second Edition

Accessing RCS IBM Console in Windows Using Linux Virtual Machine

Help File. Version February, MetaDigger for PC

Browser Client 2.0 Admin Guide

MONAHRQ Installation Permissions Guide. Version 2.0.4

Advanced Presentation Features and Animation

Oracle Managed File Getting Started - Transfer FTP Server to File Table of Contents

User Management Resource Administrator. UMRA Example Projects. Service Management

Moxa Device Manager 2.0 User s Guide

Tutorial Guide to the IS Unix Service

Getting Started with Mplus Version 7.31 Demo for Mac OS X and Linux

Appointment Scheduler

Cluster Computing With R

CPE111 COMPUTER EXPLORATION

The Einstein Depot server

CLC Server Command Line Tools USER MANUAL

LAB: Enterprise Single Sign-On Services. Last Saved: 7/17/ :48:00 PM

Installing FEAR on Windows, Linux, and Mac Systems

Grid Engine 6. Troubleshooting. BioTeam Inc.

Note: With v3.2, the DocuSign Fetch application was renamed DocuSign Retrieve.

IceWarp to IceWarp Server Migration

Credit Card Encryption 9.0

Installation Guide for WebSphere Application Server (WAS) and its Fix Packs on AIX V5.3L

The instructions were written for Windows 7. They have run without problems for Windows 8.

Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, Introduction 1. 2 Invoking Shell Scripts 2

Configuration Guide. Remote Backups How-To Guide. Overview

SFTP SHELL SCRIPT USER GUIDE

Talend Open Studio for MDM. Getting Started Guide 6.0.0

File Management Where did it go? Teachers College Summer Workshop

1.5 MONITOR. Schools Accountancy Team INTRODUCTION

SANbox Manager Release Notes Version Rev A

ELECOM Mouse Assistant Macintosh version

SSH Connections MACs the MAC XTerm application can be used to create an ssh connection, no utility is needed.

KaleidaGraph Quick Start Guide

Configure Single Sign on Between Domino and WPS

Printer Connection Manager

Creating Basic Custom Monitoring Dashboards Antonio Mangiacotti, Stefania Oliverio & Randy Allen

Event Manager. LANDesk Service Desk

PuTTY/Cygwin Tutorial. By Ben Meister Written for CS 23, Winter 2007

University of Toronto

CS 326e F2002 Lab 1. Basic Network Setup & Ethereal Time: 2 hrs

Quick Start Using DASYLab with your Measurement Computing USB device

Create a New Database in Access 2010

Rapid Assessment Key User Manual

How to Create a Spreadsheet With Updating Stock Prices Version 3, February 2015

Running your first Linux Program

Working with SQL Server Integration Services

Getting Started with Command Prompts

Basic C Shell. helpdesk@stat.rice.edu. 11th August 2003

The MAC address, short for Media Access Control address, is a number in hexadecimal format that uniquely identifies every machine on a network.

How to FTP (How to upload files on a web-server)

Windows XP Virtual Private Network Connection Setup Instructions

MOVES Batch Mode: Setting up and running groups of related MOVES run specifications. EPA Office of Transportation and Air Quality 11/3/2010

How To Configure CU*BASE Encryption

Mapping ITS s File Server Folder to Mosaic Windows to Publish a Website

Project Management within ManagePro

Introduction to Sun Grid Engine (SGE)

Intel System Event Log (SEL) Viewer Utility

Introduction. How does FTP work?

Chapter 9 Slide Shows

Getting Started using the SQuirreL SQL Client

Installation Guide for Crossroads Software s Traffic Collision Database

Working With Direct Deposit Accounts and Your Payment Elections

IS L06 Protect Servers and Defend Against APTs with Symantec Critical System Protection

Setting Up ALERE with Client/Server Data

RDM+ Remote Desktop for Android. Getting Started Guide

warpct.com Basic Computer Skills MS Windows XP Workbook courseware by WARP! Computer Training

Manual. Sealer Monitor Software. Version

Linko Software Express Edition Typical Installation Guide

Cloud Server powered by Mac OS X. Getting Started Guide. Cloud Server. powered by Mac OS X. AKJZNAzsqknsxxkjnsjx Getting Started Guide Page 1

EditAble CRM Grid. For Microsoft Dynamics CRM. How To Guide. Trial Configuration: Opportunity View EditAble CRM Grid Scenario

Computer Programming In QBasic


Introduction to the UNIX Operating System and Open Windows Desktop Environment

Introduction to the use of the environment of Microsoft Visual Studio 2008

HP StorageWorks Modular Smart Array 1000 Small Business SAN Kit Hardware and Software Demonstration

DataPA OpenAnalytics End User Training

A Crash Course on UNIX

Setting up FileMaker 10 Server

Command Line - Part 1

Configuration Guide for Exchange 2003, 2007 and 2010

Veritas Cluster Server Database Agent for Microsoft SQL Configuration Guide

Introduction. Chapter 1

Virtual CD v10. Network Management Server Manual. H+H Software GmbH

IBM Pure Application Create Custom Virtual Image Guide - Part 1 Virtual Image by extending

How To Use Standard Pos On A Pc Or Macbook Powerbook (Powerbook 2)

Configuration Manager

Linux Labs: mini survival guide

Title: Documentation for the Pi-UPS-Monitor-App

Moxa Device Manager 2.3 User s Manual

Constant Contact Export

Moving the TRITON Reporting Databases

Transcription:

Running the shell Tcl/Tk demo Brian Toby Tcl shell = /usr/bin/tclsh (tclsh.exe) Tcl/Tk shell = /usr/bin/wish (wish.exe) As usually distributed requires many extra files Here: combined distribution as one file (starkit) Includes several extra packages Starting Tcl/Tk Windows: ncnrpack-win.exe Linux: ncnrpack-linux OS X: ncnrpack-osx Requires X11 Aqua version of Tcl/Tk does not support graphics demo Can be run as ncnrpack-xxx <script> runs commands in script The set command set var1 value set var2 $var1 set var3 var1 Tcl stuff The set command puts writes a string: $var1 puts {w/o substitution: $var1 ncnrpack-xxx opens console Embedded commands set list [glob *] Math set var [expr {pow(2,3)*10] if {test1 { statement(s) else { statement(s) If-then-else if {var1 == test { puts test done set var1 else { puts not test

looping Tk background foreach var {1 2 3 a b c { puts $var for {set I 1 {$I <= 4 {incr I { puts $I Master window is named. Something inside master is a child Name of children of master will be.<name> <name> ==> start w/lower case letter.b or.btoby not.bt Some Tk Commands: making widgets Command label label <child-name> -text label text Returns <child-name> Command button button <child-name> -text txt \ -command tcl command Returns <child-name> N.B. creates child but does not display it Displaying widgets For very quick demos, use pack: label.l -text sample pack.l Better, use grid grid <child> -column <num> -row <num> label.l -text sample grid.l -column 1 -row 1 Demo1 Demo 1 label.label -text "Welcome to the Tcl/Tk demo" grid.label -column 1 -row 1 button.b -text "Exit" -command "exit" grid.b -column 1 -row 2 Type the above into console or Windows: drag file demo1.txt onto ncnrpackwin.exe icon or Command line: Toby$ ncnrpack-osx demo1.txt or In console (windows may need cd <dir> to get to right place): source demo1.txt

Children with children Child windows toplevel <name> Frames (containers) frame <name> Child of child is named.parent.child toplevel.win button.win.b -text child button pack.win.b Destroy command deletes widgets & children destroy.win destroy. (deletes.win &.win.b) (same as exit) Demo 2 label.label -text "Welcome to the Tcl/Tk demo" grid.label -column 1 -row 1 button.b -text "Exit" -command "exit" grid.b -column 1 -row 2 toplevel.w pack [label.w.l -text child] pack [button.w.b -text kill -command "destroy.w"] Creates a 2nd window. Clicking on kill closes the child window; clicking on exit closes both Demo 2 Demo 3 foreach c {1 2 3 { foreach r {1 2 3 { grid [label.$c$r -text "$c-$r"] -column $c -row $r Creates a table with grid Demo 3 Demo 4 Define a new command # define a routine to delete children of an item proc cleanup {parent { foreach item [winfo children $parent] { if {$item!=.tkcon {destroy $item Define a new command with: proc <name> <args> {script <name> <arg(s)> then executes command

Nothing happens! Demo 4 New command has been defined: cleanup Use as cleanup. -- like this: Demo 3a foreach c {1 2 3 { foreach r {1 2 3 { grid [label.$c$r -text "$c-$r"] -column $c -row $r # replace upper left element with frame destroy.11 grid [frame.f -relief raised -bd 2] -column 1 -row 1 # fill the frame foreach c {1 2 { foreach r {1 2 { grid [label.f.$c$r -text "$c+$r"] -column $c -row $r Creates a table inside a table with grid & frame Demo 3a Demo 3b foreach c {1 2 3 { foreach r {1 2 3 { grid [label.$c$r -text "$c-$r"] -column $c -row $r # change an element on the fly to show it can be done.33 configure -text "new element\n33" Changes an existing label Demo 3b Graphics demo package require BLT pack [blt::graph.g].g element create l -xdata {1 2 3 4 -ydata {1 2 9 16 # oops.g element configure l -ydata {1 4 9 16 # allow zooming Blt_ZoomStack.g Shows how to use BLT for plotting

Zoom --> Graphics Demo Running external programs Many ways -- this one is platform independent: set fp [open x.txt w] puts $fp input close $fp exec program < x.txt > x.out set fp [open x.out r] while {[gets $fp line] >= 0 { #do something with line Running external programs Even better, have program write tcl code as output, then replace while with: set lines [read $fp] close $fp eval $lines To suppress errors in output catch {eval $lines Running interactive programs: Win9x, -ME # this creates a DOS box to run a program in proc forknewterm {title command "wait 1" "scrollbar 1" { global env expgui set pwd [file nativename [pwd]] # check the.exp path -- can DOS use it? if {[string first // [pwd]]!= -1 { MyMessageBox -parent. -title "Invalid Path" \ -message {Error -- Use "Map network drive" to access this directory with a letter (e.g. F:) GSAS can't directly access a network drive \ -icon error -type ok -default ok \ -helplink "expgui_win_readme.html NetPath" return Win-NT/-2000/-XP if {[info command winutils::shell] == "" { MyMessageBox -parent. -title "Setup error" \ -message {Error -- "WINTILS not found. Can't do anything!" \ -icon error -type darn -default darn \ -helplink "expgui_win_readme.html Winexec" return # loop over multiple commands foreach cmd $command { # replace the forward slashes with backward regsub -all / $cmd \\ cmd winutils::shell [file join $dir gsastcl.bat] $cmd proc forknewterm {title command { global env expgui # loop over commands foreach cmd $command { # replace the forward slashes with backward regsub -all / $cmd \\ cmd exec $env(comspec) /c \ "start [file join $dir gsastcl.bat] $cmd"

Unix/OS X proc forknewterm {title command "wait 1" "scrollbar 1" { global env expgui set termopts { if $scrollbar { append termopts " -sb" else { append termopts " +sb" if {$wait { set suffix { else { set suffix {& catch {eval exec xterm $termopts -title [list $title] \ -e /bin/sh -c [list $command] $suffix errmsg if $expgui(debug) {puts "xterm result = $errmsg" How can you tell where you are? if {$tcl_platform(platform) == "windows" && \ $tcl_platform(os) == "Windows 95" { # win-95 elseif {$tcl_platform(platform) == "windows" { # win-xp else { # the rest See file expgui/gsascmds.tcl for more complete versions of the commands and for gsascmds.bat