Module "Tk.curry"

Library for GUI programming in Curry (based on Tcl/Tk). This paper contains a description of the basic ideas behind this library.

Version: November 2004


 Exported names:

Datatypes:
TkCanvasItem | TkConfCollection | TkConfItem | TkMenuItem | TkRefType | TkWidget

Constructors:
TkActive | TkAnchor | TkBackground | TkBottom | TkCanvas | TkCenter | TkCheckButton | TkCol | TkCText | TkEntry | TkFill | TkFillX | TkFillY | TkForeground | TkHandler | TkHeight | TkInit | TkItems | TkLabel | TkLeft | TkLine | TkList | TkListBox | TkMatrix | TkMButton | TkMenu | TkMenuButton | TkMessage | TkMMenuButton | TkMSeparator | TkOval | TkPlainButton | TkPolygon | TkRectangle | TkRef | TkRight | TkRow | TkScale | TkScrollH | TkScrollV | TkTcl | TkText | TkTextEdit | TkTop | TkWidth

Functions:
debugTcl | forkWish | openWish | popup_message | runConfigControlledWidget | runControlledWidget | runControlledWidgetInit | runControlledWidgetOnPort | runWidget | runWidgetInit | runWidgetOnPort | runWidgetOnPortInit | runWidgetPassive | tkAddCanvas | tkAppendTaggedValue | tkAppendValue | tkCAddCanvas | tkCConfig | tkCExit | tkCFocus | tkCGetValue | tkConfig | tkCSetValue | tkCUpdate | tkCVoid | tkExit | tkFocus | tkGetValue | tkSetValue | tkUpdate | tkVoid | TkButton | TkCanvasScroll | TkCmd | TkConfigButton | TkConfigCmd | TkEntryScroll | TkTextEditScroll | tkChooseColor | tkGetOpenFile | tkGetOpenFileWithTypes | tkGetSaveFile | tkGetSaveFileWithTypes


 Summary of exported functions:

debugTcl  :: TkWidget a -> IO ()  deterministic 
          
forkWish  :: String -> String -> IO ()  deterministic 
          Initializes Tcl/Tk with some tcl text and ignores wish output.
openWish  :: String -> IO (Port SP_Msg)  deterministic 
          Creates a new GUI window with a "title" for the top-level window (but unspecified contents).
runWidget  :: String -> TkWidget (IO ()) -> IO ()  deterministic 
          IO action to run a TkWidget in a new GUI window.
runWidgetInit  :: String -> TkWidget (IO ()) -> (Port SP_Msg -> IO ()) -> IO ()  deterministic 
          IO action to run a TkWidget in a new GUI window.
runWidgetPassive  :: String -> TkWidget a -> IO (Port SP_Msg)  deterministic 
          IO action to show a TkWidget in a new GUI window in passive mode, i.e., ignore all GUI events.
runControlledWidget  :: String -> (TkWidget (IO ()),a -> Port SP_Msg -> IO ()) -> [a] -> IO ()  deterministic flexible
          Runs a TkWidget in a new GUI window and process GUI events.
runConfigControlledWidget  :: String -> (TkWidget (IO ()),a -> Port SP_Msg -> IO [(TkRefType,TkConfItem (IO ()))]) -> [a] -> IO ()  deterministic flexible
          Runs a TkWidget in a new GUI window and process GUI events.
runControlledWidgetInit  :: String -> (TkWidget (IO ()),a -> Port SP_Msg -> IO ()) -> (Port SP_Msg -> IO ()) -> [a] -> IO ()  deterministic flexible
          Runs a TkWidget in a new GUI window and process GUI events after executing an initial comment on the GUI window.
runWidgetOnPort  :: TkWidget Success -> Port SP_Msg -> Success  deterministic 
          Runs a TkWidget on a GUI window that was previously created by the operation "openWish".
runControlledWidgetOnPort  :: (TkWidget Success,a -> Port SP_Msg -> Success) -> [a] -> Port SP_Msg -> Success  deterministic flexible
          Runs a TkWidget on a GUI window that was previously created by the operation "openWish".
runWidgetOnPortInit  :: TkWidget Success -> Port SP_Msg -> (Port SP_Msg -> Success) -> Success  deterministic 
          Runs a TkWidget on a GUI window that was previously created by the operation "openWish".
tkConfig  :: TkRefType -> TkConfItem a -> Port SP_Msg -> IO ()  deterministic flexible
          Changes the current configuration of a widget (deprecated operation, only included for backward compatibility).
tkCConfig  :: TkRefType -> TkConfItem a -> Port SP_Msg -> Success  deterministic flexible
          Changes the current configuration of a widget (deprecated operation, only included for backward compatibility).
tkVoid  :: Port SP_Msg -> IO ()  deterministic 
          An event handler that does nothing.
tkExit  :: Port SP_Msg -> IO ()  deterministic 
          An event handler for terminating the GUI.
tkGetValue  :: TkRefType -> Port SP_Msg -> IO String  deterministic flexible
          Gets the (String) value of a variable in a GUI.
tkSetValue  :: TkRefType -> String -> Port SP_Msg -> IO ()  deterministic flexible
          Sets the (String) value of a variable in a GUI.
tkUpdate  :: (String -> String) -> TkRefType -> Port SP_Msg -> IO ()  deterministic 
          Updates the (String) value of a variable w.r.t.
tkAppendValue  :: TkRefType -> String -> Port SP_Msg -> IO ()  deterministic flexible+rigid
          Appends a String value to the contents of a TextEdit widget and adjust the view to the end of the TextEdit widget.
tkAppendTaggedValue  :: TkRefType -> String -> String -> Port SP_Msg -> IO ()  deterministic flexible+rigid
          This is an experimental function and might be changed in the future.
tkFocus  :: TkRefType -> Port SP_Msg -> IO ()  deterministic flexible
          Sets the input focus of this GUI to the widget referred by the first argument.
tkAddCanvas  :: TkRefType -> [TkCanvasItem] -> Port SP_Msg -> IO ()  deterministic flexible
          Adds a list of canvas items to a canvas referred by the first argument.
tkCVoid  :: Port SP_Msg -> Success  deterministic 
          An event handler that does nothing.
tkCExit  :: Port SP_Msg -> Success  deterministic 
          An event handler for terminating the GUI.
tkCGetValue  :: TkRefType -> Port SP_Msg -> String -> Success  deterministic flexible
          Gets the (String) value of a variable in a GUI.
tkCSetValue  :: TkRefType -> String -> Port SP_Msg -> Success  deterministic flexible
          Sets the (String) value of a variable in a GUI.
tkCUpdate  :: (String -> String) -> TkRefType -> Port SP_Msg -> Success  deterministic 
          Updates the (String) value of a variable w.r.t.
tkCFocus  :: TkRefType -> Port SP_Msg -> Success  deterministic flexible
          Sets the input focus of this GUI to the widget referred by the first argument.
tkCAddCanvas  :: TkRefType -> [TkCanvasItem] -> Port SP_Msg -> Success  deterministic flexible
          Adds a list of canvas items to a canvas referred by the first argument.
popup_message  :: String -> IO ()  deterministic 
          A simple popup message.
TkCmd  :: (Port SP_Msg -> a) -> TkConfItem a  deterministic 
          A simple event handler that can be associated to a widget.
TkConfigCmd  :: (Port SP_Msg -> IO [(TkRefType,TkConfItem (IO ()))]) -> TkConfItem (IO ())  deterministic 
          An event handler that can be associated to a widget.
TkButton  :: (Port SP_Msg -> a) -> [TkConfItem a] -> TkWidget a  deterministic 
          A button with an associated event handler which is activated if the button is pressed.
