KBFrame Manual
Creation commands :
Delete commands :
Display commands :
Usage:
mf = KBMainFrame[sm,fm,options];
sf = KBSubFrame[ss,fs,options];
Where:
- sm is a unique character string that identifies the application
and the main frame.
- ss is a character string that identifies the sub frame.
- fm,fs is a frame where widgets can be put.
- options are passed to the toplevel window.
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[];
Usage:
mb = KBFAddMenuButton[w, opts];
Where:
- mb is the symbol under which the MenuButton is created.
- w is a KBFrame.
- opts are passed to the new MenuButton.
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[];
Usage:
kcf = KBFComponentFrame[f, Add->cmpts, opts]
Where:
- kcf is the symbol under which the components are created.
- f is the parent widget.
- cmpts is the list of the components.
- opts is passed to the enclosing frame of
KBFComponentFrame.
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]:
Component | Text | Command | Items | Variable | TextWidgetVariable | WidgetVariable | WidgetOption | NextColumn | NumberForm | EntryWidth | SpinBox |
KBFGroup | O | - | - | - | O | - | - | O | - | - | - |
KBFSeparator | - | - | - | - | - | O | O | - | - | - | - |
KBFText | O | - | - | O | - | O | O | O | - | - | - |
KBFString | O | - | - | O | O | O | O | O | - | O | O |
KBFNumber | O | - | - | O | O | O | O | O | O | O | O |
KBFCursorEntry | O | O | - | O | O | O | O | O | O | O | O |
KBFCheckButton | O | O | - | O | - | O | O | O | - | - | - |
KBFRadioButton | O | O | O | O | O | O | O | O | - | - | - |
KBFOptionMenu | O | - | O | O | O | O | O | O | - | - | - |
KBFButton | O | O | - | O | - | O | O | O | - | - | - |
KBFTextEditor | O | - | - | O | O | O | O | O | - | - | - |
KBFListBox | O | - | O | O | O | O | O | O | - | - | - |
- Text option
The label string assiciated with the component.
- Command option
The function invoked when the button is pressed.
- Items option
The list of selections.
- Variable option
The variable to store values of input string, number or selection.
- TextWidgetVariable option
The label widget (e.g. TextLabel for KBFString) is created with this variable.
- WidgetVariable option
The main widget (e.g. Entry for KBFString) is created with this variable.
- WidgetOption option
The list of options to be passed to the main widget.
- NextColumn option
If True, this component is placed at the top of the next column.
- NumberForm option
The output form for KBFNumber/KBFCursorEntry.
The default number form can be changed by DefaultNumberForm option.
- EntryWidth option
The width of the entry box.
The default width can be changed by DefaultEntryWidth option.
- SpinBox option(KBFNumber/KBFString/KBFCursorEntry)
If True, this component appear with spin button(upward/downward).
In KBFNumber/KBFString component,
if spin button pushd, the function binded by Command option was invoked
with $Event global variable.
In the $Event variable, the spin button direction is reported
by the rule Direction->"up" or Direction->"down".
Special Options:
- KBFCheckButton/KBFRadioButton
- InitialIndex option
The initial number of variable index.
- KBFCursorEntry
- CursorPosition option
The initial cursor position is at
nth column from left (when n>0),
or -nth column from right (when n<0)
The default position can be changed by DefaultCursorPosition option.
Note: DefaultPosition option
is available only for backword compatibility.
DO NOT use DefaultPosition option
for new programming.(Use CursorPosition option instead)
- Range option
The range of variable.
The default width can be changed by DefaultRange option.
- Factor option
The magnification for display.
Component[Frame/Hook]:
Component | Add | Command | DeselectCommand |
Text | TabName | InitialTab | InitialState |
WidgetVariable | WidgetOption | NextColumn |
KBFFrame | O | - | - | - | - | - | - | O | O | O |
KBFFrameToggled | O | - | - | O | - | - | O | O | O | O |
KBFFrameTabed | O | - | - | - | - | O | - | O | O | O |
KBFTab | O | O | O | O | O | - | - | O | O | - |
KBFHook | - | O | - | - | - | - | - | - | - | - |
- Add option
The list of componets to create on this widget.
- Command option
KBFTab: The function invoked when the tab is selected.
KBFHook: The function invoked when KBFComponentFrame is created.
- DeselectCommand option
The function invoked when the tab is deselected.
- Text option
KBFFrameToggled: The label string assiciated with the component.
KBFTab: The tab name string assiciated with the component.
- TabName option
The tab name string assiciated with the component.
- InitialTab option
The initial tab name or number to be selected.
- InitialState option
The initial statue of toggle frame.
- WidgetVariable option
The main widget (e.g. Entry for KBFString) is created with this variable.
- WidgetOption option
The list of options to be passed to the main widget.
- NextColumn option
If True, this component is placed at the top of the next column.
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[];
Usage:
r = KBFOptionDialog[Add->cmpts, opts]
Where:
- r is 0 when the user pressed the cancel button, 1
when ok button is pressed.
- cmpts is the list of the components.
- opts is other options. Currently only Title option
is allowed.
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[];
Usage:
fn = KBFOpenDialog[dir,flt]
fn = KBFSaveDialog[dir,flt]
Where:
- fn is the returned file name.
- dir is the initial directory.
- flt is the filter for selecting what to display in the list.
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[];
Usage:
tf = KBFTabFrame[f]
tab1 = tf@AddTab[label, f1, opts]
Where:
- tf is the symbol under which the container of tabbed frames is
created.
- f is the parent widget.
- label is a string used as the label of the new tab.
- f1 is a frame where widgets can be put.
- opts is options to AddTab, which include
Command, DeselectCommand and Expand.
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:
- Command specifies the expression executed when the tab is
selected.
- DeselectCommand specifies the expression executed when another
tab is selected and this tab is hidden.
- When Expand is True, this tabbed frame expands to the
size of KBFTabFrame.
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[];
Usage:
tf = KBFToggleFrame[p,f]
Where:
- tf is the symbol under which the container of
KBFToggleFrame is created.
- p is the parent widget.
- f is a frame where widgets can be put.
- opts is options, which include InitialState and
Text.
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[];
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[];
Usage:
w[ProgressBar] = p
w[ProgressBar] = Null
Where:
- w is a KBFrame.
- p is a Real number between 0 and 1.
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[];
Usage:
w[StatusLine] = {d, s}
w[StatusLine] = s
w[FreeStatusLine]
Where:
- w is a KBFrame.
- d is a widget.
- s is a string to be displayed in the status line.
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[];
Usage:
w[InfoLabel] = {d, s}
w[InfoLabel] = {d, s, Tags->t}
Where:
- w is a KBFrame.
- d is a widget.
- s is a string to be displayed in the status line.
- t is a tag of an item.
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[];
Usage:
w[AboutMessage] = s
Where:
- w is a KBFrame.
- s is a string displayed in the "About" dialog box.
Description:
There are "About ..." menus under
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
.