KBFrame Manual


Creation commands : Delete commands : Display commands :

KBMainFrame,KBSubFrame

Usage:


    mf = KBMainFrame[sm,fm,options];
    sf = KBSubFrame[ss,fs,options];

Where:

Description:

KBMainFrame and KBSubFrame creates a toplevel window with a menu bar and a status line. The first toplevel window should be created with KBMainFrame, and the rest of the toplevel windows with KBSubFrame.

mf can be treated as the name of the toplevel window. For example, mf[Geometry]="+60+40" sets the geometry of the toplevel window.

Example:


FFS;
w = KBMainFrame["FrameTest",f,Title->"Frame Test"];
b = Button[f,Text->"Button"];
TkWait[];

KBFAddMenuButton

Usage:


    mb = KBFAddMenuButton[w, opts];

Where:

Description:

KBFAddMenuButton create a new MenuButton on the menu bar of KBFrame. The new MenuButton is placed between the Edit and Window menu. A Menu associated with it can be created as usual. (See the example below.)

Example:


FFS;
w = KBMainFrame["MenuEx", f, Title->"Menu Example"];
mb = KBFAddMenuButton[w, Text->"Test"];
m = Menu[mb,Add->{
      Button[Text->"Action 1", Command:>Print["1"]],
      Button[Text->"Action 2", Command:>Print["2"]]}];
TkWait[];

KBFComponentFrame

Usage:


    kcf = KBFComponentFrame[f, Add->cmpts, opts]

Where:

Description:

KBFComponentFrame provides simple arrangement of Tk widgets in the main application area. Add option specifies the list of components, which are listed with the available options below.

Component[Grouping/Entry/Button]:
ComponentTextCommandItemsVariableTextWidgetVariableWidgetVariableWidgetOptionNextColumnNumberFormEntryWidthSpinBox
KBFGroupO---O--O---
KBFSeparator-----OO----
KBFTextO--O-OOO---
KBFStringO--OOOOO-OO
KBFNumberO--OOOOOOOO
KBFCursorEntryOO-OOOOOOOO
KBFCheckButtonOO-O-OOO---
KBFRadioButtonOOOOOOOO---
KBFOptionMenuO-OOOOOO---
KBFButtonOO-O-OOO---
KBFTextEditorO--OOOOO---
KBFListBoxO-OOOOOO---
Special Options:
Component[Frame/Hook]:
ComponentAddCommandDeselectCommand TextTabNameInitialTabInitialState WidgetVariableWidgetOptionNextColumn
KBFFrameO------OOO
KBFFrameToggledO--O--OOOO
KBFFrameTabedO----O-OOO
KBFTabOOOOO--OO-
KBFHook-O--------

Example:


FFS;
w = KBMainFrame["CompArr", f, Title->"Arrange Component Test"];
s = "initial string"; n = 1; c = 1; r = 1; o = 1; l = 1;
cf = KBFComponentFrame[f,
  Add->{
    KBFGroup[Text->"Group1"],
    KBFText[Text->"Examples of Component Arrangement"],
    KBFString[Text->"String Input :", Variable:>s],
    KBFNumber[Text->"Number Input :", Variable:>n],
    KBFCheckButton[Text->"Check", Variable:>c],
    KBFRadioButton[Items->{"Radio 1","Radio 2"}, Variable:>r],
    KBFOptionMenu[Items->{"Option 1","Option 2","Option 3"}, Variable:>o],
    KBFListBox[Items->{"List 1","List 2","List 3","List 4"}, Variable:>l],
    KBFSeparator[],
    KBFButton[Text->"Print", Command:>Print[{s,n,c,r,o,l}]]
  }
];
TkWait[];

KBFOptionDialog

Usage:


    r = KBFOptionDialog[Add->cmpts, opts]

Where:

Description:

KBFOptionDialog creates a dialog box and blocks until the user clicks the ok or cancel button. The Add option is the same as in the case of KBFComponentFrame, with an exception that WidgetVariable option is not available now. The contents of the Variable is not changed when the user clicks the cancel button.

Example:


FFS;
w = KBMainFrame["DialogTest", f, Title->"Dialog Box Test"];
b = Button[f, Text->"Option", Command:>ot];
s = "initial string"; n = 1; c = 1; r = 1; o = 1; l = 1;
ot := (rc = KBFOptionDialog[
    Title->"Option Test",
    Add->{
      KBFGroup[Text->"Group1"],
      KBFText[Text->"Examples of Component Arrangement"],
      KBFString[Text->"String Input :", Variable:>s],
      KBFNumber[Text->"Number Input :", Variable:>n],
      KBFCheckButton[Text->"Check", Variable:>c],
      KBFRadioButton[Items->{"Radio 1","Radio 2"}, Variable:>r],
      KBFOptionMenu[Items->{"Option 1","Option 2","Option 3"}, Variable:>o],
      KBFListBox[Items->{"List 1","List 2","List 3","List 4"}, Variable:>l],
      KBFSeparator[],
      KBFButton[Text->"Print", Command:>Print[{s,n,c,r,o,l}]]
    }
  ];
  Print[{rc,s,n,c,r,o,l}];
);
TkWait[];

KBFOpenDialog,KBFSaveDialog

Usage:


    fn = KBFOpenDialog[dir,flt]
    fn = KBFSaveDialog[dir,flt]

Where:

Description:

KBFOpenDialog and KBFSaveDialog create a file selection dialog box. They list the files that match flt and all the directories in dir in its listbox. The return value is the full path name of the selected file or Null if the user pressed the cancel button.

