gtk2hs

Drawing text on GTK's DrawingArea in Haskell

被刻印的时光 ゝ 提交于 2020-01-06 02:41:15
问题 I have a DrawingArea onto which I can draw using primitives such as drawRectangle and drawLine . How do I draw text onto that area? I'm most interested in something that quickly outputs a single line of text. Graphics.UI.Gtk.Gdk.Drawable.layoutLine seems to be what I want, but it wants a Graphics.Rendering.Pango.Layout.LayoutLine as input. How do I construct that LayoutLine ? Are there better alternatives than doing it this way? Thanks! 回答1: I don't know if you would consider using Cairo. If

Could someone explain gtk2hs drag and drop to me, the listDND.hs demo just isn't doing it for me?

旧巷老猫 提交于 2019-12-24 15:19:29
问题 As the title says, I just don't get DND (or rather I understand the concept and I understand the order of callbacks, I just don't understand how to setup DND for actual usage.) I'd like to say that I've done DND stuff before in C, but considering I never really got that working... So I'm trying (and mostly succeeding, save DND) to write a text editor (using gtksourceview, because it has built in code highlighting.) Reasons are below if you want them. Anyways, there's not really a good DND

gtksourceview2: implement completion provider

纵饮孤独 提交于 2019-12-23 18:44:59
问题 The documentation states about SourceCompletionProvider : You must implement this interface to provide proposals to SourceCompletion What does "implement this interface" means in the context? Should I create new GObject using this functions? Any example?. When I have new GObject , then how can I add functions (like sourceCompletionProviderGetName ) to it? Thanks 回答1: gtk+ is written in C, however it uses glib to provide an object-oriented style interface. Much of the gtk+ API is defined using

Can't use a glade xml file with haskell

久未见 提交于 2019-12-20 23:26:20
问题 I'm not sure if I should say hi or not, being this my first post here. Anyway, I am following the glade tutorial from the gtk2hs website. The code compiled properly but when I try to execute it I get this error. (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) This is my glade file. <?xml

How to pass state between event handlers in gtk2hs

强颜欢笑 提交于 2019-12-20 11:10:14
问题 I'm trying to make a toy application, just to get my head around how to write event driven programs in Haskell. What I'm trying to do is draw a line to a canvas which moves forward every time a key is pressed (so it's sort of a primordial cursor in a text editor). My problem is I can't work out what the best way to count the number of times the user has pressed a key. Obviously I can't use a global variable like I would in an imperative program so presumably I need to pass the state around on

How to pass state between event handlers in gtk2hs

ε祈祈猫儿з 提交于 2019-12-20 11:09:06
问题 I'm trying to make a toy application, just to get my head around how to write event driven programs in Haskell. What I'm trying to do is draw a line to a canvas which moves forward every time a key is pressed (so it's sort of a primordial cursor in a text editor). My problem is I can't work out what the best way to count the number of times the user has pressed a key. Obviously I can't use a global variable like I would in an imperative program so presumably I need to pass the state around on

Gtk2hs windows 7 installation

[亡魂溺海] 提交于 2019-12-18 07:08:56
问题 I did: cabal update cabal install gtk2hs-buildtools But stuck here: >cabal install gtk Resolving dependencies... [1 of 2] Compiling SetupWrapper ( C:\Users\1\AppData\Local\Temp\gtk-0.12.5.4 -4000\gtk-0.12.5.4\SetupWrapper.hs, C:\Users\1\AppData\Local\Temp\gtk-0.12.5.4-4 000\gtk-0.12.5.4\dist\setup\SetupWrapper.o ) [2 of 2] Compiling Main ( C:\Users\1\AppData\Local\Temp\gtk-0.12.5.4 -4000\gtk-0.12.5.4\Setup.hs, C:\Users\1\AppData\Local\Temp\gtk-0.12.5.4-4000\gtk -0.12.5.4\dist\setup\Main.o )

How can I access a ListStore GtkBuilder

荒凉一梦 提交于 2019-12-13 00:23:38
问题 I'm using the following code to load my gui's elements: import Graphics.UI.Gtk main = do initGUI -- loading builder <- builderNew builderAddFromFile builder "gui.glade" window <- builderGetObject builder castToWindow "window" onDestroy window mainQuit widgetShowAll window mainGUI How could I access a ListStore named "listStore", like how I've accessed a Window named "window" Example: -- doesn't compile because castToListStore is part of a hidden module, unlike castToWindow :( listStore <-

Haskell & Gtk : how to draw points as soon as they are computed

最后都变了- 提交于 2019-12-12 17:40:43
问题 I created a working program displaying the Mandelbrot set, but the whole set is displayed after all is computed; I wonder which changes of the code I must do in order to have a points displayed as soon as it's known if it belongs to the set or not. Here is my program; the beginning is not very important, it's more or less common to all programs using Gtk: module Main where import Control.Monad (when) import Graphics.Rendering.Cairo as C import Graphics.UI.Gtk import Graphics.UI.Gtk.Builder ()

gtk2Hs : Combo box with text and pictures

自闭症网瘾萝莉.ら 提交于 2019-12-11 13:39:56
问题 The basic ComboBox provided by Gtk can only handle a String or a Pixbuf But I wanted a text and a picture nearby on the same row of selection. I looked for a while how to obtain the result bellow using Haskell and Gtk2Hs. 回答1: Here is the code to obtain the expected result : pic1 <- pixbufNewFromFile "Picture_1.png" pic2 <- pixbufNewFromFile "Picture_2.png" pic3 <- pixbufNewFromFile "Picture_3.png" let lstsecrep = [ ("Picture 1",pic1) , ("Picture 2",pic2) , ("Picture 3",pic3) ] lststorerep <-