Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Graphics.UI.Gtk
- main :: IO ()
- main = do
- initGUI
- window <- windowNew
- set window [windowTitle:="Operaciones sencillas", containerBorderWidth := 20,
- windowDefaultWidth:=150, windowDefaultHeight:=100]
- table <- tableNew 4 2 True
- containerAdd window table
- label1 <-labelNew (Just "Ingrese un entero positivo:")
- tableAttachDefaults table dataText 0 1 1 2
- button1 <- buttonNewWithLabel "Calcula el factorial"
- tableAttachDefaults table button1 1 2 1 2
- label2 <- labelNew(Just"")
- tableAttachDefaults table button2 0 2 3 4
- onClicked button2 mainQuit
- onClicked button1 (sol dataText label2)
- onDestroy window mainQuit
- widgetShowAll window
- mainGUI
- sol :: Entry -> Label -> IO ()
- sol dT l2 = do
- txt <- entryGetText dT
- labelSetText l2 ("El factorial de "++ txt ++ " es: " ++ (fact txt))
- fact :: String -> String
- fact txt = show (product [1.. (read txt :: Int)])
Advertisement
Add Comment
Please, Sign In to add comment