Personal tools

LGtk

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
m (fix typos)
(Changelog for 0.5.3)
 
(33 intermediate revisions by one user not shown)
Line 1: Line 1:
== What is it? ==
+
[[Category:User interfaces]]
   
 
LGtk is a lens-based API for Gtk.
 
LGtk is a lens-based API for Gtk.
 
LGtk is built on Gtk2Hs.
 
LGtk is built on Gtk2Hs.
  +
  +
== Introduction ==
   
 
Most Haskellers would like to use a mature FRP-based API for creating graphical user interfaces.
 
Most Haskellers would like to use a mature FRP-based API for creating graphical user interfaces.
Line 8: Line 10:
 
LGtk has a lens-based API which fits better these user interfaces.
 
LGtk has a lens-based API which fits better these user interfaces.
   
== Demo application ==
+
== Internal links ==
   
You can try the demo application with the following commands:
+
* [[LGtk/Semantics]]
+
* [[LGtk/ADT_lenses]]
cabal install gtk2hs-buildtools
 
cabal install lgtk
 
lgtkdemo
 
 
== Features ==
 
 
Features of lgtk-0.5
 
 
* The API is closed, you can safely use any constructs as long as you obey the documented laws.
 
* Support for asynchronous events. Using LGtk is a safe way for writing multithreaded Gtk applications.
 
   
 
== Examples ==
 
== Examples ==
Line 38: Line 40:
   
 
<hask>action</hask> gives acces to a monad in which new references can be made by <hask>newRef</hask>.
 
<hask>action</hask> gives acces to a monad in which new references can be made by <hask>newRef</hask>.
A crutial feature of LGtk is that you cannot change the value of references in this monad (you can read them though).
+
A crucial feature of LGtk is that you cannot change the value of references in this monad (you can read them though).
   
 
<hask>label</hask> gives acces to a monad in which you can read references but no reference creation or write is possible.
 
<hask>label</hask> gives acces to a monad in which you can read references but no reference creation or write is possible.
Line 53: Line 55:
 
[ entryShow r1
 
[ entryShow r1
 
, entryShow r2
 
, entryShow r2
, label $ liftM2 (+) (readRef r1) (readRef r2)
+
, label $ liftM show $ liftM2 (+) (readRef r1) (readRef r2)
 
]
 
]
 
</haskell>
 
</haskell>
Line 59: Line 61:
 
=== Complex examples ===
 
=== Complex examples ===
   
You can find a more complex examples in the source code of LGtk.
+
You can find more complex examples in the source code of LGtk.
 
More examples will be presented here also.
 
More examples will be presented here also.
   
Line 66: Line 68:
 
== Status ==
 
== Status ==
   
LGtk is actively developed. The semantics is getting stable but it is not yet documented.
+
Features of lgtk-0.5
  +
  +
* The API is closed, you can safely use any constructs as far as you obey the documented laws.
  +
* Support for asynchronous events. Using LGtk is a safe way for writing multithreaded Gtk applications.
  +
* The semantics is getting stable but it is not yet documented.
   
 
TODO list:
 
TODO list:
Line 74: Line 76:
 
* Support more Gtk constructs.
 
* Support more Gtk constructs.
   
  +
  +
== Demo application ==
  +
  +
You can try the demo application with the following commands:
  +
  +
cabal install gtk2hs-buildtools
  +
cabal install lgtk
  +
lgtkdemo
   
 
== Changelog ==
 
== Changelog ==
  +
  +
=== lgtk-0.5.3 ===
  +
  +
* bugfix: handle focus out events for entries
  +
* bugfix: run postponed actions at widget initialization
  +
  +
=== lgtk-0.5.2 ===
  +
  +
* Better support for references with equality
  +
* Documentation fixes and cleanup
  +
* Inner change: safer state handling with MVars
  +
  +
=== lgtk-0.5.1 ===
  +
  +
* Documentation fixes and cleanup
  +
* Try to support Haskell Platform 2012.4.0.0
   
 
=== lgtk-0.5 ===
 
=== lgtk-0.5 ===
Line 88: Line 114:
 
* More examples in the demo application.
 
* More examples in the demo application.
 
* Lots of inner changes.
 
* Lots of inner changes.
 
   
 
== External links ==
 
== External links ==
   