Example:


FFS;
w = KBMainFrame["OpenDialogTest", f, Title->"File Open Dialog Test"];
b = Button[f,Text->"Open",Command:>of[]];

of[] := Module[{fn},
  fn = KBFOpenDialog["/","*"];
  If [fn <=> Null, Print["Open file is "//fn]];
];

TkWait[];

KBFTabFrame

Usage:


    tf = KBFTabFrame[f]
    tab1 = tf@AddTab[label, f1, opts]

Where:

Description:

KBFTabFrame creates an object which is a container of tabbed frames.

Methods:

AddTab[label, f1, opts]
Creates a new tab with a label. The contents of the tabbed frame is created as children of f1. Possible options for opts are: The return value of AddTab is used as an argument for SelectTab.
DisableTab[tab]
Disables a tab tab. tab is a return value of AddTab.
EnableTab[tab]
Enables a tab tab. tab is a return value of AddTab.
SelectTab[tab]
Selects a tab tab. tab is a return value of AddTab.

Example:


FFS;

w = KBMainFrame["tabtest",f,Title->"TabFrame Test"];
tf = KBFTabFrame[f];
tab1 = tf@AddTab["red",f1,Command:>Print["red"],DeselectCommand:>Print["not red"]];
fc1 = Frame[f1,Width->640,Height->240,BG->"red"];
tab2 = tf@AddTab["green",f2];
fc2 = Frame[f2,Width->320,Height->240,BG->"green"];
tab3 = tf@AddTab["blue",f3];
fc3 = Frame[f3,Width->320,Height->480,BG->"blue"];
tf@SelectTab[tab1];

TkWait[];

KBFToggleFrame

Usage:


    tf = KBFToggleFrame[p,f]

Where:

Description:

KBFToggleFrame creates an frame which a user can hide and show. Text option specifies the title of the frame. If InitialState is True, the initial state of the frame is "expanded". The default value of InitialState is False ("collapsed").

Example:


FFS;

w = KBMainFrame["toggleframe",f];
uf = KBFToggleFrame[f,tf,Text->"Toggle",InitialState->True];
b = Button[tf,Text->"exit",Width->20,Command:>Exit[]];

TkWait[];

Close

Usage:


    w[Close]

Where:

Description:

Close the KBSubFrame w.

Example:


FFS;
w = KBMainFrame["CloseTest", f, Title->"Close test"];
ws = KBSubFrame["ClosedFrame", fs, Title->"To be closed"];
Bind[fs,"<Button>",ws[Close]];
TkWait[];

ProgressBar

Usage:


    w[ProgressBar] = p
    w[ProgressBar] = Null

Where:

Description:

The first form displays the progress bar at the right of the status line. The second form disables the progress bar.

Example:


FFS;
w = KBMainFrame["ProgBarTest", f, Title->"Progress Bar Test"];
Bind[f, "<Button-1>", StartProgBar[]];

StartProgBar[] := (
  Do[w[ProgressBar]=p;Pause[0.1],{p,0,1,0.05}];
  w[ProgressBar] = Null;
);

TkWait[];

StatusLine

Usage:


    w[StatusLine] = {d, s}
    w[StatusLine] = s
    w[FreeStatusLine]

Where:

Description:

The first form configures the widget d so that s is displayed when the pointer enters it. This form is intended to be used as a short user guide or information display. The second form displays s in the status line permanently. The third form release the status line locked by the second form.

Example:


FFS;
w = KBMainFrame["StatLineTest", f, Title->"Status Line Test"];
f1 = Frame[f, Width->150, Height->100, Side->"left", BG->"red"];
f2 = Frame[f, Width->150, Height->100, Side->"left", BG->"green"];
f3 = Frame[f, Width->150, Height->100, Side->"left", BG->"blue"];

w[StatusLine] = {f1, "red frame"};
w[StatusLine] = {f2, "green frame"};
w[StatusLine] = {f3, "blue frame"};

TkWait[];

InfoLabel

Usage:


    w[InfoLabel] = {d, s}
    w[InfoLabel] = {d, s, Tags->t}

Where:

Description:

The first form configures the widget d so that s is displayed in a small window when the pointer enters it. The second form displays s when the pointer stops on an item of a canvas with a tag t.

Example:


FFS;
w = KBMainFrame["InfoLabelTest", f, Title->"InfoLabel Test"];
c = Canvas[f,Width->640,Height->300];
c[Create$Rectangle] = {100,100,200,200,Fill->"red",Tag->"red"};
c[Create$Rectangle] = {300,100,400,200,Fill->"green",Tag->"green"};
c[Create$Rectangle] = {500,100,600,200,Fill->"blue",Tag->"blue"};
b = Button[f,Text->"button",Command:>Print["hi,"]];

w[InfoLabel] = {c,"red rectangle",Tags->"red"};
w[InfoLabel] = {c,"green rectangle",Tags->"green"};
w[InfoLabel] = {c,"blue rectangle",Tags->"blue"};
w[InfoLabel] = {b,"prints hi"};

TkWait[];

AboutMessage

Usage:


    w[AboutMessage] = s

Where:

Description:

There are "About ..." menus under Belle Menu and Help MenuButton. It creates a dialog box where s is displayed.

Example:


FFS;
w = KBMainFrame["AboutTest", f, Title->"About Dialog Test"];
w[AboutMessage] = "This Program was developed by Mr. X\nIf you encounter any problem, please call.\n    Day: 5xxx\n    Night: 64-xxxx";
TkWait[];

Send feedback to: Samo Stanic .