SqlMask is the widget that displays one record at a time and buttons to browse data, save/delete records. SqlMask is inherited from sqlkit.widgets.common.sqlwidget.SqlWidget
clear the mask for a new record NOTE: this does NOT prepare for a new record (missing obj)
Parameters: |
|
---|
Add a label to the frame whose key in self.widgets is ‘frame_key’.
Parameters: |
|
---|
In example 15:
LAYOUT = '''
{|.number .. }
...
'''
m.set_frame_label(‘number’, ‘Number’)
Introspection of the table is used to determine which widgets will be used to edit the data. The following rules are applied:
varchar: gtk.Entry numbers: gtk.Entry with right alignment bool: gtk.CheckBox text: gtk.Text FKey: fk_edit (a custom ComboBoxEntry) date/datetime: dateedit (entry + arrow for calendar + time) default: gtk.Entry
All fields will have a label that is sensitive to mouse clicks. A mouse click pops up a filter widget.
The most powerful part of SqlMask is the ability to define the layout via simple text description. In the examples you’ll see how easy it is to create fancy layout that have all nice gtk Widgets like expanders, notebooks, panes and it makes it incredibly easy to nest SqlTables into SqlMask to build complex layout that represent also Relationships.
If no layout is provided a flat one will be generated on the fly.
The key is that a textual layout is parsed to see if the token are recognized as fields of the table that the mask is editing, in which case introspection is done to understand which widget should be used to edit the data (according to rules above) and a label is added:
title
date_release
L=description TXS=description
director_id
will show a mask with an entry, a date a text and a fkey. Title and director_id will be already instrumented with completion: director_id will try to complete choosing the values of directors from the director table, title will suggest completion based on title present in the table (and in this case may not be very useful). Description would render is am entry as it’s a varchar, we wanted to “cast” it to text so we had to explicitly add also a token for the label. L is the identified for a sensitive label (a gtk.Label inside a gtk.Event) and TX is the identifier or a scrolled text.
The description language you can use is petty rich (and dynamic, so you can add your custom made widgets): you’d better have a look at the demo of sqlkit.layout that you find in sqlkit.demo.layout
When parsing the textual layout, any token that is not recognized as a field is passed as is to sqlkit.layout.Layout
Occasionally you may need to refine your layout, change packing, visibility, attribute an so on. You can reach the gtk widgets via the widgets attribute of the SqlWidget. In example 26 we use:
Tbl = t.widgets['T.a']
Tbl.get_parent().child_set_property(Tbl, 'y-options', gtk.EXPAND|gtk.FILL)
that changes pack properties to a gtk.Table whose name is T.a
mouse scrolling: | |
---|---|
allows to browse the records that have been loaded by a reload operation | |
Control-s: | saves the record |
Control-q: | quits the table |
Control-n: | opens a new record |
pre-display: |
|
---|
New in version 0.8.8.