home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / tcl / xf2.3-p / xf2 / xf2.3 / xftutorial / script.xf / example.scrpt < prev    next >
Encoding:
Text File  |  1993-11-20  |  31.7 KB  |  934 lines

  1. # tutorial
  2. global exampleLast
  3. set exampleLast 27
  4. global exampleLastSectionDone
  5. set exampleLastSectionDone -1
  6.  
  7.  
  8. set exampleName0 {Example}
  9. set exampleText0 {\
  10. You should not do anything in XF. The tutorial handles the
  11. complete dialog with XF. You just have to press the "Next
  12. page" button (boring isn't it :-).
  13.  
  14. In this "simple sample session" we build a small directory
  15. browser. This application allows the user to walk through
  16. the directory tree and to show the contents of files (the
  17. first 50 lines).
  18.  
  19. The basic dialog component will be a menubar at the top
  20. of the main dialog window. The menubar will contain a 
  21. menubutton, that allows the user to refresh the displayed
  22. directory contents and to quit the program.
  23.  
  24. Below this menubar are two labels. One will display the name
  25. of the currently displayed directory. This name will be
  26. updated when the user changes the directory. The second
  27. label contains the name of the currently displayed file.
  28.  
  29. The rest of the main dialog window contains two lists, that
  30. are placed beside each other. The left list contains all
  31. file and directory names of the current directory, and the
  32. right list contains the contents of the currently displayed
  33. file.
  34.  
  35. To change the directory or to display a file, the items of
  36. the left list have a "binding" that performs the appropriate
  37. action when the left mouse button is clicked over them.
  38.  
  39. This was a short survey on the idea of the program we want
  40. to build. Now let's begin...}
  41.  
  42. set exampleCommand0 {\
  43. XFMiscClearInterpreter
  44. global xfConf xfPath
  45. set xfConf(saveInterval) 0
  46. set xfConf(onlyOneWindow) 0
  47. set xfConf(externalEditor) ""
  48. set xfConf(geometry) packer
  49. set xfConf(newPacker) 0
  50. source "$xfPath(src)/xfpacking.tcl"
  51. global curDir
  52. set curDir \[pwd\]
  53. XFEditSetType Frame 0
  54. update idletasks}
  55.  
  56.  
  57. set exampleName1 {Inserting the frames}
  58. set exampleText1 {\
  59. First we insert three frame widgets in the workspace by
  60. double clicking onto the "Frame" item in the left listbox in
  61. the main XF window.
  62.  
  63. The top most frame will contain the menubar, the center
  64. frame will contain the labels to display the current widget
  65. path and the file name, and the bottom most frame will
  66. contain the two listboxes to display the directory and the
  67. file contents.}
  68.  
  69. set exampleCommand1 {\
  70. .xfEdit.frame2.additional.additional select clear
  71. .xfEdit.frame2.template.template select clear
  72. .xfEdit.frame2.standard.standard select clear
  73. .xfEdit.frame2.standard.standard select from 4
  74. .xfEdit.frame2.standard.standard select to 4
  75. update idletasks
  76. .xfEdit.frame5.addDefault configure -relief sunken
  77. update idletasks
  78. .xfEdit.frame5.addDefault configure -state active
  79. update idletasks
  80. .xfEdit.frame5.addDefault invoke
  81. update idletasks
  82. .xfEdit.frame5.addDefault invoke
  83. update idletasks
  84. .xfEdit.frame5.addDefault invoke
  85. update idletasks
  86. .xfEdit.frame5.addDefault configure -state normal
  87. update idletasks
  88. .xfEdit.frame5.addDefault configure -relief raised
  89. update idletasks}
  90.  
  91.  
  92. set exampleName2 {Resizing the workspace}
  93. set exampleText2 {\
  94. Now we set the size of the workspace to fit the needs of the
  95. application. This can be done either by directly setting the
  96. size with the window manager or by setting the size
  97. parameters for the toplevel window.}
  98.  
  99. set exampleCommand2 {\
  100. wm geometry . 450x250
  101. update idletasks}
  102.  
  103.  
  104. set exampleName3 {Inserting the menubutton}
  105. set exampleText3 {\
  106. The next step is to select the top most frame as current
  107. widget. To select the top most frame you can double click
  108. the middle mouse button over the widget, or you select the
  109. widget from the pull down menu that is attached to the
  110. widget path displayed in the main edit window of XF.
  111.  
  112. Now the menubutton is inserted by double clicking over the
  113. menubutton item in the "standard" list of the XF main
  114. window. This menubutton will contain two items. One item to
  115. refresh the currently displayed directory and one item to
  116. quit the application.}
  117.  
  118. set exampleCommand3 {\
  119. XFEditSetPath .frame0
  120. XFEditSetType Menubutton 0
  121. .xfEdit.frame2.additional.additional select clear
  122. .xfEdit.frame2.template.template select clear
  123. .xfEdit.frame2.standard.standard select clear
  124. .xfEdit.frame2.standard.standard select from 8
  125. .xfEdit.frame2.standard.standard select to 8
  126. update idletasks
  127. .xfEdit.frame5.addDefault configure -state active
  128. update idletasks
  129. .xfEdit.frame5.addDefault configure -relief sunken
  130. update idletasks
  131. .xfEdit.frame5.addDefault invoke
  132. update idletasks
  133. .xfEdit.frame5.addDefault configure -state normal
  134. update idletasks
  135. .xfEdit.frame5.addDefault configure -relief raised
  136. update idletasks}
  137.  
  138.  
  139. set exampleName4 {Inserting the label}
  140. set exampleText4 {\
  141. After inserting the menubutton, the center frame is selected
  142. as the current widget, and the label widget that displays
  143. the currently displayed directory path is inserted. After
  144. that a second label is inserted for the file name of the
  145. displayed file. Selecting and inserting are done as
  146. described before.}
  147.  
  148. set exampleCommand4 {\
  149. XFEditSetPath .frame1
  150. XFEditSetType Label 0
  151. .xfEdit.frame2.additional.additional select clear
  152. .xfEdit.frame2.template.template select clear
  153. .xfEdit.frame2.standard.standard select clear
  154. .xfEdit.frame2.standard.standard select from 5
  155. .xfEdit.frame2.standard.standard select to 5
  156. update idletasks
  157. .xfEdit.frame5.addDefault configure -state active
  158. update idletasks
  159. .xfEdit.frame5.addDefault configure -relief sunken
  160. update idletasks
  161. .xfEdit.frame5.addDefault invoke
  162. update idletasks
  163. .xfEdit.frame5.addDefault configure -state normal
  164. update idletasks
  165. .xfEdit.frame5.addDefault configure -relief raised
  166. update idletasks
  167. .xfEdit.frame5.addDefault configure -state active
  168. update idletasks
  169. .xfEdit.frame5.addDefault configure -relief sunken
  170. update idletasks
  171. .xfEdit.frame5.addDefault invoke
  172. update idletasks
  173. .xfEdit.frame5.addDefault configure -state normal
  174. update idletasks
  175. .xfEdit.frame5.addDefault configure -relief raised
  176. update idletasks}
  177.  
  178.  
  179. set exampleName5 {Inserting the listboxes}
  180. set exampleText5 {\
  181. Now we insert the two listboxes that contain the contents of
  182. the directory and the contents of the selected file. We
  183. insert the template "ListboxLS" by double clicking onto the
  184. "Combined" item in the "templates" list. This opens the
  185. subdirectory, where the template "ListboxLS" is selected.
  186. This is a listbox that already has two scrollbars, so that
  187. we don't have to deal with the handling of listboxes and
  188. scrollbars.}
  189.  
  190. set exampleCommand5 {\
  191. XFEditSetPath .frame2
  192. XFEditSetType Combined 2
  193. .xfEdit.frame2.additional.additional select clear
  194. .xfEdit.frame2.template.template select clear
  195. .xfEdit.frame2.standard.standard select clear
  196. .xfEdit.frame2.template.template select from 0
  197. .xfEdit.frame2.template.template select to 0
  198. update idletasks
  199. XFEditInsertTmplt Combined/
  200. update idletasks
  201. XFEditSetType ListboxS 2
  202. .xfEdit.frame2.template.template select from 9
  203. .xfEdit.frame2.template.template select to 9
  204. update idletasks
  205. XFEditInsertTmplt ListboxLS
  206. update idletasks
  207. XFEditInsertTmplt ListboxLS
  208. update idletasks}
  209.  
  210.  
  211. set exampleName6 {Layouting the widgets}
  212. set exampleText6 {\
  213. After we have inserted all widgets we currently want to
  214. insert into the application, we now can layout the window.
  215. To do this we first make the toplevel window the current
  216. window. Now we call the packing window for this widget from
  217. the "Configuration" menu.
  218.  
  219. By activating the packing window, the first child widget of
  220. the packed widget is flashed.  The packing window contains
  221. all packer options in the upper part of the window. The
  222. lower part of the window contains two lists.
  223.  
  224. The left list contains all children of the current toplevel
  225. window. Here you can select the widget for which you want to
  226. pack the children. The right list contains all packed
  227. children of the current widget. Here you can select the
  228. widget you want to pack.}
  229.  
  230. set exampleCommand6 {\
  231. XFEditSetPath .
  232. .xfEdit.frame1.configMenu.m post [winfo rootx .xfEdit.frame1.configMenu] [expr [winfo rooty .xfEdit.frame1.configMenu]+[winfo height .xfEdit.frame1.configMenu]]
  233. update idletasks
  234. .xfEdit.frame1.configMenu.m activate 0
  235. update idletasks
  236. .xfEdit.frame1.configMenu.m activate 2
  237. update idletasks
  238. .xfEdit.frame1.configMenu.m invoke 2
  239. update idletasks
  240. .xfEdit.frame1.configMenu.m unpost
  241. update idletasks}
  242.  
  243.  
  244. set exampleName7 {Layouting the menubar}
  245. set exampleText7 {\
  246. After selecting the first frame in the "children" list, we
  247. specify that this frame fills the complete width of the
  248. space he gets from the packer by selecting the "fillx"
  249. option.}
  250.  
  251. set exampleCommand7 {\
  252. .xfPackingToplevel.frame2.children.childs.childs select from 0
  253. .xfPackingToplevel.frame2.children.childs.childs select to 0
  254. XFPackingGetPacking . Toplevel
  255. update idletasks
  256. .xfPackingToplevel.frame2.fill.fillx configure -state active
  257. update idletasks
  258. .xfPackingToplevel.frame2.fill.fillx configure -relief sunken
  259. update idletasks
  260. .xfPackingToplevel.frame2.fill.fillx invoke
  261. update idletasks
  262. .xfPackingToplevel.frame2.fill.fillx configure -state normal
  263. update idletasks
  264. .xfPackingToplevel.frame2.fill.fillx configure -relief raised
  265. update idletasks}
  266.  
  267.  
  268. set exampleName8 {Layouting the directory label}
  269. set exampleText8 {\
  270. Now the second frame is selected and gets the same
  271. parameters as the first frame. The frame fills the complete
  272. width of the space he gets from the packer, too.}
  273.  
  274. set exampleCommand8 {\
  275. .xfPackingToplevel.frame2.children.childs.childs select from 1
  276. .xfPackingToplevel.frame2.children.childs.childs select to 1
  277. XFPackingGetPacking . Toplevel
  278. update idletasks
  279. .xfPackingToplevel.frame2.fill.fillx configure -state active
  280. update idletasks
  281. .xfPackingToplevel.frame2.fill.fillx configure -relief sunken
  282. update idletasks
  283. .xfPackingToplevel.frame2.fill.fillx invoke
  284. update idletasks
  285. .xfPackingToplevel.frame2.fill.fillx configure -state normal
  286. update idletasks
  287. .xfPackingToplevel.frame2.fill.fillx configure -relief raised
  288. update idletasks}
  289.  
  290.  
  291. set exampleName9 {Layouting the display area}
  292. set exampleText9 {\
  293. After selecting the third frame (the bottom frame), this
  294. frame is set to fill the complete remaining space (width and
  295. height) of the window.  This is done by selecting "fillx",
  296. "filly" and "expand". This means the widget is expanded to
  297. use the remaining space, and it fills this space.}
  298.  
  299. set exampleCommand9 {\
  300. .xfPackingToplevel.frame2.children.childs.childs select from 2
  301. .xfPackingToplevel.frame2.children.childs.childs select to 2
  302. XFPackingGetPacking . Toplevel
  303. update idletasks
  304. .xfPackingToplevel.frame2.fill.fillx configure -state active
  305. update idletasks
  306. .xfPackingToplevel.frame2.fill.fillx configure -relief sunken
  307. update idletasks
  308. .xfPackingToplevel.frame2.fill.fillx invoke
  309. update idletasks
  310. .xfPackingToplevel.frame2.fill.fillx configure -state normal
  311. update idletasks
  312. .xfPackingToplevel.frame2.fill.fillx configure -relief raised
  313. update idletasks
  314. .xfPackingToplevel.frame2.fill.filly configure -state active
  315. update idletasks
  316. .xfPackingToplevel.frame2.fill.filly configure -relief sunken
  317. update idletasks
  318. .xfPackingToplevel.frame2.fill.filly invoke
  319. update idletasks
  320. .xfPackingToplevel.frame2.fill.filly configure -state normal
  321. update idletasks
  322. .xfPackingToplevel.frame2.fill.filly configure -relief raised
  323. update idletasks
  324. .xfPackingToplevel.frame2.expand.expand configure -state active
  325. update idletasks
  326. .xfPackingToplevel.frame2.expand.expand configure -relief sunken
  327. update idletasks
  328. .xfPackingToplevel.frame2.expand.expand invoke
  329. update idletasks
  330. .xfPackingToplevel.frame2.expand.expand configure -state normal
  331. update idletasks
  332. .xfPackingToplevel.frame2.expand.expand configure -relief raised
  333. update idletasks}
  334.  
  335.  
  336. set exampleName10 {Layouting children of the menubar}
  337. set exampleText10 {\
  338. Now we select the top most frame as packing master.  To do
  339. this you select the frame (.frame0) in the left list of the
  340. packing window with a double click. You see that the
  341. "children" list changes and now displays the children of our
  342. menubar. By clicking on the "left" option, the menubutton is
  343. displayed at the left side of the frame.}
  344.  
  345. set exampleCommand10 {\
  346. .xfPackingToplevel.frame2.children.widgets.widgets select from 13
  347. .xfPackingToplevel.frame2.children.widgets.widgets select to 13
  348. update idletasks
  349. XFPackingMakeMaster .frame0 config Toplevel
  350. update idletasks
  351. .xfPackingToplevel.frame2.children.childs.childs select from 0
  352. .xfPackingToplevel.frame2.children.childs.childs select to 0
  353. update idletasks
  354. XFPackingGetPacking .frame0 Toplevel
  355. update idletasks
  356. .xfPackingToplevel.frame2.side.left configure -state active
  357. update idletasks
  358. .xfPackingToplevel.frame2.side.left configure -relief sunken
  359. update idletasks
  360. .xfPackingToplevel.frame2.side.left invoke
  361. update idletasks
  362. .xfPackingToplevel.frame2.side.left configure -state normal
  363. update idletasks
  364. .xfPackingToplevel.frame2.side.left configure -relief raised
  365. update idletasks}
  366.  
  367.  
  368. set exampleName11 {Layouting children of the directory label}
  369. set exampleText11 {\
  370. Now we select the center frame as packing master. The file
  371. name label is selected and placed right. After selecting the
  372. directory label it is placed left and is expanded so that
  373. the complete remaining space is used by the directory
  374. label.}
  375.  
  376. set exampleCommand11 {\
  377. .xfPackingToplevel.frame2.children.widgets.widgets select from 10
  378. .xfPackingToplevel.frame2.children.widgets.widgets select to 10
  379. update idletasks
  380. XFPackingMakeMaster .frame1 config Toplevel
  381. update idletasks
  382. .xfPackingToplevel.frame2.children.childs.childs select from 1
  383. .xfPackingToplevel.frame2.children.childs.childs select to 1
  384. update idletasks
  385. XFPackingGetPacking .frame1 Toplevel
  386. update idletasks
  387. .xfPackingToplevel.frame2.side.right configure -state active
  388. update idletasks
  389. .xfPackingToplevel.frame2.side.right configure -relief sunken
  390. update idletasks
  391. .xfPackingToplevel.frame2.side.right invoke
  392. update idletasks
  393. .xfPackingToplevel.frame2.side.right configure -state normal
  394. update idletasks
  395. .xfPackingToplevel.frame2.side.right configure -relief raised
  396. update idletasks
  397. .xfPackingToplevel.frame2.fill.fillx configure -state active
  398. update idletasks
  399. .xfPackingToplevel.frame2.fill.fillx configure -relief sunken
  400. update idletasks
  401. .xfPackingToplevel.frame2.fill.fillx invoke
  402. update idletasks
  403. .xfPackingToplevel.frame2.fill.fillx configure -state normal
  404. update idletasks
  405. .xfPackingToplevel.frame2.fill.fillx configure -relief raised
  406. update idletasks
  407. .xfPackingToplevel.frame2.children.childs.childs select from 0
  408. .xfPackingToplevel.frame2.children.childs.childs select to 0
  409. update idletasks
  410. XFPackingGetPacking .frame1 Toplevel
  411. update idletasks
  412. .xfPackingToplevel.frame2.side.left configure -state active
  413. update idletasks
  414. .xfPackingToplevel.frame2.side.left configure -relief sunken
  415. update idletasks
  416. .xfPackingToplevel.frame2.side.left invoke
  417. update idletasks
  418. .xfPackingToplevel.frame2.side.left configure -state normal
  419. update idletasks
  420. .xfPackingToplevel.frame2.side.left configure -relief raised
  421. update idletasks
  422. .xfPackingToplevel.frame2.fill.fillx configure -state active
  423. update idletasks
  424. .xfPackingToplevel.frame2.fill.fillx configure -relief sunken
  425. update idletasks
  426. .xfPackingToplevel.frame2.fill.fillx invoke
  427. update idletasks
  428. .xfPackingToplevel.frame2.fill.fillx configure -state normal
  429. update idletasks
  430. .xfPackingToplevel.frame2.fill.fillx configure -relief raised
  431. update idletasks
  432. .xfPackingToplevel.frame2.expand.expand configure -state active
  433. update idletasks
  434. .xfPackingToplevel.frame2.expand.expand configure -relief sunken
  435. update idletasks
  436. .xfPackingToplevel.frame2.expand.expand invoke
  437. update idletasks
  438. .xfPackingToplevel.frame2.expand.expand configure -state normal
  439. update idletasks
  440. .xfPackingToplevel.frame2.expand.expand configure -relief raised
  441. update idletasks}
  442.  
  443.  
  444. set exampleName12 {Layouting children of the display area}
  445. set exampleText12 {\
  446. Now we select the bottom most frame as packing master. The
  447. first list is selected and packed left. The fill options are
  448. already set for both frames. The second list is also packed
  449. left, so that both lists appear one beside the other. The
  450. right list is set to "expand", so it uses the complete
  451. remaining space in the parent.}
  452.  
  453. set exampleCommand12 {\
  454. .xfPackingToplevel.frame2.children.widgets.widgets select from 1
  455. .xfPackingToplevel.frame2.children.widgets.widgets select to 1
  456. update idletasks
  457. XFPackingMakeMaster .frame2 config Toplevel
  458. update idletasks
  459. .xfPackingToplevel.frame2.children.childs.childs select from 0
  460. .xfPackingToplevel.frame2.children.childs.childs select to 0
  461. update idletasks
  462. XFPackingGetPacking .frame2 Toplevel
  463. update idletasks
  464. .xfPackingToplevel.frame2.side.left configure -state active
  465. update idletasks
  466. .xfPackingToplevel.frame2.side.left configure -relief sunken
  467. update idletasks
  468. .xfPackingToplevel.frame2.side.left invoke
  469. update idletasks
  470. .xfPackingToplevel.frame2.side.left configure -state normal
  471. update idletasks
  472. .xfPackingToplevel.frame2.side.left configure -relief raised
  473. update idletasks
  474. .xfPackingToplevel.frame2.children.childs.childs select from 1
  475. .xfPackingToplevel.frame2.children.childs.childs select to 1
  476. update idletasks
  477. XFPackingGetPacking .frame2 Toplevel
  478. update idletasks
  479. .xfPackingToplevel.frame2.side.left configure -state active
  480. update idletasks
  481. .xfPackingToplevel.frame2.side.left configure -relief sunken
  482. update idletasks
  483. .xfPackingToplevel.frame2.side.left invoke
  484. update idletasks
  485. .xfPackingToplevel.frame2.side.left configure -state normal
  486. update idletasks
  487. .xfPackingToplevel.frame2.side.left configure -relief raised
  488. update idletasks
  489. .xfPackingToplevel.frame2.expand.expand configure -state active
  490. update idletasks
  491. .xfPackingToplevel.frame2.expand.expand configure -relief sunken
  492. update idletasks
  493. .xfPackingToplevel.frame2.expand.expand invoke
  494. update idletasks
  495. .xfPackingToplevel.frame2.expand.expand configure -state normal
  496. update idletasks
  497. .xfPackingToplevel.frame2.expand.expand configure -relief raised
  498. update idletasks}
  499.  
  500.  
  501. set exampleName13 {Parameter setting for menubutton}
  502. set exampleText13 {\
  503. The layouting is finished, now we can begin to set the
  504. parameters for the different widgets. First we configure the
  505. menubutton in the menubar. To do this we make the menubar
  506. frame (.frame0) our packing master. Now we press the button
  507. "Child parameters". To call parameter setting directly you
  508. can also double click the right mouse button over the widget
  509. you want to configure.}
  510.  
  511. set exampleCommand13 {\
  512. .xfPackingToplevel.frame2.children.widgets.widgets select from 13
  513. .xfPackingToplevel.frame2.children.widgets.widgets select to 13
  514. update idletasks
  515. XFPackingMakeMaster .frame0 config Toplevel
  516. update idletasks
  517. .xfPackingToplevel.frame2.children.childs.childs select from 0
  518. .xfPackingToplevel.frame2.children.childs.childs select to 0
  519. update idletasks
  520. XFPackingGetPacking .frame0 Toplevel
  521. update idletasks
  522. .xfPackingToplevel.additional.chldparameters configure -state active
  523. update idletasks
  524. .xfPackingToplevel.additional.chldparameters configure -relief sunken
  525. update idletasks
  526. .xfPackingToplevel.additional.chldparameters invoke
  527. update idletasks
  528. .xfPackingToplevel.additional.chldparameters configure -state normal
  529. update idletasks
  530. .xfPackingToplevel.additional.chldparameters configure -relief raised
  531. update idletasks}
  532.  
  533.  
  534. set exampleName14 {Parameter setting for menubutton}
  535. set exampleText14 {\
  536. First the menubutton label is entered, and then the menu
  537. definition is called by pressing the button "Menu".}
  538.  
  539. set exampleCommand14 {\
  540. .xfMenubuttonConfig4.params1.params2.text.text delete 0 end
  541. update idletasks
  542. .xfMenubuttonConfig4.params1.params2.text.text insert end File
  543. update idletasks
  544. .xfMenubuttonConfig4.additional.menu configure -state active
  545. update idletasks
  546. .xfMenubuttonConfig4.additional.menu configure -relief sunken
  547. update idletasks
  548. .xfMenubuttonConfig4.additional.menu invoke
  549. update idletasks
  550. .xfMenubuttonConfig4.additional.menu configure -state normal
  551. update idletasks
  552. .xfMenubuttonConfig4.additional.menu configure -relief raised
  553. update idletasks}
  554.  
  555.  
  556. set exampleName15 {Pull down menu definition}
  557. set exampleText15 {\
  558. Here the label of the menu item is inserted, and then the
  559. command that should be called when the menu item is
  560. selected. After that, you press the button "Insert". You see
  561. that the item is inserted in the list beside the parameters.
  562. The first item we insert will rescan the directory. The
  563. second menu item will quit the program.}
  564.  
  565. set exampleCommand15 {\
  566. global xfStatus
  567. set xfTmpCounter [expr $xfStatus(menuCounter)-1]
  568. XFMiscSetText .xfMenuConfig5$xfTmpCounter.params1.params2.frame1.elements.elem2.command.command TkBroRefresh
  569. update idletasks
  570. .xfMenubuttonConfig4.leave.ok configure -state active
  571. update idletasks
  572. .xfMenubuttonConfig4.leave.ok configure -relief sunken
  573. update idletasks
  574. .xfMenubuttonConfig4.leave.ok invoke
  575. update idletasks
  576. .xfMenuConfig5$xfTmpCounter.params1.params2.frame1.elements.elem2.label.label delete 0 end
  577. update idletasks
  578. .xfMenuConfig5$xfTmpCounter.params1.params2.frame1.elements.elem2.label.label insert end Refresh
  579. update idletasks
  580. .xfMenuConfig5$xfTmpCounter.params1.params2.commands.insert configure -state active
  581. update idletasks
  582. .xfMenuConfig5$xfTmpCounter.params1.params2.commands.insert configure -relief sunken
  583. update idletasks
  584. .xfMenuConfig5$xfTmpCounter.params1.params2.commands.insert invoke
  585. update idletasks
  586. .xfMenuConfig5$xfTmpCounter.params1.params2.commands.insert configure -state normal
  587. update idletasks
  588. .xfMenuConfig5$xfTmpCounter.params1.params2.commands.insert configure -relief raised
  589. update idletasks
  590. XFMiscSetText .xfMenuConfig5$xfTmpCounter.params1.params2.frame1.elements.elem2.command.command "destroy .; exit"
  591. update idletasks
  592. .xfMenuConfig5$xfTmpCounter.params1.params2.frame1.elements.elem2.label.label delete 0 end
  593. update idletasks
  594. .xfMenuConfig5$xfTmpCounter.params1.params2.frame1.elements.elem2.label.label insert end Quit
  595. update idletasks
  596. .xfMenuConfig5$xfTmpCounter.params1.params2.commands.insert configure -state active
  597. update idletasks
  598. .xfMenuConfig5$xfTmpCounter.params1.params2.commands.insert configure -relief sunken
  599. update idletasks
  600. .xfMenuConfig5$xfTmpCounter.params1.params2.commands.insert invoke
  601. update idletasks
  602. .xfMenuConfig5$xfTmpCounter.params1.params2.commands.insert configure -state normal
  603. update idletasks
  604. .xfMenuConfig5$xfTmpCounter.params1.params2.commands.insert configure -relief raised
  605. update idletasks}
  606.  
  607.  
  608. set exampleName16 {Parameter setting for directory label}
  609. set exampleText16 {\
  610. Now we configure the label that displays the directory
  611. name.}
  612.  
  613. set exampleCommand16 {\
  614. global xfStatus
  615. set xfTmpCounter [expr $xfStatus(menuCounter)-1]
  616. .xfMenuConfig5$xfTmpCounter.leave.ok configure -state active
  617. update idletasks
  618. .xfMenuConfig5$xfTmpCounter.leave.ok configure -relief sunken
  619. update idletasks
  620. .xfMenuConfig5$xfTmpCounter.leave.ok invoke
  621. update idletasks
  622. .xfPackingToplevel.frame2.children.widgets.widgets select from 10
  623. .xfPackingToplevel.frame2.children.widgets.widgets select to 10
  624. update idletasks
  625. XFPackingMakeMaster .frame1 config Toplevel
  626. update idletasks
  627. .xfPackingToplevel.frame2.children.childs.childs select from 0
  628. .xfPackingToplevel.frame2.children.childs.childs select to 0
  629. update idletasks
  630. XFPackingGetPacking .frame1 Toplevel
  631. update idletasks
  632. .xfPackingToplevel.additional.chldparameters configure -state active
  633. update idletasks
  634. .xfPackingToplevel.additional.chldparameters configure -relief sunken
  635. update idletasks
  636. .xfPackingToplevel.additional.chldparameters invoke
  637. update idletasks
  638. .xfPackingToplevel.additional.chldparameters configure -state normal
  639. update idletasks
  640. .xfPackingToplevel.additional.chldparameters configure -relief raised
  641. update idletasks}
  642.  
  643.  
  644. set exampleName17 {Parameter setting for directory label}
  645. set exampleText17 {\
  646. Here we just specify, that the path is to be displayed at
  647. the left border of the label. The directory label gets
  648. the symbolic name "dirName" for easy reference in
  649. procedures, and the label is set to "/usr/local...".}
  650.  
  651. set exampleCommand17 {\
  652. .xfLabelConfig4.params1.params2.text.text delete 0 end
  653. update idletasks
  654. .xfLabelConfig4.params1.params2.text.text insert end /usr/local...
  655. update idletasks
  656. .xfLabelConfig4.params1.params2.symname.symname delete 0 end
  657. update idletasks
  658. .xfLabelConfig4.params1.params2.symname.symname insert end dirName
  659. update idletasks}
  660.  
  661.  
  662. set exampleName18 {Remaining parameters}
  663. set exampleText18 {\
  664. Now we can continue with the next parameters. These
  665. parameters are set without showing the dialogs. With this
  666. parameter settings we have set all parameters for now.}
  667.  
  668. set exampleCommand18 {\
  669. .frame1 configure -borderwidth 0
  670. .frame1.label4 configure -anchor w
  671. .frame2 configure -borderwidth 0
  672. .frame2.frame.listbox1 configure -geometry 20x10
  673. XFMiscSetSymbolicName .frame1.label5 fileName
  674. XFMiscSetSymbolicName .frame2.frame.listbox1 dirList
  675. XFMiscSetSymbolicName .frame2.frame6.listbox1 contentsList
  676. update idletasks
  677. .xfLabelConfig4.leave.ok configure -state active
  678. update idletasks
  679. .xfLabelConfig4.leave.ok configure -relief sunken
  680. update idletasks
  681. .xfLabelConfig4.leave.ok invoke
  682. update idletasks
  683. .xfPackingToplevel.frame1.ok configure -state active
  684. update idletasks
  685. .xfPackingToplevel.frame1.ok configure -relief sunken
  686. update idletasks
  687. .xfPackingToplevel.frame1.ok invoke
  688. update idletasks}
  689.  
  690.  
  691. set exampleName19 {Defining actions}
  692. set exampleText19 {\
  693. What we have now is the skeleton of the program.  Now we add
  694. the functionality. This is done by defining procedures.
  695. First we define some code that is executed at the beginning
  696. of the program, directly after all widgets have been
  697. created.  This source is called the end source (it is the
  698. last source that is executed, before flow control is passed
  699. to the main loop). To enter this code select the menu item
  700. "Programming|End source".}
  701.  
  702. set exampleCommand19 {\
  703. .xfEdit.frame1.infoMenu.m post [winfo rootx .xfEdit.frame1.infoMenu] [expr [winfo rooty .xfEdit.frame1.infoMenu]+[winfo height .xfEdit.frame1.infoMenu]]
  704. update idletasks
  705. .xfEdit.frame1.infoMenu.m activate 0
  706. update idletasks
  707. .xfEdit.frame1.infoMenu.m activate 1
  708. update idletasks
  709. .xfEdit.frame1.infoMenu.m activate 2
  710. update idletasks
  711. .xfEdit.frame1.infoMenu.m activate 4
  712. update idletasks
  713. .xfEdit.frame1.infoMenu.m activate 5
  714. update idletasks
  715. .xfEdit.frame1.infoMenu.m activate 6
  716. update idletasks
  717. .xfEdit.frame1.infoMenu.m activate 7
  718. update idletasks
  719. .xfEdit.frame1.infoMenu.m activate 8
  720. update idletasks
  721. .xfEdit.frame1.infoMenu.m invoke 8
  722. update idletasks
  723. .xfEdit.frame1.infoMenu.m unpost
  724. update idletasks}
  725.  
  726.  
  727. set exampleName20 {Defining the end source}
  728. set exampleText20 {\
  729. This source defines a global variable named "curDir" that
  730. contains the current directory name. After that the list
  731. containing the directory is updated to show the contents of
  732. the current directory. To allow testing at this point, it
  733. would be necessary to define the global variable by hand
  734. (with another XF dialog), because this end source is not
  735. evaluated.}
  736.  
  737. set exampleCommand20 {\
  738. XFMiscSetText .xfInfoProc.frame4.text.text "global curDir
  739. set curDir \[pwd\]
  740. TkBroRefresh"
  741. update idletasks}
  742.  
  743.  
  744. set exampleName21 {Procedure handling}
  745. set exampleText21 {\
  746. Now we call the dialog box where the application procedures
  747. can be added/changed etc. This dialog box is activated by
  748. selecting the menu item "Procedures|Programming".}
  749.  
  750. set exampleCommand21 {\
  751. .xfInfoProc.frame1.add configure -state active
  752. update idletasks
  753. .xfInfoProc.frame1.add configure -relief sunken
  754. update idletasks
  755. .xfInfoProc.frame1.add invoke
  756. update idletasks
  757. .xfInfoProc.frame3.ok configure -state active
  758. update idletasks
  759. .xfInfoProc.frame3.ok configure -relief sunken
  760. update idletasks
  761. .xfInfoProc.frame3.ok invoke
  762. update idletasks
  763. .xfEdit.frame1.infoMenu.m post [winfo rootx .xfEdit.frame1.infoMenu] [expr [winfo rooty .xfEdit.frame1.infoMenu]+[winfo height .xfEdit.frame1.infoMenu]]
  764. update idletasks
  765. .xfEdit.frame1.infoMenu.m activate 0
  766. update idletasks
  767. .xfEdit.frame1.infoMenu.m activate 1
  768. update idletasks
  769. .xfEdit.frame1.infoMenu.m invoke 1
  770. update idletasks
  771. .xfEdit.frame1.infoMenu.m unpost
  772. update idletasks}
  773.  
  774.  
  775. set exampleName22 {Defining the refresh procedure}
  776. set exampleText22 {\
  777. Here we can insert the procedure name, the arguments and the
  778. source. In this case this is the source that is called when
  779. the directory is to be read and displayed in the directory
  780. list.}
  781.  
  782. set exampleCommand22 {\
  783. XFMiscSetText .xfInfoProc.frame4.text.text "
  784. global curDir
  785.  
  786. set list \[exec ls -a\]
  787. \[SymbolicName dirList\] delete 0 end
  788. \[SymbolicName contentsList\] delete 0 end
  789. \[SymbolicName dirName\] configure -text \$curDir
  790. \[SymbolicName fileName\] configure -text {}
  791. foreach i \$list {
  792.   \[SymbolicName dirList\] insert end \$i
  793. }
  794. update"
  795. update idletasks
  796. .xfInfoProc.current.current delete 0 end
  797. update idletasks
  798. .xfInfoProc.current.current insert end TkBroRefresh
  799. update idletasks
  800. .xfInfoProc.frame4.args.args delete 0 end
  801. update idletasks}
  802.  
  803.  
  804. set exampleName23 {Defining the refresh procedure}
  805. set exampleText23 {\
  806. Now we insert the procedure by pressing the "Insert"
  807. button.}
  808.  
  809. set exampleCommand23 {\
  810. .xfInfoProc.frame1.add configure -state active
  811. update idletasks
  812. .xfInfoProc.frame1.add configure -relief sunken
  813. update idletasks
  814. .xfInfoProc.frame1.add invoke
  815. update idletasks
  816. .xfInfoProc.frame1.add configure -relief raised
  817. update idletasks}
  818.  
  819.  
  820. set exampleName24 {Adding additional procedures}
  821. set exampleText24 {\
  822. Now we can continue with the next procedures. This
  823. procedures are added without showing the dialogs.  With this
  824. the procedure definition is finished.}
  825.  
  826. set exampleCommand24 {\
  827. proc TkBroOpen {fname} {
  828.   global curDir
  829.  
  830.   if {[file isdirectory $fname]} {
  831.     cd $fname
  832.     set curDir [pwd]
  833.     TkBroRefresh
  834.   } {
  835.     set thisfile [open $fname r]
  836.     [SymbolicName contentsList] delete 0 end
  837.     [SymbolicName fileName] configure -text $fname
  838.     for { set i 1 } { $i<50 } { incr i } {
  839.       [SymbolicName contentsList] insert end [ gets $thisfile ]
  840.     }
  841.     update
  842.     close $thisfile
  843.   }
  844. }
  845. update idletasks
  846. .xfInfoProc.frame3.ok configure -state active
  847. update idletasks
  848. .xfInfoProc.frame3.ok configure -relief sunken
  849. update idletasks
  850. .xfInfoProc.frame3.ok invoke
  851. update idletasks}
  852.  
  853.  
  854. set exampleName25 {List binding}
  855. set exampleText25 {\
  856. To allow directory changing and file displaying it is
  857. necessary to set the binding for the directory listbox items
  858. to the procedure that handles this feature. You call the
  859. binding dialog by selecting the menu item
  860. "Configuration|Binding".}
  861.  
  862. set exampleCommand25 {\
  863. XFEditSetPath [SymbolicName dirList]
  864. .xfEdit.frame1.configMenu.m post [winfo rootx .xfEdit.frame1.configMenu] [expr [winfo rooty .xfEdit.frame1.configMenu]+[winfo height .xfEdit.frame1.configMenu]]
  865. update idletasks
  866. .xfEdit.frame1.configMenu.m activate 0
  867. update idletasks
  868. .xfEdit.frame1.configMenu.m activate 2
  869. update idletasks
  870. .xfEdit.frame1.configMenu.m activate 3
  871. update idletasks
  872. .xfEdit.frame1.configMenu.m activate 4
  873. update idletasks
  874. .xfEdit.frame1.configMenu.m activate 5
  875. update idletasks
  876. .xfEdit.frame1.configMenu.m activate 6
  877. update idletasks
  878. .xfEdit.frame1.configMenu.m invoke 6
  879. update idletasks
  880. .xfEdit.frame1.configMenu.m unpost
  881. update idletasks}
  882.  
  883.  
  884. set exampleName26 {Insert list binding}
  885. set exampleText26 {\
  886. Now we insert the event name we want to add to the list in
  887. the entry field after the "Current event:" label.  This is
  888. the event name that will get the new action.  The procedure
  889. to call when this event is received is inserted in the big
  890. text field at the bottom of the dialog box. The inserted
  891. procedure "TkBroOpen" handles the directory changing and
  892. file showing.}
  893.  
  894. set exampleCommand26 {\
  895. XFMiscSetText .xfBindingListbox.value.value "
  896. TkBroOpen \[%W get \[%W nearest %y\]\]"
  897. update idletasks
  898. .xfBindingListbox.current.current delete 0 end
  899. update idletasks
  900. .xfBindingListbox.current.current insert end <Button-1>
  901. update idletasks
  902. .xfBindingListbox.frame2.insert configure -state active
  903. update idletasks
  904. .xfBindingListbox.frame2.insert configure -relief sunken
  905. update idletasks
  906. .xfBindingListbox.frame2.insert invoke
  907. update idletasks
  908. .xfBindingListbox.frame2.insert configure -state normal
  909. update idletasks
  910. .xfBindingListbox.frame2.insert configure -relief raised
  911. update idletasks}
  912.  
  913.  
  914. set exampleName27 {The end !?}
  915. set exampleText27 {\
  916. Now you would normally save the program... You should try it
  917. :-). To leave the tutorial select the menu item "File|Quit".
  918. If you select the quit item in the applications's file menu,
  919. you will only get a dialog box that says that you would exit
  920. the program.
  921.  
  922. Well that's all for now. I hope the tutorial was helpful for
  923. you... If not send me a mail explaining what you don't
  924. like.}
  925.  
  926. set exampleCommand27 {\
  927. .xfBindingListbox.frame1.ok configure -state active
  928. update idletasks
  929. .xfBindingListbox.frame1.ok configure -relief sunken
  930. update idletasks
  931. .xfBindingListbox.frame1.ok invoke
  932. update idletasks}
  933.  
  934.