Wiki

Changes between Version 1 and Version 2 of GtkStaticWidgets

Show
Ignore:
Timestamp:
11/06/11 11:23:59 (13 years ago)
Author:
callisto
Comment:

completed label and separator widgets

Legend:

Unmodified
Added
Removed
Modified
  • GtkStaticWidgets

    v1 v2  
    55== Labels == 
    66 
     7A 'label' simply displays some text.  The most straightforward construction is: 
     8{{{ 
     9#!cobra 
     10                label1 = Label("label") 
     11}}} 
     12 
     13Labels can display larger blocks of text.  Set 'lineWrap' to true if the text should be wrapped and displayed on multiple lines.  Markup is supported to change the style of the text.  If your label text contains markup you need to set the 'useMarkup' attribute of the label to true.  
     14 
     15The following image and program shows three different labels. 
     16 
     17[[Image(gtk-labels.png)]] 
     18 
     19{{{ 
     20#!cobra 
     21# @args -pkg:gtk-sharp-2.0 # remove initial '#' 
     22 
     23use Gtk 
     24 
     25class ExampleWindow inherits Window 
     26        cue init 
     27                base.init("Example of Labels") 
     28                listen .deleteEvent, do(obj, e as DeleteEventArgs) 
     29                        Application.quit 
     30                .createWidgets 
     31                .setDefaultSize(300, 100) 
     32 
     33        def createWidgets 
     34                label1 = Label("label") 
     35                label2 = Label("with _mnemonic") 
     36                label3 = Label("Right now, if you want software contracts in your language,  
     37how can you get them? The answer is to use <tt>Eiffel</tt> or D. What if you want static and  
     38dynamic binding? Use Objective-C or Boo. What if you want expressiveness and quick coding?  
     39Use <b>Python, Ruby or Smalltalk</b>. What if you want runtime performance? Use C#, Java, C++,  
     40etc. <i>What if you want first class language support for unit tests? Use D.</i>") 
     41                label3.lineWrap = true 
     42                label3.useMarkup = true 
     43 
     44                box = HBox(false, 20) 
     45                box.borderWidth = 20 
     46                box.packStart(label1, true, true, 0) 
     47                box.packStart(label2, true, true, 0) 
     48                box.packStart(label3, true, true, 0) 
     49                .add(box) 
     50         
     51class RunProgram 
     52        def main 
     53                Application.init 
     54                window = ExampleWindow() 
     55                window.showAll 
     56                Application.run 
     57}}} 
     58 
    759== Separators == 
     60 
     61Separators are widgets which display as lines, and are used to divide up parts of the interface.  Separators are either ''vertical'' or ''horizontal''.   
     62 
     63 * HSeparator() : creates a horizontal line - use to divide up widgets arranged vertically 
     64 * VSeparator() : creates a vertical line - use to divide up widgets arranged horizontally 
    865 
    966== Frame ==  
     
    1168A 'frame' is a container class which holds one child widget, and displays that child with a surrounding border and title.  That child can be another container, so frames can contain many other widgets. 
    1269 
    13 A frame is easy to construct and use.  Given a box containing widgets to display, the following two lines wrap the box in the frame class: 
     70A frame is constructed with the text of the title to display.  The child widget is then added before packing the frame to display: 
    1471{{{ 
    1572#!cobra 
     
    3390 * !ShadowType.!EtchedOut 
    3491 
    35 The following program illustrates using frames to label some radiobuttons.  The frame on the left uses the default alignment and style. 
     92The following image and program illustrates the use of frames to label some radiobuttons.  The frame shown on the left uses the default alignment and style. 
    3693 
    3794[[Image(gtk-frames.png)]]