0%(1)0% found this document useful (1 vote) 4K views21 pagesSL Unit-1 Notes!-1
Jntuh Btech 3-2 CSE(AIML)
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
dntroduction +
| iy Ruby 41 0 pusie . object - oxlented tonquage .
> Ruby har features that axe frites o peat, python end Small tt
Paogoaroming languages which ate sol pling languages
using aby Sinton Ss mth easier than using Emautaln syntar.
| > Ruby 4s a inktrpecied Scaipfing language. So most © of IES ofp l(a
font taetule ‘nshuclions dif ctly and freely .
> Raby fs alto dua neflective, object -sienfed gene stal ~ puspose
Psoqnamming language
1 eveaytting ~ suby Moo objec extant blocks.
the objective a suby war fo develop a sufles between programmes
and tomputing machinery,
Featunes of, Ruby $
Fak 76 0 Senves ide sedpling language Bhe python and pect.
Haan be wed 4 wxite C&P scapts - :
con be tmbedded = to ATMEL i
Siar a alton, tay and grmlag auntat fo ches prqaamm
longuages The cet ond peal, an : en
\ i (on be eatily médmteined,
} > BQ paogsom: — fon J
|g Rails :
> foils % alto known ae Ruby on Rails.
holt Wf a Serves Side application development framework wiley
fin muy tanguage.
23} supposttt — Mic (Model Wiewo- tonteolten) asthilechise which pawides
defautk hucuse Whe database, wel pages y and web sewices.
co gt uses wtb Standard? Whe JOON oF AML to trons fer data, |
| sat gto uses HTML, Cho ond Jaa scvipt fos the Uses anlectace. |
@ scanned with OKEN ScannerRails concept uses two snajes pindples ¢
4+ oontt fepeat yourselt (ORY): Ht is a pane % sphoare deve
ment to seduce the —epetivon th information or dey
2. conventions over _wntqueatfon (coc): Rails has opinions ataut — |)
The beet eoay do enany things in a web opp h cation, |
Inhy Ruby on Rails : 1
Tt allow! uses to tounch a faster web oppiications.
Buby tm Rails fomeworts maker users app tastes and safes.
> useds apps con be Easily updated with fadest funclionality,
TL wes meta prgromming Kehriques to wile programy.
Feature of Rails $
Ae MC onchitecluse
@ Adve Records
3 Bull: -in teaking
Ao Meba progeramming
Re convention oven tontigucation
|| & seat tolding (defines how application database mir).
Advantages of Ruby _on_ails
4. Tooling
2. Ubsacies
{| 3. code ually
|]. Teck automation
Fr hawge tomeunity
6. pooductivi hy. i
Pisaduan tages of Ruby _on Roils 2 , i
| 4 Runtime speed ig 100 |
ita (ack Bf fleet BI fly
| 3 pecagaued boot peed
4 mutfithreading
K. Access use oH Adfive accords.
@ scanned with OKEN Scanner©
athe -stichute ond _€4eCation_of Ruby porograms ¢
> whenevet a gtuby Paogpar 4 sun, “Should wih the lerical
Sruclurt th he progam + ;
ienical shuclure toveais he tokens ih the prota,
Din he mb sep che dyntatic thuchtse tf the progotarn ‘e
coved +
> In synakic Shuclue YW Eaploims how oe Expxeusions, Control
Sruclusiety methods, classe: ond etc od wailen as a sees.
oh tokens. :
(F) Keticos _shuctyre : |
athe shy —inespreer parses (deurribes) pnqaam qu a sequence |
of tokens
—ythe doment used tn hy are tomments Bleeal¢ panchuaton 5
Vdenkiyiers and epoords.
4. comments ¢ comment uly Mart with a at character ond
tonfinue Hil end he Fine,
he Inteoprtdes fants the “at chasacies ond any ful that follows
she syraboly
Oot 4 if peat in a Shing oF Eprticon Tt 1s not tontidered
as Comment
trample 2 a= "HIS nome is mr HH a A Comment
Ste rot at Hs scgrovend
comment
Fa. titesale > ahey ane values that —oppeat directly in ruby tource
code,
they ‘include numbess, shige Of Hat & requlos enpse tons
tomple: \ ton ‘beep titesal |
| Saiddu" A an shing Weodd \
[Twp] a Aequiar eoyntscion Hera,
@ scanned with OKEN Scanneri
3: punclaation : Ruby wer funchiation for various proposes ihe "4h"
Hoe addition, "4" for multiplication » "11" for Boolean OR operation,
they ane clio used fo delimit string, aequlas Bapetichon 4 orrrauys
and to up 6 Separade exyreasions «
He gdentiticas ¢ elensflors ane wieal "m alby ty mame . Vantables,
methads , classes ond ele.
they include itr y nuimbess ond undexseosts has actears
with a numbpst , Cannot “nclide white space
> they cannot
oot e0n painting —chreacteau
a sdentfiexs that begin with capital leteare are conttants.
fdample: 4, 2, -fiddu, a4) AB
Ke Keyword + Keywoode have spec! mearing n maby.
<> dels ate folaly Yl Keywords.
Whe space t Spacer, fabs and newlines ane not tokens, but axe
used 40 Separale tokens.
Moth tf the while spaces ane ignowed by ‘oktepreles and ane
really wed fo facilate fe acading and — undexstanding
prtogsiams -
Gi) syntofic _stuchines :
St Aescanbes how thal tonenr. coming ‘info the Iyter synlakc
shuchixe of a sutby prdg2tam,
cathe basic. unit tf Syntart in thy YW the eapetion,
cote Fnlerpaeler evaluates —exprtuions ond! producer values.
othe Srnplesh ehprtssion Ws called —pimany expretion they nepstseo
values direety
~anumbes, ghing Werals , heywords fike due, false
Alererces oo aly primany, Epreaons,
ong males
@ scanned with OKEN Scanneri) puogpam —eeculion +
Q-
Ag Ruby Wa Koipling lenquage, Jo jhe muy propa can be
repatecented ar stafemenls of lls ov staple to he taeCuted,
cttese statements cote trecufed —Sequentfally nthe andes they
APPeOts
=> tis trecuflon wed Gon be changed by udng of ouby's Cobo
Slatements .
sah Uno geal method tke © main method fiom whee the
execution — Sarts.
rrr—=FEE—=ee—=ee”—=—“‘=é#éE
fine.
when Mepis — incounens a class or method — dlifinatfon, Her
pocler tteculer the dladement and creates a new class sr meshool
Dials tn the progtarn the Tnktepreten eet ules a method —fnvo@-
fon taptiewion fee the —meltnd dafined above,
SK Fvocation will caue she datemenk in the method. body to
ke Hefuled.
athe sruy “inbspet tes fn Frwoked for he cammand fine and
Sofpt to txecak,
baby inkeprtiess seads she Ble and trecules
faetules any BC GDN Blocks then Tt ast trecution fom the
Yost tne of the file until one of the fotowing happens ¢
G) Reaches end pf He File,
GH fecules a shadement that Cowes Stuy prDgnam to eominale
GS Readt a fine that marke the ingical end 4 +e file
with the then — ND —-
the script. at fas)
@ scanned with OKEN Scanner
|
i
‘
qfr rackege Management with ‘Popy Gems t
Rby Gens fe a standardized package ond instalation fremewss
fos branes ond applications
BY Wing Raby gene A WE Eaty to locate, ‘mulalt, upgrade and
| uninstay Ruby packages.
|) > Facilites povided by Ruby gems fot users and —developests ¢
4. 4 Sandasdiyed package femal.
| & A Cenkal —veposttory (location) for hosting packages in the
| feral
| 3 St factHawe Mnstatatin and — management of mur tiple s Smutanco-
usly —Gnstatied —vesrdoms of the dame [Fhrary.
| S$ foclitays using of end- We tool fer quesing ‘nulauting ,
i urinating ond ofenwite monipulating these packages
| 230 Ruby POyraming te developers — build hein applications
| and Glaasies in a Single #e- thee files are caited a gems
| Towiauting Ruby Gems :
Suby gems Ae open — uutee , so TE con be Preely downloaded.
| > Fon ‘nailing the Raby geent sytem we need
i> package libraries fox ruby ane called — Tuby gems. fy use the
‘nchded ‘nsaitation Seoript -
h ed ruby gerne ~ 0-4-0
‘% niby insdall eb
> fom sesting — whether ouby geme ft Inctanied succestfuly or
nol use the lommand fine,
% gem help.
Sostatting Application _Gemt ¢
> Gent aie 0 Simple collector of mlby codes in a cetciption file.
abe ony usest Creates 0 new gem, he Con Upct uptoad that
opm to the Gon bol gem sewer fom hes where eyeryone Gan
@ scanned with OKEN Scanner@
use that 9¢m.
Tk we wont to use & new ger, then we need to add name
S the gem to the geen Ble (Hit the ik of gems).
Hea adding the name of the qe to gem fle, we wie a
4oo} “ pundlea".
> he Bundles tool downloade ery gem tn oust list fom
the gem deevey and Tnthalls all she gems in she gem file,
>the ‘sal! command downloade andl ‘mstau's the gem and all
Abe necesiasy Aequirtments.
athlon ables Tt bullde documentation for the “imitated gems.
codes sen ‘nstau dip
Feiching {rh fee -o-4-( gem (i007)
Building native fulensiont. this Could fake a while |
duccessdutty nsiatied ab tee - O-4I
felching : dip - 00-9 gem Coos)
Successfully inslatied dip ~ 0-0-0
passing dofumentation fev rbtte - 0-4)
Snslaliing ai documentation tee whbee- 0-4!
passing documentation far dvip -0- 00
anstaiting si documentation fer dip -0-0-9
tone installing dotumentalion dev rbtee ,
dyip ales p seconds
& emt Installed .
Hee we have instaned 2 geme shkee & dep.
aRekee is a dovled acsotiagive collecHoas which ‘ ‘implemented
uuding she concept oP fed- Black #ee,
= palip geen depends on the abhte which has an extension. |
Hs talenions, then |)
if
@ scanned with OKEN Scanner
a hay pout instays the ehfeee and wilds
UL slate ‘nttalting dap gem.Mest ‘insaring both the gems 8 oes othest auby builds
documentation ter the Inctaued gems.
Invtalling and using Gem Lbsrawies ¢
> Most ef the Uibrasies ‘in aby we aeleased #1 the dorm of &
gem I) a gackaged fieraay 8) by wing applications that Can
| be ‘nitatted with a too! called Ruby Gems .
[As mentioned belive couy get AS a packaging a4steen designed
to facilale the trtalfon, shaving and ‘ndtartaton ap libraes.
the moin file whee fibsavies one dfortd "Ruby gems. eng"
a3 their ote some oles douste of ibswavies Mike Git Hub.
| > ruby gems enabler user fo ‘nda! and manage muliple versions
a the Jame fibsany,
| Agen using Ruby gems fo dovnload the Wbeaay we Con allo use
Ak to wad the fibvary tomponents nto ous application,
soquiste *auby gems
nequisre gem "gluecloth', *>=o.0.y"
doc = Blueclth : : new <2 MARKUP
| HS Te Some sample [Hay Ji] + Just easing +o use (glueclothI(t).
| Just a Simple at
Ti hip: uy ~fang-or9,
MORKUP
pubs doc. to -htm},
| srene eplueclorY 46 gem which olrtaoly be ‘instatted,
cathe fouk hwo lings one “Ruby Gems - specie Code".
cothe Bout ine toads the Ruby gems Cone ibrasies which will be
needed to wok with indatied gems }
othe Sttond fine odd he" plue cloth” gem fo Ruby! “ftom” |
1
@ scanned with OKEN Scanner0
cots line uses “Mxequire” to taad any Ubvaies that she gem's
creator specified to be autoloaded.
caeating pun own Gems t
Creating and purfhing neo gem if simple by using ole present
Sm suuby gems -
het we cafe a new ens leh gem name be hola gem,
fede “% tee
b hola - gemspec
Lob
t— hola .sb
the code fpr ous package it placed with in the fi dlirectany
the tode Inside tb toe) holark 8 to make suse that we should
get dome output torn fhe gem,
Lode ‘tetat fb) hola cb
clase bolo.
def self hi
ms “hello wortd!
end
end.
wo athe gemipace difines what is in the gem Be 1 who made. the
gem, dhe Yestlion of the gem,
It is also ous Intesfore ath "Ruby gent. wag.
Lede? cat bola genr¢pace
Geen ss tpeci ication + new do (s}
$name = hola!
Seveation = 0-0-0"
8 tummasy = * hola”
g. descsipHion = "A simple hello wortd gem"
S$ authors = [Nick Guasanty"]
Bemail = ‘nick @ quasar to’
Qe Hills = (ri | hola-abe]
@ scanned with OKEN Scannergr hornepage = itp ir aubygeen’ 09 gern hola? a |
gehcense = 'MOT!
endl :
erthe qeongpace if abo & euty, $0 HC Con wike seipht ty genesale
the qile ames and mention the veasion cumbe st,
olyer we have created a gemupace y oe ON build & gem fom i
and ‘nstatl Ae gtr f tat
todas % gem build hola genupec
Successfully built Ruby geen
Name ; holo
veagon! 0+ 0*0
filos s hola b+ 0+0 ger
‘Fo gam Fnstatl . | hola ~ 0:0: 0gem
Successfully tsated hola - 0:0:
1 gem ‘nstatleol
efor mpicting the piling of crated gem. final fp it to
“nequine' the tm ord ue it
* ith
7? aequire ‘hola’
=> tle
>> holo Ht
helo world}
row “hola geno" deadly fo chose, for this we need to! sth oe
tornpultes with ory Ruby gems actount . by ating lode ;
codes ¢ Cucl—w quaish Hitps Il by gens «org [ api [va] ori
keys yard 7
woh geolecedbial 5 chmod o600 wf geal ceedentials
enkte host pawword fot user Cqaush! :
snow we ae ztady fo inhndue oll Jem fo the world,
i
|
@ scanned with OKEN Scannerodes oem push hala ~ 0-0-0 gem
pushing gem to Rubygems + org.»
Suecesstuly xeqfsteced gem hola (0+ 0-0)
Ruby ond _web +
> Many options one avaliable for using -euby 40 ‘implement we
applications like wailing oust own SMTP Serer, FIP daemon ov
web Seavest ‘in stuhy »
It con alip prrtown other tasks like eI programming ov as
@ yeplacement fox pH.
esting ca _S pts <
the tut fom ob CG 1S tommmon Gateway Snkfare,
ulen we clk on a fink on a wtb page ox URL ob dhe. following
pxoress occurs.
4. we use out bsowsen to acrels tho URL and connect to +he
{ttTp web — sesveat.
2. web Seaver — merece the request message and looks foe aceesting
the #les on the genes if thy Eis, OP they ave fund the
getumed + de clit. othemwise , it mekimmy an — eropr message
3. dhe browses receives the information fawn the desves and
Gispleys the aeteived fle or Empy messages,
web Serves
dernest Side sch}
pata bace
Http protocol.
@ scanned with OKEN Scanner‘he Cookies +
Basic Ruby CaS code is
th | fuse] Bn] muty
putt “ontent —dype seat | hemi An wn
Puls "chiml> as fs a dat < ody? < 1Hmt >" *
rt we Cal this Seofpt “Heed eg? ond “uploaded 1H fo a unix
bared web hosting provider with the aight permission y we an
we ik at a CGP seaiph.
swhen a user equesls yest-cgi fom a wel browses 5 Ahe web
Seven searches fos 40h. (gion the web Sit.
| s.ay}ea1 4¥inding feats cgi the genes executes Ft ‘using the. i
suby Intec prteles.
| > the Ruby scat sehtnt 0 basic HTTP headest ond then anehins
oo basic MTML document
using Cais Ruby tan ca CGI brary to untle more complex
Car Staipk-
cote flowing ade cats he cof scapt bray fo eeale a Gt
Seaiph-
code: | [vse] bin] auby
equi ‘cgi
Ogi = CAE. nevo
puts egi-heades
pas "chtml> this 1s a dest < [ody > ",
catty tode coiealed a CG2 object and wed if to print the
headex fine.
prvchaw
cookies we ued for Aemembesing and ‘racking preferen(es
tommissions and oer Infomation required fer better Wisi tos
Fupestenre of Se stakes.
|
\
@ scanned with OKEN Scanner| Yow cookies work >
| cs the geavesr Sade tome dale 4 ake visttost bowser in the fom
of a cookie.
athe bss may accept she Cookie, Woak is accepied, it ie
Soed as a ptain Hat, r€terd on the visitov's hard dave.
Dwhen the vision asiives fp anolhesr page on jhe Jeewet, dhe
cookie is availaye fos Achieud.
sdonte achitued, the Sever knowet what war Jorecl-
|| cookies have five varlaue- tenglh $elds ~
iH capiones sche dole the cookie will —eupies 32 the yolue is null,
1} Cooki@ will gapite when the visitos quik the bmwer.
> oomain: the domdin name a He Sie.
paths the path to the dito or web page that sche she wokie,
Ais moy te Honk iF you wank to shies the cone from any
dixectory oF page.
a secune s Th this fidd value is “ecuxe", the cookie Can be
achieved only by 4 fecuse gener. TE the feld 3s blank no
Juch Apshicfon txisth
Handling Cookies in Ruby ¢
Sn ruby we tn create a object named Cookie and lore ony
Jevrtal nfesmation in i
swe Can aio se a tookig = heades in +he call fo CGT. oul -
Codes t{ [uses] bin | uby
sequize “eg
gt = C42 new (uty)
(okie = CAT-11 COOKIE + New ('name'= > {my cookie tvalue' = >
‘zara lt’, | gepints! => Time.nowt
eqis out ("cooie' => ceonie) do au
ond cgi head #Cqts body q* Cookie stored "}
@ scanned with OKEN Scanner
\|he copies ane neprented using a sepocale objtee og class
fwe tries I a gutendible plug n-hased famewors that Ie the
“PIP athe user Come back to Anis page ogdin, yo con sehfeve
the Cookie values se} at shown be lows
Code ab! [uta [ bin] wuby
— Acquire "eq"
Caf = caf. neo (*himly")
Coole =cq! «cookies [img cookie
Gout ("cookie '= > cookie) do
yj head + (Gisbody 4 Cookie fo}
en
C1:: Cookie, containing the Jollowing accectort 2
Mmbute Rehined value
name Cookie name
velue an ora of cookie value
path Ae Cookte path
dornain the domain
frapiaes the gapisation Hme fax a fime objec} )
Setar tue Tf Youre cookie
x cholee of wth Seouess :
othe suby yertions atesting fom mityy 8 ‘and ay the tale. vesitons
oo bundied — with we psick
we BAK IC ae HerGbIe, pure—why rrp seney foolHil.
hore the Inboducton Hf we goick most of the aby septs
whe ‘muoring unde» the lobo! Apache wll seeven,
Wer to wile, seners to handle Http Aequests and setponser
fs Ruby standard bray Wy installed on fveny machine that has
Auby » mos Ane frAMewoHKE IN Ly Fe sally and ack we
weprick as a default development web Jesves,
@ scanned with OKEN Scanner> pesider uing we Bates ot Sesyetng Matic content, we can alin
use i Bke Java fexviet —Gonfaines fo dlore Some Simple sesvies
al a partifulas |otalton, :
¥ Soap and web sesviles ¢
the Simple obfeet access prototor (soap) 38 a eros plat ond
language - independent Rpc profote) based a YL and sometimes
Wrap. .
Tt uses KML 40 ty tode +he ‘information that makes the emote
proceduxe ceils. and Http to Panspork that infysmation aCvoss
a nelwots far clienls to Semvert and vice versa,
“Soap has several advantages oven oer technologies like com,
CoPRA and ele,
Jaulatting soapy)
Poop Implementation fpr Ruby Cionpye)
Lode’ t gm Gnstay Joapys ----- imelude dependencies
this Command Milalls SodpyR ond a the rated packages fox
SOAPUR,
siting LoApYR Seaveds
Stoopyy Jupporls 2 diffecent type ck sesvexs
car [ras cas baed
« standa lone.
Skep 4 - Snhesid oonp ss Rpes: Standalone sever class
3% “wmplemen! pus own gland alone Senven we need 4 wile
a mw class.
athe nw clas will be dild of he Sonp:: standalone seve
(od clase Myseswwa < SOAP? RPC Ss Sandalone senweg
end
@ scanned with OKEN Scanner£ define handles methods
Sn Hit Sep we write our web sevice methods.
obese method? wit we accutane fxr the cufside world.
code? clate Myseawer the “iniKaliye" method it ated fo gapose Jeeves method.
codes clase MYLPME ZL0AP 1; RPC I; standalone server
def inialze (*aaqs)
add—method (receive, method Wome , + partanisg )
end
end
Dees pon of parameleae :
4. Receiwet! obj thet — fontaine the ‘method Name’ method,
aH
a
parrarnelen
rahe name the mehgd which Ye carted de to
an pC aequedt
3. param hat Specigi@: when pavameler names ond pacameler modes
ok given.
Slep_H- Sas the Jere.
{ 4% Gash pus Sena instanfaling one Msanre
| sche final dat ts to hy E
|
|
a the de deste = class and calling Stast method. \
@ scanned with OKEN Scanner©
i
Code + ny Gentes = My Sealer new (esvername!, ‘urn bmubyet seavice Hamel
houtname ; port’) |
4 SEWED. tart. |
Descaip tion of aequired posameleae ¢ |
4. eouteantame $ A deaven name, he wer Can give kis own nome.
2. Us wuby_: sevice Name 2- Here umn ssuby 7S condtant y but ues
Con give a unique seavenname for this Senyos.
3. hoskname s Specitier the hostname on which the sesvey will Le
Wasted,
post $ fin available post numbes which should be wed fey the web
Seavey
y Ruy TK:
Ruby 1k povides Suby with a gsaphid uiey inbstace (Gur),
31k an un on windsos, mac and fru.
the baile component of @ tK- bated application is cated a widgel.
3s applications fellow a widget hierarchy — where a many no- of
whdg et ton be placed within anothea widgel
othe mdin widgel in a KK propa is eleeed as mot widget.
Roo} wie can be cxtated by making a new ‘nefence in
jhe TK-a00F class
Fnstaltasfon 2
quer can ingal Tk fom “active Hale Actye Toi"
windows
mac and tinue used — may have ahtady nstatted Te along
with he 0% |
@ scanned with OKEN ScannerSimple Tk Apphicadfon ¢
ahe Tatowing 36 a code fr Gmph th applicaten an Pub,
Cede s neque UK" :
dovl = TKsvol Mh {HH "eau" h
“UC (LL + new (sOoH) do
fext "feito worta | '
Pack ('podx =>in, tpady’ >it, 'side!= >bept’ )
end
HK « motnloop
Rest ¢
> Aer loading Th ertention module, we eated ae
using Th ovo! +n#w
Aer that we prepared a TK tae) widget as a child of te wot
fame and Seting Several options. tox he lavel,
Mast we pack the wok hame ancl enfor the main Gul event
toop,
Fon cneating a widget we need to tae name of the widget
ae given in the Ts doturrent- and odd ‘ti’ nfo of i
fos frame the widget "larg", "Ruton", ond "eaty! » become
the classes "Tk tobe", “Tk button" and "Tk enky"
fot (rtating an ‘Mstance of a wldget we ute "New"
OTL we donot specigices a pastnt foe the given widget by
detauit tt wilt consider the sopt-level tame,
@ scanned with OKEN ScannerSealTog. ld opffon :
SMI geal [TH oplfons ane pasted to a widget fra "Hyeht,
ay uy we also pec options hy ting 4 (ode Hoth,
erthe name of the oplfon 46 wed as a method name with Ip
the Heck «
athe atqumentt to the oplfory —ayptaoy ax aaiguenents to the method
cats
Sh pooent FE Aatien as the flask angitenent do the widget dottowed
by an op dhe ode Hock 4 oplfons.
Lode s iKlabels neo Cpaaient — widget )
teu "hello wortd {!
pack ("pada ! => sy
'yady != > Ay
‘gfe! = 3 teft!)
i
fF oF
TKtale|. new (parent ~ widget 1 ACLE = > "hello jwooldl! "9. pack)
Getting whdget pata!
> call backs and binding Vaotabes con pe used for geting
tntamotion fayn widget
tan be easily 221) following ts an example tode pe
cai back
cal back
(ode TH butlon. new (alton) §
7 deat "ok"
Cormmand proc 4 p mycheck value, focif 9
pack ( ‘side! steht (pada! => (0 » _ to)
/
iW
@ scanned with OKEN Scanner<3 *ahe Mwommand* option has a objec "proc, which will be called
when cauback $f.
wate he obfed poet patced ate™ Hock auocated lth the
method call,
Binding event :
3 when widgeb ane Infroduced fo the ute many ewent may octuy
Whe 3 they gek clicked, the mole moves over dem, ond &C.
“sant ahese events need do be capluaed>
By using widge “Und metad y we can Create a bioding fom
on tvenk pn a parktulas widget fo a blocls of code ,
> example: we have (seated a button widget fray “displays an
“mage, we wank to change the image wher user” modse fe OVOT
Abe button.
Lode!
anequing "IK?
frnage a = ‘spholo drnage « tee { fle Nmage s git’
_ image a = ‘T4 pholp Srnage.. new} Hie Mimage o, gid
b> 1K ButoN -ntw ( Ono} ) do
‘image image 4
Gommanad Yeu7d : 1
pack
bs Bnd ("enker") 4 b> conigtsel image! = > trnageo)}
by bind ("eave") $b- tonfiquee (mage! <> irnaqe 1
“hs main loop.
<> fut we cetaled 9 GIF nage ob] fom the Ble and cotated
a baton is! fy aiplay image 4.”
cothen Vnded the event ‘enter? 0 that we Can display imageg |
wher we move mouse oer dhe button, |
othen we binded event "leave ¥ to display the image 4, when the
mouse eaves he Matton, |
@ scanned with OKEN Scanner©
x |!
Ganuass comnigs widget Implements shucluetd graphic.
A commas Con te utd fo alisploy mo. of Hem Fhe xelandle, civcles,
finer ond 40k»
> Memt may be montpulak ol and cot backs can be auotiated with
‘lerng.
yntax: Tk Canvas. new §
-- shondard option! ~~ --.---
-- ~-whlget -spedgic opfons ~--~
}
de
— thela con be many options for canuae Uke, background, borden
width, highlight color, select back qrund, select foreground and ele |
Scaring 3
A searolle widget Helps 40 see all pasts of anothea widgeh sahose
tontent 7 much laxger than the availante sewten space fo dhow
dhe tontenlt.
3h Seapttbas displays 400 amt, 4né Hout one ts af each end
oh he seoroltert ond the setond 7s at the middle @p poston.
4 dhe Seroilest.
~sto that he position ond size of he Shien ‘indicale which pot hon
dh the doc te visible im the associated window:
Syntore: Th scepile2t new $
oe slandacd option - - - --
weet widget - specific opltons- sae
b
cl ighit ght
thei coe many options for ACsollea the, 4alre focus, highid)
cols y Yep + ovient ond eke.
i
@ scanned with OKEN Scanner