1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
# Frame examples.
import os
from ocempgui.widgets import *
from ocempgui.widgets.Constants import *
def create_frame_view ():
table = Table (2, 3)
table.topleft = 5, 5
table.spacing = 5
# Create and display two 'standard' frames.
hframe = HFrame (Label ("Horizontal Frame"))
table.add_child (0, 0, hframe)
lbl = Label ("Vertical Frame" + os.linesep + "with 5 px spacing")
lbl.multiline = True
vframe = VFrame (lbl)
vframe.spacing = 5
table.add_child (0, 1, vframe)
for i in xrange(3):
btn = Button ("Button %d" % i)
hframe.add_child (btn)
btn2 = Button ("Button %d" % i)
vframe.add_child (btn2)
# Create framed frames.
framed1 = VFrame (Label ("VFrame"))
framed2 = HFrame ()
framed3 = VFrame (Label ("VFrame as HFrame.widget"))
framed3.add_child (Label ("Child of a VFrame"))
framed2.widget = framed3
framed2.add_child (Button ("Button 1"), Button ("Button 2"))
button = Button ("Simple Button")
framed1.add_child (framed2, button)
table.add_child (1, 0, framed1)
# Create a Frame with alignment.
frame_align = VFrame (Label ("VFrame with right alignment"))
frame_align.align = ALIGN_RIGHT
label1 = Label ("Label")
label2 = Label ("Even longer label")
button = CheckButton ("A CheckButton")
frame_align.add_child (label1, label2, button)
table.add_child (1, 1, frame_align)
# Add insensitive frames.
hframe = HFrame (Label ("Insensitive HFrame"))
hframe.sensitive = False
table.add_child (0, 2, hframe)
vframe = VFrame (Label ("Insensitive VFrame"))
vframe.sensitive = False
table.add_child (1, 2, vframe)
for i in xrange(3):
btn = Button ("Button %d" % i)
hframe.add_child (btn)
btn2 = Button ("Button %d" % i)
vframe.add_child (btn2)
return table
if __name__ == "__main__":
# Initialize the drawing window.
re = Renderer ()
re.create_screen (600, 300)
re.title = "Frame examples"
re.color = (234, 228, 223)
re.add_widget (create_frame_view ())
# Start the main rendering loop.
re.start ()
|