0

I am attempting to fix the size of a widget in GTK+, specifically using Gtk2hs with Haskell.

I have drawn an image in a DrawingArea and I would like to specify the exact size of this drawing area. I do not want other widgets or the user to make this widget larger or smaller. Is this possible?

Note, I am using ghc version 6.10.4 under Ubuntu 9.10. Gtk2hs version 0.10.1.

unwind
  • 391,730
  • 64
  • 469
  • 606
Necrototem
  • 554
  • 6
  • 12

2 Answers2

3

You can call gtk_widget_set_size_request() to cause a widget to request a fixed height and width. You'll have to determine the Haskell equivalent.

Note that this is generally a Bad Idea(TM) and you should arrange your containers and child packing properties such that your controls are sized appropriately. For example, changing the size of your image will require code changes if you're hardcoding size request values.

anthony
  • 40,424
  • 5
  • 55
  • 128
  • Thanks. This was halfway to fixing my problem. I also needed to place it inside a Fixed pane (as opposed to HBox or VBox, say) to prevent the enclosing widget from resizing the DrawingArea. – Necrototem Feb 16 '10 at 23:41
2

The Gtk2Hs function to fix a widget size is :

widgetSetSizeRequest 
  :: WidgetClass self    
  => self    
  -> Int    
  -> Int    
  -> IO ()

with as arguments :

  1. The widget
  2. Width of the Widget
  3. Height of the Widget
JeanJouX
  • 2,555
  • 1
  • 25
  • 37