-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsampletext.py
More file actions
50 lines (32 loc) · 1 KB
/
sampletext.py
File metadata and controls
50 lines (32 loc) · 1 KB
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
#!/usr/bin/env python
# -*- coding: latin-1 -*-
"""
Frame example (April 26, 2014)
Piece of SimpleGUICS2Pygame.
https://bitbucket.org/OPiMedia/simpleguics2pygame
GPLv3 --- Copyright (C) 2013, 2014 Olivier Pirson
http://www.opimedia.be/
"""
from SimpleGUICS2Pygame import simpleguics2pygame as simplegui
simplegui.Frame._hide_status = True
CANVAS_WIDTH = 400
CANVAS_HEIGHT = 300
def draw(canvas):
"""
Draw a simple text.
:param canvas: simplegui.Canvas
"""
text = 'Canvas'
font_size = 40
text_width = frame.get_canvas_textwidth(text, font_size)
canvas.draw_text(text,
((CANVAS_WIDTH - text_width)//2,
CANVAS_HEIGHT//2 + font_size//4),
font_size, 'Green')
# Main
frame = simplegui.create_frame('Title', CANVAS_WIDTH, CANVAS_HEIGHT)
frame.add_label('Control Panel')
frame.add_label('')
frame.add_button('Quit', frame.stop)
frame.set_draw_handler(draw)
frame.start()