My favorites | Sign in
Project Home Downloads Issues
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 248 attachment: text_refresh.py (979 bytes)

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
from pymt import *
import random

class TestWidget(MTWidget):
def __init__(self, **kwargs):
MTWidget.__init__(self, **kwargs)
#label
label='michel oijndpoijepqowijn xnpoij'
self.txt=Label(label,font_size=12,bold=True,size=(50,20))
#button to randomly change label properties
self.button=MTButton(label='change',pos=(self.pos[0],self.pos[1]+200))
self.button.push_handlers(on_press=self.change_txt)
self.add_widget(self.button)
def change_txt(self,i):
rand=random.random()
list0=[5,12,14,8,9,16]
list1=[True,False]
self.txt.font_size=list0[int(rand*5.99)]
self.txt.bold=list1[int(rand*1.99)]
self.txt.size=(int(rand*100),int(rand*100))
self.txt.color=(rand,rand,rand,1)
print str(self.txt.font_size)+' '+str(self.txt.bold)+' '+str(self.txt.size)+' '+str(self.txt.color)
#do refresh
self.txt.refresh()
def draw(self):
MTWidget.draw(self)
self.txt.draw()

w=MTWindow()
testwidg=TestWidget()
w.add_widget(testwidg)

runTouchApp()
Powered by Google Project Hosting