* You can find the current API documentation [http://hackage.haskell.org/package/lgtk at HackageDB].
+
* [http://hackage.haskell.org/package/lgtk API documentation at HackageDB]
* There is [http://hub.darcs.net/divip/lgtk a darcs repo on hub.darcs.net].
+
* [http://hub.darcs.net/divip/lgtk Darcs repo on hub.darcs.net]
  +
* [http://people.inf.elte.hu/divip/LGtk/LGtk.html Initial announcement]
  +
  +
Related Stackoverflow questions:
  +
  +
* [http://stackoverflow.com/questions/16123588/what-is-this-special-functor-structure-called What is this special functor structure called?]
  +
* [http://stackoverflow.com/questions/16769579/howto-abort-getchar-safely Howto abort getChar safely?]
  +
  +
Reddit comments:
  +
  +
* [http://www.reddit.com/r/haskell/comments/1cemr2/lgtk_lensbased_gtk_interface/ 15 April]
  +
* [http://www.reddit.com/r/haskell/comments/1cj0o6/lgtk_api_fixed/ 17 April]
  +
* [http://www.reddit.com/r/haskell/comments/1f5m5j/ann_lgtk_05/ 27 May]
  +
* [http://www.reddit.com/r/haskell/comments/1fjerf/lens_chains_lgtk_semantics_first_part/ 2 June]

Latest revision as of 21:24, 15 June 2013


LGtk is a lens-based API for Gtk. LGtk is built on Gtk2Hs.

Contents

[edit] 1 Introduction

Most Haskellers would like to use a mature FRP-based API for creating graphical user interfaces. FRP may not be the best tool for special user interfaces, like interfaces which consists of buttons, checkboxes, combo boxes, text entries and menus only. LGtk has a lens-based API which fits better these user interfaces.

[edit] 2 Internal links

[edit] 3 Examples

[edit] 3.1 Hello World

main = runWidget $ label $ return "Hello World!"
return
is neded because labels may be dynamic, see the next examples.

[edit] 3.2 Copy

The following applications presents an entry and a label below of it. When a text is entered in the entry, the label is changed to the entered text.

main = runWidget $ action $ do
   r <- newRef "enter text here"
   return $ vcat
       [ entry r
       , label $ readRef r
       ]
action
gives acces to a monad in which new references can be made by
newRef
.

A crucial feature of LGtk is that you cannot change the value of references in this monad (you can read them though).

label
gives acces to a monad in which you can read references but no reference creation or write is possible.

[edit] 3.3 Addition

Two entries of integers and a label which shows the sum:

main = runWidget $ action $ do
   r1 <- newRef (12 :: Integer)
   r2 <- newRef 4
   return $ vcat
       [ entryShow r1
       , entryShow r2
       , label $ liftM show $ liftM2 (+) (readRef r1) (readRef r2)
       ]

[edit] 3.4 Complex examples

You can find more complex examples in the source code of LGtk. More examples will be presented here also.

Lgtkdemo.png

[edit] 4 Status

Features of lgtk-0.5

  • The API is closed, you can safely use any constructs as far as you obey the documented laws.
  • Support for asynchronous events. Using LGtk is a safe way for writing multithreaded Gtk applications.
  • The semantics is getting stable but it is not yet documented.

TODO list:

  • Add an efficient implementation for LGtk. LGtk has only a reference implementation currently.
  • Add support for styles (layout, colors, etc).
  • Support more Gtk constructs.


[edit] 5 Demo application

You can try the demo application with the following commands:

cabal install gtk2hs-buildtools
cabal install lgtk
lgtkdemo

[edit] 6 Changelog

[edit] 6.1 lgtk-0.5.3

  • bugfix: handle focus out events for entries
  • bugfix: run postponed actions at widget initialization

[edit] 6.2 lgtk-0.5.2

  • Better support for references with equality
  • Documentation fixes and cleanup
  • Inner change: safer state handling with MVars

[edit] 6.3 lgtk-0.5.1

  • Documentation fixes and cleanup
  • Try to support Haskell Platform 2012.4.0.0

[edit] 6.4 lgtk-0.5

  • Do not use monadic lenses any more.
  • Support for asynchronous events.
  • Lazily created tabs.
  • Unactive tabs are really unactive (event handlers are detached).
  • File references watch the files. When the file changes, the GUI is updated.
  • References with inherent identity (makes defining auto-sensitive buttons easier)
  • Experimental support for colored buttons.
  • More examples in the demo application.
  • Lots of inner changes.

[edit] 7 External links

Related Stackoverflow questions:

Reddit comments: