Acces to db made easy

- Home
- Sqlkit
  - Sqlkit
  - Widgets
    - Mask view
    - Table view
  - Browsing data
    - Constraints
    - Filters
    - Totals
  - Editing data
    - Completion
    - Validation
    - Relationships
  - Printing
  - Advanced configuration
    - Fields
    - Views
- Sqledit GUI
- Support & Tutorials
  - Sqledit - the application
  - Sqlkit - features' tour
  - Installing instructions
- Layout
- Download
  - Download
  - Changelog
  - Backward incompatibilities

- Prev: Utilities
- Next: Printing

# Field Widgets

Each field is represented using a proper gtk widget. Table and Mask need two different objects, a cell renderer for tables and a widget from module sqlkit.widgets.mask.miniwidgets for masks.

Cell renderers and function to represent the data are defined in sqlkit.widgets.table.columns.

Widgets defined in sqlkit.widgets.mask.miniwidgets are just interfaces (or proxies) to other gtk widgets.

## Fields Representation

Field or Property | Mask | Table
`Varchar` | `VarcharWidget` |
`Text` | `TextWidget` |
`Integer` | `IntegerWidget` |
`Float` | `FloatWidget` |
`Numeric` | `DecimalWidget` |
`Date` | `DateWidget` |
`Datetime` | `DateTimeWidget` |
`Datetime w/ TZ` | `DateTimeTZWidget` |
`Interval` | `IntervalWidget` |
`Time` | `TimeWidget` |
`Time w/ timezone` | `TimeTZWidget` |
`Boolean` | `BooleanWidget` |
`Boolean with null` | `BooleanNullWidget` |
`Enum` (varchar or integer with render=’enum’) | `EnumWidget` |
`Image` (varchar with render=’image’) | `ImageWidget` |
`ForeignKey` | `ForeignKeyWidget` |
`relation (o2m/m2m)` | `CollectionWidget`. This is just a SqlTable that represents the related field |

class `sqlkit.widgets.mask.miniwidgets.``Widget`(gtkwidget, field)

  A proxy between the field and a real gtk widget

  `__init__`(gtkwidget, field)

    setup all what is needed in the widget: completion if any and much more for complex cases as `CollectionWidget`

    Parameters: | gtkwidget – the gtk widget used to display the data field – the field from `sqlkit.fields`

  `set_value`(value, shown=False, initial=False)

    Set the value in the widget

    Parameters: | value – the value to be set shown – (boolean) only memaningfull for foreign key. if True, the displayed value is returned also in any case. The difference is only for ForeignKey The displayed value may be used for completion purpouses initial – not used by miniwidget. Needed for compatibility with tablewidgets where it needs to propagate to master’s set_value

  `get_value`(shown=False)

    Return the displayed value

    Parameter: | shown – (boolean) return the shown value or the real value (only meaningful for foreign keys)

  `set_editable`(editable)
    set the widget editability if the fields is not editable, the widget cannot be editable
  `add_completion`()

    add completion bindings and liststore

    This adds completion capabilities to varchar fields and to foreign keys. You can add it to other widgets as well provided you also use completion’s `set_values` method to provide values to be used in completion.

class `sqlkit.widgets.mask.miniwidgets.``VarcharWidget`(*args)

class `sqlkit.widgets.mask.miniwidgets.``TextWidget`(*args)

class `sqlkit.widgets.mask.miniwidgets.``IntegerWidget`(*args)

class `sqlkit.widgets.mask.miniwidgets.``FloatWidget`(*args)

class `sqlkit.widgets.mask.miniwidgets.``DecimalWidget`(*args)

class `sqlkit.widgets.mask.miniwidgets.``DateWidget`(*args)
  A widget that uses `DateEdit` widget to represent a date. A button that pops a calendar is provided to pick a date

class `sqlkit.widgets.mask.miniwidgets.``DateTimeWidget`(*args)
  A timezone unaware widget to set datetime. Very poor widget indeed. Uses `DateTimeEdit`.

class `sqlkit.widgets.mask.miniwidgets.``DateTimeTZWidget`(*args)
  A timezone aware widget to set datetime. Should have a TimeZone chooser but does not yet

class `sqlkit.widgets.mask.miniwidgets.``IntervalWidget`(gtkwidget, field)

class `sqlkit.widgets.mask.miniwidgets.``TimeWidget`(gtkwidget, field)
  A timezone unaware widget to set time. Very poor widget indeed.

class `sqlkit.widgets.mask.miniwidgets.``TimeTZWidget`(gtkwidget, field)
  A timezone aware widget to set time. Should have a TimeZone chooser but does not yet

class `sqlkit.widgets.mask.miniwidgets.``BooleanWidget`(*args)

  Null value is not admittable

  A boolean widget can be represented via CheckButton (default) or radio button (just use r=field_name when setting layout). In the latter case you can safely group widgets toghether with normal gtk tools `.set.group()` to gain a switch between different alternatives:

      m.SqlMask(..., layout='r=male, r=female')
      m.widgets['r=female'].set_group(m.widgets['r=male'])

class `sqlkit.widgets.mask.miniwidgets.``BooleanNullWidget`(*args)
  This gtkwidget is placed in inconsinstent state to represent NULL

class `sqlkit.widgets.mask.miniwidgets.``EnumWidget`(gtkwidget, field)
  A proxy for a ComboBox

class `sqlkit.widgets.mask.miniwidgets.``ImageWidget`(gtkwidget, field)
  A proxy for Image Viewer to represent fields that hold file name as images

class `sqlkit.widgets.mask.miniwidgets.``ForeignKeyWidget`(*args)

  A ComboBoxEntry that displays a represention of the referenced record rather that the referece. I.e.: it shows last_name/first_name of a director rather than the id of the record in the directors’ table.

  It also enforces the foreign key constraint. Completion occurs on the foreign (referenced) table according to what is detailed in Completion documentation.

class `sqlkit.widgets.mask.miniwidgets.``CollectionWidget`(*args)

  A SqlTable widget that represents a collection of records. This is used to represent a property that in turn holds a relation. E.g.: `director.movies` movies being a list. The contructor setups a SqlTable that has `relationship_leader` pointing to the main SqlMask.

  It maintains the same session so that a single commit will save parent and children.

### Signals

>   value-set: | a signal emitted each time a value is set (via method `Widget.set_value`). This signal does not trigger a general change in value as would be for entries a `changed` signal. Callback function: `value_set_cb(widget, value, initial):`
>   Parameters: | widget – the Miniwidget that issued the signal value – the value that is being set initial – (boolean) True if the value is set with initial=True

### Colors

You can change default color for not nullable object globally:

    from sqlkit.widgets.mask import miniwidgets
    miniwidgets.NOT_NULL_COLOR = gtk.gdk.color_parse('green')

You can change the foreground of unsensitive widgets setting NOT_EDITABLE_COLOR

## Image Viewer

class `sqlkit.layout.image_widget.``ImageWidget`

  Image Widget suitable for basic image viewing. Inherits from VBox

  `sb`(txt)
    Push info on Status Bar
  `scale_pixbuf`(pixbuf, w=None, h=None)

    scale pixbuf image with the same ratio so that it fits into self.w/self.h

    Parameters: | pixbuf – a gtk.gdk.Pixbuf object w – the desired width h – the desired height

  `set_image`(image_path)

    set rendered image

    Parameter: | image_path – the path of the image

  `set_pixbuf`(pixbuf)

    Set the image via the pixbuf

    Parameter: | pixbuf – the gtk.gdk.Pixbuf

  `set_stock`(stock_id, size=<enum GTK_ICON_SIZE_DIALOG of type GtkIconSize>)

    Set the image via the stock-id

    Parameters: | stock-id – a stock-id size – the desired image (default: ICON_SIZE_DIALOG)

  `show_image`(action=None)
    Open another window that will show the same image with at a different zooming. Setup callback to keep the new window updated by the first one.

### Properties

imageViewer has the following properties:

image: | the image path currently rendered
scale: | possible values AUTOREDUCTION, SCALE. If True the image should autoscale. If value is AUTOREDUCTION the image is never enlarged over its natural size
width: | the with of the gtk.Image widget
height: | the height og the gtk.Image widget
scale_factor: | the current scale factor between render image and thumbnail

### Signals

ImageViewer has the following signals:

  image-selected: | The image has been selected for upload. Callback: `on_image_selected(widget, filename, new_filename):`
  Parameters: | widget – the widget that issued the signal fielname – the filename that has been selected new_filename – a preferred filename as suggested by the user if any
image-displayed:
  | The image has been displayed `on_image_displayed(widget, pixbuf_full, pixbuf):`
  Parameters: | widget – the widget that issued the signal pixbuf_full – the pixbuf rendered from the file pixbuf – the scaled pixbuf
  image-deleted: | the image has been deleted `on_image_deleted(widget, filename):`
  Parameters: | widget – the widget that issued the signal fielname – the filename that has been deleted

## DateEdit

class `sqlkit.layout.dateedit.``DateEdit`

  basic gtk widget to edit data

  `set_date`(new_date, from_focus_out=False)
    new_date is a datetime.date object. Can be set by:
      - do_set_property
      - focus_out_event
      - popup click

class `sqlkit.layout.dateedit.``DateTimeEdit`