The hk_classes Python reference | ||
---|---|---|
Prev | Chapter 2. Classes in alphabetical order |
Base class for visible widgets. It handles the geometry and the look of the widgets.
Inherits from hk_class.
Figure 2-7. Geometry specific methods
- set_size(x, y,width,height)
lets you to set position and size of an object
- set_size(width,height)
lets you to set size of an object
- set_position(x,y)
lets you to set position of an object
- set_x(x)
lets you to set the horizontal position of an object
- set_y(y)
lets you to set the vertical position of an object
- set_width(width)
see set_size()
- set_height(height)
see set_size()
- x()
returns the x co-ordinate of the object
- y()
returns the y co-ordinate of the object
- width()
returns the width of the object
- height()
returns the height of the object
Figure 2-8. Look and Feel methods
- set_font(fontname,size)
sets the font, e.g. set_font("Arial",12)
- set_font(font)
sets the font of type hk_font, e.g.
- hk_font font()
returns a font object of type hk_font
- set_foregroundcolour(colour)
sets the foreground colour. 'colour' is of type hk_colour. The foreground colour will be used for fonts, frames etc
- foregroundcolour()
returns the foreground colour, which is of type hk_colour.
- set_backgroundcolour(colour)
sets the background colour. 'colour' is of type hk_colour. This colour will be used to fill the whole background.
- hk_colour backgroundcolour()
returns the background colour, which is of type hk_colour.
Figure 2-9. Miscelleanous methods
- set_label(labeltext)
Every visible object has a label which will be displayed when necessary, i.e. a button usually needs a label
- label()
returns the label string.
- type()
returns the type of this object. Possible values are:
textlabel
button
rowselector
boolean
lineedit
memo
combobox
grid
report
reportsection
reportdata
other
- identifier()
the identifier is a unique name within a presentation (either a form or a report) with which this object can be identified and thus located
- presentation()
returns the parent hk_presentation object (either a form or a report)
Example 2-13. Changing colour and position
1 redcolour =hk_colour(255,0,0) 2 greencolour =hk_colour(0,255,0) 3 if hk_this.foregroundcolour().red()!=255: 4 hk_this.set_foregroundcolour(redcolour) 5 hk_this.set_backgroundcolour(greencolour) 6 hk_this.set_label("green button") 7 else: 8 hk_this.set_foregroundcolour(greencolour) 9 hk_this.set_backgroundcolour(redcolour) 10 hk_this.set_label("red button") 11 12 hk_this.set_position(hk_this.x()+50,hk_this.y()+10) |