TkConfigButton  :: (Port SP_Msg -> IO [(TkRefType,TkConfItem (IO ()))]) -> [TkConfItem (IO ())] -> TkWidget (IO ())  deterministic 
          A button with an associated event handler which is activated if the button is pressed.
TkTextEditScroll  :: [TkConfItem a] -> TkWidget a  deterministic 
          A text edit widget with vertical and horizontal scrollbars.
TkCanvasScroll  :: [TkConfItem a] -> TkWidget a  deterministic 
          A canvas widget with vertical and horizontal scrollbars.
TkEntryScroll  :: [TkConfItem a] -> TkWidget a  deterministic 
          An entry widget with a horizontal scrollbar.
tkGetOpenFile  :: IO String  deterministic 
          Pops up a GUI for selecting an existing file.
tkGetOpenFileWithTypes  :: [(String,String)] -> IO String  deterministic 
          Pops up a GUI for selecting an existing file.
tkGetSaveFile  :: IO String  deterministic 
          Pops up a GUI for choosing a file to save some data.
tkGetSaveFileWithTypes  :: [(String,String)] -> IO String  deterministic 
          Pops up a GUI for choosing a file to save some data.
tkChooseColor  :: IO String  deterministic 
          Pops up a GUI dialog box to select a color.

 Imported modules:

Ports
Prelude
Read
Unsafe

 Exported datatypes:

TkWidget

The type of possible widgets in a GUI. "a" is the result type of event handlers, currently "IO ()" or "Success".

Constructors:

TkPlainButton :: [TkConfItem a] -> TkWidget a
TkCanvas :: [TkConfItem a] -> TkWidget a
TkCheckButton :: [TkConfItem a] -> TkWidget a
TkEntry :: [TkConfItem a] -> TkWidget a
TkLabel :: [TkConfItem a] -> TkWidget a
TkListBox :: [TkConfItem a] -> TkWidget a
TkMessage :: [TkConfItem a] -> TkWidget a
TkMenuButton :: [TkConfItem a] -> TkWidget a
TkScale :: Int -> Int -> [TkConfItem a] -> TkWidget a
TkScrollV :: TkRefType -> [TkConfItem a] -> TkWidget a
TkScrollH :: TkRefType -> [TkConfItem a] -> TkWidget a
TkTextEdit :: [TkConfItem a] -> TkWidget a
TkRow :: [TkConfCollection] -> [TkWidget a] -> TkWidget a
TkCol :: [TkConfCollection] -> [TkWidget a] -> TkWidget a
TkMatrix :: [TkConfCollection] -> [[TkWidget a]] -> TkWidget a


TkConfItem

The data type for possible configurations of a widget.

Constructors:

TkActive :: Bool -> TkConfItem a
TkAnchor :: String -> TkConfItem a
TkBackground :: String -> TkConfItem a
TkForeground :: String -> TkConfItem a
TkHandler :: ([(TkRefType,TkConfItem a)] -> Port SP_Msg -> a) -> TkConfItem a
TkHeight :: Int -> TkConfItem a
TkInit :: String -> TkConfItem a
TkItems :: [TkCanvasItem] -> TkConfItem a
TkList :: [String] -> TkConfItem a
TkMenu :: [TkMenuItem a] -> TkConfItem a
TkRef :: TkRefType -> TkConfItem a
TkText :: String -> TkConfItem a
TkWidth :: Int -> TkConfItem a
TkFill :: TkConfItem a
TkFillX :: TkConfItem a
TkFillY :: TkConfItem a
TkTcl :: String -> TkConfItem a


TkConfCollection

The data type for possible configurations of a collection of widgets.

Constructors:

TkCenter :: TkConfCollection
TkLeft :: TkConfCollection
TkRight :: TkConfCollection
TkTop :: TkConfCollection
TkBottom :: TkConfCollection


TkMenuItem

The data type for specifying items in a menu.

Constructors:

