Library for GUI programming in Curry (based on Tcl/Tk).
This paper contains a description of the basic ideas
behind this library.
This library is an improved and updated version of the library Tk.
The latter might not be supported in the future.
Version: November 2006
| Exported names: |
Datatypes:
CanvasItem
| Color
| ConfCollection
| ConfItem
| Event
| GuiPort
| MenuItem
| ReconfigureItem
| Style
| Widget
| WidgetRef
Constructors:
Active
| Anchor
| Background
| Bg
| Black
| Blue
| Bold
| BottomAlign
| Brown
| Canvas
| CanvasItems
| CenterAlign
| CheckButton
| CheckInit
| CLine
| Col
| COval
| CPolygon
| CRectangle
| CText
| Cyan
| DefaultEvent
| Entry
| Fg
| Fill
| FillX
| FillY
| Foreground
| Gold
| Gray
| Green
| Handler
| Height
| Italic
| KeyPress
| Label
| LeftAlign
| List
| ListBox
| Magenta
| Matrix
| MButton
| Menu
| MenuButton
| Message
| MMenuButton
| MouseButton1
| MouseButton2
| MouseButton3
| MSeparator
| Navy
| Orange
| Pink
| PlainButton
| Purple
| Red
| RemoveStreamHandler
| Return
| RightAlign
| Row
| Scale
| ScrollH
| ScrollV
| StreamHandler
| TclOption
| Text
| TextEdit
| Tomato
| TopAlign
| Turquoise
| Underline
| Violet
| White
| WidgetConf
| Width
| WRef
| Yellow
Functions:
addCanvas
| addRegionStyle
| appendStyledValue
| appendValue
| Button
| col
| CanvasScroll
| Cmd
| Command
| ConfigButton
| chooseColor
| debugTcl
| exitGUI
| EntryScroll
| focusInput
| getCursorPosition
| getOpenFile
| getOpenFileWithTypes
| getSaveFile
| getSaveFileWithTypes
| getValue
| ListBoxScroll
| matrix
| popup_message
| removeRegionStyle
| row
| runConfigControlledGUI
| runControlledGUI
| runGUI
| runGUIwithParams
| runHandlesControlledGUI
| runInitControlledGUI
| runInitGUI
| runInitGUIwithParams
| runInitHandlesControlledGUI
| runPassiveGUI
| seeText
| setConfig
| setValue
| TextEditScroll
| updateValue
| Summary of exported functions: |
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
| Imported modules: |
| Exported datatypes: |
The port to a GUI is just the stream connection to a GUI where Tcl/Tk communication is done.
Constructors:
The type of possible widgets in a GUI.
Constructors:
:: [ConfItem] -> Widget
PlainButton - a button in a GUI whose event handler is activated
if the user presses the button
:: [ConfItem] -> Widget
Canvas - a canvas to draw pictures containing CanvasItems
:: [ConfItem] -> Widget
CheckButton - a check button: it has value "0" if it is unchecked and
value "1" if it is checked
:: [ConfItem] -> Widget
Entry - an entry widget for entering single lines
:: [ConfItem] -> Widget
Label - a label for showing a text
:: [ConfItem] -> Widget
ListBox - a widget containing a list of items for selection
:: [ConfItem] -> Widget
Message - a message for showing simple string values
:: [ConfItem] -> Widget
MenuButton - a button with a pull-down menu
:: Int -> Int -> [ConfItem] -> Widget
Scale - a scale widget to input values by a slider
:: WidgetRef -> [ConfItem] -> Widget
ScrollH - a horizontal scroll bar
:: WidgetRef -> [ConfItem] -> Widget
ScrollV - a vertical scroll bar
:: [ConfItem] -> Widget
TextEdit - a text editor widget to show and manipulate larger
text paragraphs
:: [ConfCollection] -> [Widget] -> Widget
Row - a horizontal alignment of widgets
:: [ConfCollection] -> [Widget] -> Widget
Col - a vertical alignment of widgets
:: [ConfCollection] -> [[Widget]] -> Widget
Matrix - a 2-dimensional (matrix) alignment of widgets
The data type for possible configurations of a widget.
Constructors:
:: Bool -> ConfItem
Active - define the active state for buttons, entries, etc.
:: String -> ConfItem
Anchor - alignment of information inside a widget where the
argument must be: n, ne, e, se, s, sw, w, nw, or center
:: String -> ConfItem
Background - the background color
:: String -> ConfItem
Foreground - the foreground color
:: Event -> (GuiPort -> IO [ReconfigureItem]) -> ConfItem
Handler - an event handler associated to a widget.
The event handler returns a list of widget
ref/configuration pairs that are applied after the handler
in order to configure GUI widgets
:: Int -> ConfItem
Height - the height of a widget (chars for text, pixels for graphics)
:: String -> ConfItem
CheckInit - initial value for checkbuttons
:: [CanvasItem] -> ConfItem
CanvasItems - list of items contained in a canvas
:: [String] -> ConfItem
List - list of values shown in a listbox
:: [MenuItem] -> ConfItem
Menu - the items of a menu button
:: WidgetRef -> ConfItem
WRef - a reference to this widget
:: String -> ConfItem
Text - an initial text contents
:: Int -> ConfItem
Width - the width of a widget (chars for text, pixels for graphics)
:: ConfItem
Fill - fill widget in both directions
:: ConfItem
FillX - fill widget in horizontal direction
:: ConfItem
FillY - fill widget in vertical direction
:: String -> ConfItem
TclOption - further options in Tcl syntax (unsafe!)
Data type for describing configurations that are applied to a widget or GUI by some event handler.
Constructors:
:: WidgetRef -> ConfItem -> ReconfigureItem
WidgetConf wref conf - reconfigure the widget referred by wref
with configuration item conf
:: Handle -> (Handle -> GuiPort -> IO [ReconfigureItem]) -> ReconfigureItem
StreamHandler hdl handler - add a new handler to the GUI
that processes inputs on an input stream referred by hdl
:: Handle -> ReconfigureItem
RemoveStreamHandler hdl - remove a handler for an input stream
referred by hdl from the GUI (usually used to remove handlers
for closed streams)
The data type of possible events on which handlers can react. This list is still incomplete and might be extended or restructured in future releases of this library.
Constructors:
:: Event
DefaultEvent - the default event of the widget
:: Event
MouseButton1 - left mouse button pressed
:: Event
MouseButton2 - middle mouse button pressed
:: Event
MouseButton3 - right mouse button pressed
:: Event
KeyPress - any key is pressed
:: Event
Return - return key is pressed
The data type for possible configurations of widget collections (e.g., columns, rows).
Constructors:
:: ConfCollection
CenterAlign - centered alignment
:: ConfCollection
LeftAlign - left alignment
:: ConfCollection
RightAlign - right alignment
:: ConfCollection
TopAlign - top alignment
:: ConfCollection
BottomAlign - bottom alignment
The data type for specifying items in a menu.
Constructors:
:: (GuiPort -> IO [ReconfigureItem]) -> String -> MenuItem
MButton - a button with an associated command
and a label string
:: MenuItem
MSeparator - a separator between menu entries
:: String -> [MenuItem] -> MenuItem
MMenuButton - a submenu with a label string
The data type of items in a canvas. The last argument are further options in Tcl/Tk (for testing).
Constructors:
:: [(Int,Int)] -> String -> CanvasItem
:: [(Int,Int)] -> String -> CanvasItem
:: (Int,Int) -> (Int,Int) -> String -> CanvasItem
:: (Int,Int) -> (Int,Int) -> String -> CanvasItem
:: (Int,Int) -> String -> String -> CanvasItem
The (hidden) data type of references to a widget in a GUI window. Note that the constructor WRefLabel will not be exported so that values can only be created inside this module.
Constructors:
The data type of possible text styles.
Constructors:
:: Style
Bold - text in bold font
:: Style
Italic - text in italic font
:: Style
Underline - underline text
:: Color -> Style
Fg - foreground color, i.e., color of the text font
:: Color -> Style
Bg - background color of the text
The data type of possible colors.
Constructors:
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
:: Color
| Exported functions: |
:: [Widget] -> Widget
Horizontal alignment of widgets.
:: [Widget] -> Widget
Vertical alignment of widgets.
:: [[Widget]] -> Widget
Matrix alignment of widgets.
:: Widget -> IO ()
Prints the generated Tcl commands of a main widget (useful for debugging).
:: String -> Widget -> IO GuiPort
IO action to show a Widget in a new GUI window in passive mode, i.e., ignore all GUI events.
Example call: (runPassiveGUI title widget)
title
- the title of the main window containing the widget
widget
- the widget shown in the new window
:: String -> Widget -> IO ()
IO action to run a Widget in a new window.
Example call: (runGUI title widget)
title
- the title of the main window containing the widget
widget
- the widget shown in the new window
:: String -> String -> Widget -> IO ()
IO action to run a Widget in a new window.
Example call: (runGUIwithParams title params widget)
title
- the title of the main window containing the widget
params
- parameter string passed to the initial wish command
widget
- the widget shown in the new window
:: String -> Widget -> (GuiPort -> IO ()) -> IO ()
IO action to run a Widget in a new window. The GUI events are processed after executing an initial action on the GUI.
Example call: (runInitGUI title widget initcmd)
title
- the title of the main GUI window
widget
- the widget shown in the new GUI window
initcmd
- the initial command executed before activating the GUI
:: String -> String -> Widget -> (GuiPort -> IO ()) -> IO ()
IO action to run a Widget in a new window. The GUI events are processed after executing an initial action on the GUI.
Example call: (runInitGUIwithParams title params widget initcmd)
title
- the title of the main GUI window
params
- parameter string passed to the initial wish command
widget
- the widget shown in the new GUI window
initcmd
- the initial command executed before activating the GUI
:: String -> (Widget,a -> GuiPort -> IO ()) -> [a] -> IO ()
Runs a Widget in a new GUI window and process GUI events. In addition, an event handler is provided that process messages received from an external message stream. This operation is useful to run a GUI that should react on user events as well as messages sent to an external port.
Example call: (runControlledGUI title th msgs)
title
- the title of the main window containing the widget
th
- a pair (widget,exth) where widget is the widget shown in the
new window and exth is the event handler for external messages
msgs
- the stream of external messages (usually coming from
an external port)
:: String -> (Widget,a -> GuiPort -> IO [ReconfigureItem]) -> [a] -> IO ()
Runs a Widget in a new GUI window and process GUI events. In addition, an event handler is provided that process messages received from an external message stream. This operation is useful to run a GUI that should react on user events as well as messages sent to an external port.
Example call: (runConfigControlledGUI title th msgs)
title
- the title of the main window containing the widget
th
- a pair (widget,exth) where widget is the widget shown in the
new window and exth is the event handler for external messages
that returns a list of widget reference/configuration pairs
which is applied after the handler in order to configure
some GUI widgets
msgs
- the stream of external messages (usually coming from
an external port)
:: String -> (Widget,a -> GuiPort -> IO ()) -> (GuiPort -> IO ()) -> [a] -> IO ()
Runs a Widget in a new GUI window and process GUI events after executing an initial action on the GUI window. In addition, an event handler is provided that process messages received from an external message stream. This operation is useful to run a GUI that should react on user events as well as messages sent to an external port.
Example call: (runInitControlledGUI title th initcmd msgs)
title
- the title of the main window containing the widget
th
- a pair (widget,exth) where widget is the widget shown in the
new window and exth is the event handler for external messages
initcmd
- the initial command executed before starting the GUI
msgs
- the stream of external messages (usually coming from
an external port)
:: String -> (Widget,[Handle -> GuiPort -> IO ()]) -> [Handle] -> IO ()
Runs a Widget in a new GUI window and process GUI events. In addition, a list of event handlers is provided that process inputs received from a corresponding list of handles to input streams. Thus, if the i-th handle has some data available, the i-th event handler is executed with the i-th handle as a parameter. This operation is useful to run a GUI that should react on inputs provided by other processes, e.g., via sockets.
Example call: (runHandlesControlledGUI title th handles)
title
- the title of the main window containing the widget
th
- a pair (widget,handlers) where widget is the widget shown in the
new window and handlers is a list of event handler for external inputs
handles
- a list of handles to the external input streams for the
corresponding event handlers
:: String -> (Widget,[Handle -> GuiPort -> IO ()]) -> (GuiPort -> IO ()) -> [Handle] -> IO ()
Runs a Widget in a new GUI window and process GUI events after executing an initial action on the GUI window. In addition, a list of event handlers is provided that process inputs received from a corresponding list of handles to input streams. Thus, if the i-th handle has some data available, the i-th event handler is executed with the i-th handle as a parameter. This operation is useful to run a GUI that should react on inputs provided by other processes, e.g., via sockets.
Example call: (runInitHandlesControlledGUI title th initcmd handles)
title
- the title of the main window containing the widget
th
- a pair (widget,handlers) where widget is the widget shown in the
new window and handlers is a list of event handler for external inputs
initcmd
- the initial command executed before starting the GUI
handles
- a list of handles to the external input streams for the
corresponding event handlers
:: WidgetRef -> ConfItem -> GuiPort -> IO ()
Changes the current configuration of a widget (deprecated operation, only included for backward compatibility). Warning: does not work for Command options!
:: GuiPort -> IO ()
An event handler for terminating the GUI.
:: WidgetRef -> GuiPort -> IO String
Gets the (String) value of a variable in a GUI.
:: WidgetRef -> String -> GuiPort -> IO ()
Sets the (String) value of a variable in a GUI.
:: (String -> String) -> WidgetRef -> GuiPort -> IO ()
Updates the (String) value of a variable w.r.t. to an update function.
:: WidgetRef -> String -> GuiPort -> IO ()
Appends a String value to the contents of a TextEdit widget and adjust the view to the end of the TextEdit widget.
:: WidgetRef -> String -> [Style] -> GuiPort -> IO ()
Appends a String value with style tags to the contents of a TextEdit widget
and adjust the view to the end of the TextEdit widget.
Different styles can be combined, e.g., to get bold blue text on a
red background. If Bold, Italic and
Underline are combined, currently all but one of these are
ignored.
This is an experimental function and might be changed in the future.
:: WidgetRef -> (Int,Int) -> (Int,Int) -> Style -> GuiPort -> IO ()
Adds a style value in a region of a TextEdit widget.
The region is specified a start and end position similarly
to getCursorPosition.
Different styles can be combined, e.g., to get bold blue text on a
red background. If Bold, Italic and
Underline are combined, currently all but one of these are
ignored.
This is an experimental function and might be changed in the future.
:: WidgetRef -> (Int,Int) -> (Int,Int) -> Style -> GuiPort -> IO ()
Removes a style value in a region of a TextEdit widget.
The region is specified a start and end position similarly
to getCursorPosition.
This is an experimental function and might be changed in the future.
:: WidgetRef -> GuiPort -> IO (Int,Int)
Get the position (line,column) of the insertion cursor in a TextEdit widget. Lines are numbered from 1 and columns are numbered from 0.
:: WidgetRef -> (Int,Int) -> GuiPort -> IO ()
Adjust the view of a TextEdit widget so that the specified line/column character is visible. Lines are numbered from 1 and columns are numbered from 0.
:: WidgetRef -> GuiPort -> IO ()
Sets the input focus of this GUI to the widget referred by the first argument. This is useful for automatically selecting input entries in an application.
:: WidgetRef -> [CanvasItem] -> GuiPort -> IO ()
Adds a list of canvas items to a canvas referred by the first argument.
:: String -> IO ()
A simple popup message.
:: (GuiPort -> IO ()) -> ConfItem
A simple event handler that can be associated to a widget. The event handler takes a GUI port as parameter in order to read or write values from/into the GUI.
:: (GuiPort -> IO [ReconfigureItem]) -> ConfItem
An event handler that can be associated to a widget. The event handler takes a GUI port as parameter (in order to read or write values from/into the GUI) and returns a list of widget reference/configuration pairs which is applied after the handler in order to configure some GUI widgets.
:: (GuiPort -> IO ()) -> [ConfItem] -> Widget
A button with an associated event handler which is activated if the button is pressed.
:: (GuiPort -> IO [ReconfigureItem]) -> [ConfItem] -> Widget
A button with an associated event handler which is activated if the button is pressed. The event handler is a configuration handler (see Command) that allows the configuration of some widgets.
:: [ConfItem] -> Widget
A text edit widget with vertical and horizontal scrollbars. The argument contains the configuration options for the text edit widget.
:: [ConfItem] -> Widget
A list box widget with vertical and horizontal scrollbars. The argument contains the configuration options for the list box widget.
:: [ConfItem] -> Widget
A canvas widget with vertical and horizontal scrollbars. The argument contains the configuration options for the text edit widget.
:: [ConfItem] -> Widget
An entry widget with a horizontal scrollbar. The argument contains the configuration options for the entry widget.
:: IO String
Pops up a GUI for selecting an existing file. The file with its full path name will be returned (or "" if the user cancels the selection).
:: [(String,String)] -> IO String
Pops up a GUI for selecting an existing file. The parameter is a list of pairs of file types that could be selected. A file type pair consists of a name and an extension for that file type. The file with its full path name will be returned (or "" if the user cancels the selection).
:: IO String
Pops up a GUI for choosing a file to save some data. If the user chooses an existing file, she/he will asked to confirm to overwrite it. The file with its full path name will be returned (or "" if the user cancels the selection).
:: [(String,String)] -> IO String
Pops up a GUI for choosing a file to save some data. The parameter is a list of pairs of file types that could be selected. A file type pair consists of a name and an extension for that file type. If the user chooses an existing file, she/he will asked to confirm to overwrite it. The file with its full path name will be returned (or "" if the user cancels the selection).
:: IO String
Pops up a GUI dialog box to select a color. The name of the color will be returned (or "" if the user cancels the selection).