我正在cabal install glib-0.12.3使用cabal-install 0.10.2在我的Ubuntu 11.10下尝试.但是,它显示以下错误消息:
setup: The program gtk2hsC2hs version >=0.13.5 is required but the version
found at /usr/bin/gtk2hsC2hs is version 0.13.4
cabal: Error: some packages failed to install:
glib-0.12.3 failed during the configure step. The exception was:
ExitFailure 1
Run Code Online (Sandbox Code Playgroud)
经过半个小时的搜索,我无法找到它的gtk2hsC2hs位置.我挖到像http://code.haskell.org/gtk2hs/tools/c2hs/这样的地方,但似乎找不到合适的版本.
我怎么能升级我的gtk2hsC2hs?谢谢!
我用gtk2hs,Glade和Haskell制作了一个GUI应用程序.它运行在Windows XP上正常,但用户需要来运行它来安装GTK +,gtk2hs(它要求libglade的-2.0.0.dll)和GHC(因为它是一个gtk2hs依赖).
我自己就是Windows n00b,但是如何从用户的角度简化安装我的小GUI?有没有办法用所需的.dll包装它?我怎样才能最好地找出需要哪些.dll?什么是好习惯?
非常感谢,Jarra
我正在编写一个具有单击并拖动功能的Haskell程序,因此每次鼠标移动事件都会向窗口绘制更新.目前我正在使用
renderWithDrawable myCanvas update
Run Code Online (Sandbox Code Playgroud)
然而,这很多都是闪烁的.我的理解是我需要创建一个单独的drawable(一个"表面"?),渲染到它,然后在一次操作中将它blit到屏幕窗口.但是我对这种方法的正确方法感到困惑.
我发现drawWindowBeginPaintRegion,它谈到消除闪烁.但是根据Haddock文档,它在Gtk3中删除了.所以我不确定我是否应该使用它,因为它似乎已被弃用.
我也在renderWithSimilarSurface开罗找到了,它似乎做了类似的事情.
我也不确定这些函数是如何关联的renderWithDrawable:我是否必须在函数内部使用它们,或者什么?
这样做的正确方法是什么?
编辑
这在开罗似乎是一个众所周知的事情.我正在试图弄清楚如何在Haskell中处理这个问题.
试图学习用Gtk2Hs编写应用程序我遇到了困难,弥合了事件驱动的Gtk2HS与模型的持久状态之间的差距.所以为了简化,让我说我有这个简单的应用程序
module Main where
import Graphics.UI.Gtk
import Control.Monad.State
main = do
initGUI
window <- windowNew
button <- buttonNew
set button [buttonLabel := "Press me"]
containerAdd window button
-- Events
onDestroy window mainQuit
onClicked button (putStrLn ---PUT MEANINGFUL CODE HERE---)
widgetShowAll window
mainGUI
Run Code Online (Sandbox Code Playgroud)
我的应用程序的状态是按下按钮的次数.看到像这样的其他帖子,他们依赖于MVars或IORefs,这对我来说似乎并不令人满意,因为将来也许我会想要重构代码,以便状态存在于自己的上下文中.
我认为解决方案应该使用状态monad使用步骤函数,如:
State $ \s -> ((),s+1)
Run Code Online (Sandbox Code Playgroud)
但我不确定其含义,如何在上面的代码中执行此操作,或者即使该monad是我的问题的正确解决方案.
我正在开始一个有希望使用gtk2hs的新项目.但是,我无法在我相当典型的Linux机器上安装此软件包.这是失败:
[1 of 2] Compiling SetupWrapper ( /tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs, /tmp/cairo-0.12.4-4201/cairo-0.12.4/dist/dist-sandbox-58b5f9c6/setup/SetupWrapper.o )
/tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs:94:45:
Ambiguous occurrence `moreRecentFile'
It could refer to either `SetupWrapper.moreRecentFile',
defined at /tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs:149:1
or `Distribution.Simple.Utils.moreRecentFile',
imported from `Distribution.Simple.Utils' at /tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs:8:1-32
/tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs:95:45:
Ambiguous occurrence `moreRecentFile'
It could refer to either `SetupWrapper.moreRecentFile',
defined at /tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs:149:1
or `Distribution.Simple.Utils.moreRecentFile',
imported from `Distribution.Simple.Utils' at /tmp/cairo-0.12.4-4201/cairo-0.12.4/SetupWrapper.hs:8:1-32
Failed to install cairo-0.12.4
[1 of 2] Compiling SetupWrapper ( /tmp/glib-0.12.4-4201/glib-0.12.4/SetupWrapper.hs, /tmp/glib-0.12.4-4201/glib-0.12.4/dist/dist-sandbox-58b5f9c6/setup/SetupWrapper.o )
/tmp/glib-0.12.4-4201/glib-0.12.4/SetupWrapper.hs:94:45:
Ambiguous occurrence `moreRecentFile'
It could refer to either `SetupWrapper.moreRecentFile',
defined at /tmp/glib-0.12.4-4201/glib-0.12.4/SetupWrapper.hs:149:1
or `Distribution.Simple.Utils.moreRecentFile',
imported from …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作玩具应用程序,以便了解如何在Haskell中编写事件驱动程序.我要做的是在画布上绘制一条线,每次按下一个键时向前移动(所以它在文本编辑器中是一种原始光标).
我的问题是我无法确定用户按下按键的次数的最佳方法.显然,我不能像在命令式程序中那样使用全局变量,所以我可能需要在调用堆栈上传递状态,但是在每个事件处理程序返回后,GTK执行会进入主循环,因为我不会控制主循环我不知道如何从一个事件处理程序传递更改的全局状态.那么一个事件处理程序如何将状态传递给另一个事件处理程序?
我在这里有一种部分解决方案,其中键盘事件重新调整myDraw,并将其设置为新的事件处理程序.我不确定这个解决方案是否可以扩展,或者即使这是一个好主意.
什么是这个问题的最佳粒子解决方案?
import Graphics.UI.Gtk
import Graphics.Rendering.Cairo
main :: IO ()
main= do
initGUI
window <- windowNew
set window [windowTitle := "Hello World",
windowDefaultWidth := 300, windowDefaultHeight := 200]
canvas <- drawingAreaNew
containerAdd window canvas
widgetShowAll window
draWin <- widgetGetDrawWindow canvas
canvas `on` exposeEvent $ do liftIO $ renderWithDrawable draWin (myDraw 10)
return False
window `on` keyPressEvent $ onKeyboard canvas
window `on` destroyEvent $ do liftIO mainQuit
return False
mainGUI
onKeyboard :: DrawingArea -> EventM EKey Bool
onKeyboard canvas …Run Code Online (Sandbox Code Playgroud) 我正在尝试在haskell中创建我的第一个"真实程序"(如果多项式可以解决积分问题),但我完全被这部分内容所困扰:
我想做一些非常简单的东西,比如GHCi:
> user input
program output
> user input
program output
> user input
program output
>
Run Code Online (Sandbox Code Playgroud)
除了我的程序输出是图像(使用LaTeX将数学表达式转换成PNG) - 所以我不能使用System.IO这样做.我认为有可能用gtk2hs我已经设法安装但我无法弄清楚如何进行输入/输出对话.
如果你有时间,请告诉我它是如何完成的.非常感谢!
我不确定我是否应该打个招呼,这是我在这里发表的第一篇文章.
无论如何,我正在关注gtk2hs网站的glade教程.代码编译正确,但是当我尝试执行它时,我得到了这个错误.
(hellogtk2hs:8670): libglade-WARNING **: Expected <glade-interface>. Got <interface>.
(hellogtk2hs:8670): libglade-WARNING **: did not finish in PARSER_FINISH state
hellogtk2hs: user error (Pattern match failure in do expression at HelloGtk2Hs.hs:8:8-15)
Run Code Online (Sandbox Code Playgroud)
这是我的林间文件.
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="window1">
<property name="can_focus">False</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Write your name here: </property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property …Run Code Online (Sandbox Code Playgroud) 我正在使用Haskell的gtk2hs库编写一个小的GUI应用程序,目前正在使用其中的多行文本框.我有一个函数,我想在用户对文本框中的文本进行更改时运行,但不希望他们必须单击按钮来激活它.
此外,因为它是一个相当侵入性和处理密集型的功能(它绘制图形,加载文件等),我希望它不会在用户进行任何更改时触发(这可能是通过文本缓冲区中的bufferChanged信号完成的)猜猜?但是当他们在两次变化之间停了几秒钟.