TkMButton :: (Port SP_Msg -> a) -> String -> TkMenuItem a
TkMSeparator :: TkMenuItem a
TkMMenuButton :: String -> [TkMenuItem a] -> TkMenuItem a


TkCanvasItem

The data type of items in a canvas. The last argument are further options in Tcl/Tk (for testing).

Constructors:

TkLine :: [(Int,Int)] -> String -> TkCanvasItem
TkPolygon :: [(Int,Int)] -> String -> TkCanvasItem
TkRectangle :: (Int,Int) -> (Int,Int) -> String -> TkCanvasItem
TkOval :: (Int,Int) -> (Int,Int) -> String -> TkCanvasItem
TkCText :: (Int,Int) -> String -> String -> TkCanvasItem


TkRefType

The (hidden) data type of references to a widget in a Tk window. Note that the constructor TkRefLabel will not be exported so that values can only be created inside this module.

Constructors:



 Exported functions:

debugTcl :: TkWidget a -> IO ()  deterministic 


forkWish :: String -> String -> IO ()  deterministic 

Initializes Tcl/Tk with some tcl text and ignores wish output.

Further infos:
  • might behave indeterministically

openWish :: String -> IO (Port SP_Msg)  deterministic 

Creates a new GUI window with a "title" for the top-level window (but unspecified contents). A GUI port is returned that can be used to start a GUI specification on this port (by the operations runWidgetOnPort, runWidgetOnPortInit, or runControlledWidgetOnPort).

Further infos:
  • might behave indeterministically

runWidget :: String -> TkWidget (IO ()) -> IO ()  deterministic 

IO action to run a TkWidget in a new GUI window.

Example call:  (runWidget title tkw)

Parameters:
title - the title of the main window containing the widget
tkw - the widget shown in the new window
Further infos:
  • might behave indeterministically

runWidgetInit :: String -> TkWidget (IO ()) -> (Port SP_Msg -> IO ()) -> IO ()  deterministic 

IO action to run a TkWidget in a new GUI window. The GUI events are processed after executing an initial action on the GUI.

Example call:  (runWidgetInit title tkw initcmd)

Parameters:
title - the title of the main GUI window
tkw - the widget shown in the new GUI window
initcmd - the initial command executed before activating the GUI
Further infos:
  • might behave indeterministically

runWidgetPassive :: String -> TkWidget a -> IO (Port SP_Msg)  deterministic 

IO action to show a TkWidget in a new GUI window in passive mode, i.e., ignore all GUI events.

Example call:  (runWidgetPassive title tkw)

Parameters:
title - the title of the main window containing the widget
tkw - the widget shown in the new window
Further infos:
  • might behave indeterministically

runControlledWidget :: String -> (TkWidget (IO ()),a -> Port SP_Msg -> IO ()) -> [a] -> IO ()  deterministic flexible

Runs a TkWidget 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:  (runControlledWidget title th msgs)

Parameters:
title - the title of the main window containing the widget
th - a pair (tkw,exth) where tkw 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)
Further infos:
  • might behave indeterministically

runConfigControlledWidget :: String -> (TkWidget (IO ()),a -> Port SP_Msg -> IO [(TkRefType,TkConfItem (IO ()))]) -> [a] -> IO ()  deterministic flexible

Runs a TkWidget 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:  (runConfigControlledWidget title th msgs)

Parameters:
title - the title of the main window containing the widget
th - a pair (tkw,exth) where tkw 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)
Further infos:
  • might behave indeterministically

runControlledWidgetInit :: String -> (TkWidget (IO ()),a -> Port SP_Msg -> IO ()) -> (Port SP_Msg -> IO ()) -> [a] -> IO ()  deterministic flexible

Runs a TkWidget in a new GUI window and process GUI events after executing an initial comment 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:  (runControlledWidgetInit title th initcmd msgs)

Parameters:
title - the title of the main window containing the widget
th - a pair (tkw,exth) where tkw 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)
Further infos:
  • might behave indeterministically

runWidgetOnPort :: TkWidget Success -> Port SP_Msg -> Success  deterministic 

Runs a TkWidget on a GUI window that was previously created by the operation "openWish". This is useful to execute a GUI in parallel to other concurrent processes.

Example call:  (runWidgetOnPort tkw wport)

Parameters:
tkw - the widget shown in the new window
wport - the wish port for the GUI
Further infos:
  • might behave indeterministically

runControlledWidgetOnPort :: (TkWidget Success,a -> Port SP_Msg -> Success) -> [a] -> Port SP_Msg -> Success  deterministic flexible

Runs a TkWidget on a GUI window that was previously created by the operation "openWish". This is useful to execute a GUI in parallel to other concurrent processes. In addition, an event handler is provided that process messages received from an external message stream. Thus, one can run a GUI that should react on user events as well as messages sent to an external port.

Example call:  (runControlledWidgetOnPort th msgs wport)

Parameters:
th - a pair (tkw,exth) where tkw 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)
wport - the wish port for the GUI
Further infos:
  • might behave indeterministically

runWidgetOnPortInit :: TkWidget Success -> Port SP_Msg -> (Port SP_Msg -> Success) -> Success  deterministic 

Runs a TkWidget on a GUI window that was previously created by the operation "openWish". This is useful to execute a GUI in parallel to other concurrent processes. The GUI is actually started after executing an initial command for the GUI.

Example call:  (runWidgetOnPortInit tkw wport initcmd)

Parameters:
tkw - the widget shown in the new GUI window
wport - the wish port for the GUI
initcmd - the initial command executed before starting the GUI
Further infos:
  • might behave indeterministically

tkConfig :: TkRefType -> TkConfItem a -> Port SP_Msg -> IO ()  deterministic flexible

Changes the current configuration of a widget (deprecated operation, only included for backward compatibility). Warning: does not work for TkCmd options!

Further infos:
  • might behave indeterministically

tkCConfig :: TkRefType -> TkConfItem a -> Port SP_Msg -> Success  deterministic flexible

Changes the current configuration of a widget (deprecated operation, only included for backward compatibility). Warning: does not work for TkCmd options!

Further infos:
  • might behave indeterministically

tkVoid :: Port SP_Msg -> IO ()  deterministic 

An event handler that does nothing.

Further infos:
  • solution complete, i.e., able to compute all solutions

tkExit :: Port SP_Msg -> IO ()  deterministic 

An event handler for terminating the GUI.

Further infos:
  • might behave indeterministically

tkGetValue :: TkRefType -> Port SP_Msg -> IO String  deterministic flexible

Gets the (String) value of a variable in a GUI.

Further infos:
  • might behave indeterministically

tkSetValue :: TkRefType -> String -> Port SP_Msg -> IO ()  deterministic flexible

Sets the (String) value of a variable in a GUI.

Further infos:
  • might behave indeterministically

tkUpdate :: (String -> String) -> TkRefType -> Port SP_Msg -> IO ()  deterministic 

Updates the (String) value of a variable w.r.t. to an update function.

Further infos:
  • might behave indeterministically

tkAppendValue :: TkRefType -> String -> Port SP_Msg -> IO ()  deterministic flexible+rigid

Appends a String value to the contents of a TextEdit widget and adjust the view to the end of the TextEdit widget.

Further infos:
  • might behave indeterministically

tkAppendTaggedValue :: TkRefType -> String -> String -> Port SP_Msg -> IO ()  deterministic flexible+rigid

This is an experimental function and might be changed in the future. Appends a String value with tags to the contents of a TextEdit widget and adjust the view to the end of the TextEdit widget.

Further infos:
  • might behave indeterministically

tkFocus :: TkRefType -> Port SP_Msg -> IO ()  deterministic flexible

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.

Further infos:
  • might behave indeterministically

tkAddCanvas :: TkRefType -> [TkCanvasItem] -> Port SP_Msg -> IO ()  deterministic flexible

Adds a list of canvas items to a canvas referred by the first argument.

Further infos:
  • might behave indeterministically

tkCVoid :: Port SP_Msg -> Success  deterministic 

An event handler that does nothing.

Further infos:
  • solution complete, i.e., able to compute all solutions

tkCExit :: Port SP_Msg -> Success  deterministic 

An event handler for terminating the GUI.

Further infos:
  • might behave indeterministically

tkCGetValue :: TkRefType -> Port SP_Msg -> String -> Success  deterministic flexible

Gets the (String) value of a variable in a GUI.

Further infos:
  • might behave indeterministically

tkCSetValue :: TkRefType -> String -> Port SP_Msg -> Success  deterministic flexible

Sets the (String) value of a variable in a GUI.

Further infos:
  • might behave indeterministically

tkCUpdate :: (String -> String) -> TkRefType -> Port SP_Msg -> Success  deterministic 

Updates the (String) value of a variable w.r.t. to an update function.

Further infos:
  • might behave indeterministically

tkCFocus :: TkRefType -> Port SP_Msg -> Success  deterministic flexible

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.

Further infos:
  • might behave indeterministically

tkCAddCanvas :: TkRefType -> [TkCanvasItem] -> Port SP_Msg -> Success  deterministic flexible

Adds a list of canvas items to a canvas referred by the first argument.

Further infos:
  • might behave indeterministically

popup_message :: String -> IO ()  deterministic 

A simple popup message.

Further infos:
  • might behave indeterministically

TkCmd :: (Port SP_Msg -> a) -> TkConfItem a  deterministic 

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.


TkConfigCmd :: (Port SP_Msg -> IO [(TkRefType,TkConfItem (IO ()))]) -> TkConfItem (IO ())  deterministic 

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.


TkButton :: (Port SP_Msg -> a) -> [TkConfItem a] -> TkWidget a  deterministic 

A button with an associated event handler which is activated if the button is pressed.


TkConfigButton :: (Port SP_Msg -> IO [(TkRefType,TkConfItem (IO ()))]) -> [TkConfItem (IO ())] -> TkWidget (IO ())  deterministic 

A button with an associated event handler which is activated if the button is pressed. The event handler is a configuration handler (see TkConfigCmd) that allows the configuration of some widgets.


TkTextEditScroll :: [TkConfItem a] -> TkWidget a  deterministic 

A text edit widget with vertical and horizontal scrollbars. The argument contains the configuration options for the text edit widget.

Further infos:
  • solution complete, i.e., able to compute all solutions

TkCanvasScroll :: [TkConfItem a] -> TkWidget a  deterministic 

A canvas widget with vertical and horizontal scrollbars. The argument contains the configuration options for the text edit widget.

Further infos:
  • solution complete, i.e., able to compute all solutions

TkEntryScroll :: [TkConfItem a] -> TkWidget a  deterministic 

An entry widget with a horizontal scrollbar. The argument contains the configuration options for the entry widget.

Further infos:
  • solution complete, i.e., able to compute all solutions

tkGetOpenFile :: IO String  deterministic 

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).

Further infos:
  • might behave indeterministically

tkGetOpenFileWithTypes :: [(String,String)] -> IO String  deterministic 

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).

Further infos:
  • might behave indeterministically

tkGetSaveFile :: IO String  deterministic 

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).

Further infos:
  • might behave indeterministically

tkGetSaveFileWithTypes :: [(String,String)] -> IO String  deterministic 

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).

Further infos:
  • might behave indeterministically

tkChooseColor :: IO String  deterministic 

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).

Further infos:
  • might behave indeterministically


Generated by CurryDoc (Version 0.4.1 of June 7, 2007) at Aug 28 15:30:12 2008