from GUI import Window, Label, Font, application
from GUI.StdColors import red
from GUI.StdFonts import system_font

num_rows = 6

#print "Getting italic font"
italic_font = Font("Times", 2 * system_font.size, ['italic'])
#print "System font height =", system_font.height
#print "Italic font height =", italic_font.height

def make_label(text, **kwds):
    #print "Creating label", text
    return Label(text = text, **kwds)

#print "Creating labels"
lbls = [
    make_label("ParrotState:"),
    make_label("Resting"),
    make_label("Spam!\nGlorious Spam!"),
    make_label("Red", color = red),
    make_label("Big Italic", font = italic_font),
    make_label("Pig in the\nMiddle", just = 'center', width = 140),
    make_label("Right\nJustified", just = 'right', width = 140),
]

#print "Setting label positions"
lbls[0].position = (20, 20)
lbls[1].position = (lbls[0].right, lbls[0].top)
for i in range(2, len(lbls)):
    lbls[i].position = (lbls[0].left, lbls[i-1].bottom + 20)
    
#for lbl in lbls:
#	print lbl.height

#print "Creating window"
win = Window(title = "Labels")
for lbl in lbls:
    win.add(lbl)
win.size = (lbls[-1].right + 20, lbls[-1].bottom + 20)
win.show()

instructions = """
There should be six rows of labels:
1. Two labels "ParrotState:" and "Resting", abutting but not overlapping.
2. A two-line label "Spam!\\nGlorious Spam!"
3. A label "Red" in red text.
4. A label "Big Italic" in a large italic font.
5. A two-line label "Pig in the\\nMiddle" centred in the window.
6. A two-line label "Right\\nJustified" right-aligned.
All labels should remain stationary relative to the top left corner
of the window when it is resized.
"""

print instructions

#application().menus = []

application().run()
