Created
February 16, 2014 21:12
-
-
Save gdcs68/9040685 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scene import * | |
import console | |
from MsgBox import * | |
testBestand = 'lister.py' | |
#testBestand = '/.file' | |
class listerLayer (Layer): | |
def __init__(self, text, font, font_size, parentScene): | |
Layer.__init__(self) | |
img, size = render_text(text, font, font_size) | |
parent = parentScene.root_layer | |
print 'parent', parent.frame | |
print 'textSize', size | |
self.image = img | |
if parent.frame.h < size.h: | |
self.frame = Rect(0, 0, size.w, parent.frame.h) | |
else: | |
self.frame = Rect(0, 0, size.w, size.h) | |
if parent: | |
pr = parent.frame | |
# x = (pr.w - size.w)/2 | |
# y = (pr.h - size.h)/2 | |
self.frame.x = 1 | |
self.frame.y = 1 | |
self.ignores_touches = False | |
parent.add_layer(self) | |
def touch_moved(self, touch): | |
print touch.prev_location | |
print touch.location | |
pass | |
class listerWindow(Window): | |
def __init__(self,p,b,lc): | |
Window.__init__(self,p,b) | |
self.stroke = Color(0.60, 0.60, 0.60) | |
self.stroke_weight=0 | |
self.background = Color(0.50, 0.50, 0.50) | |
self.msgLayer = None | |
self.lc = lc | |
self.p = p | |
def setMessage(self, Message): | |
if self.msgLayer: | |
self.msgLayer.remove_layer() | |
self.msgLayer = listerLayer(Message, 'TimesNewRomanPSMT',12,self.lc) | |
def touch_ended(self, touch): | |
self.lc.removeAll() | |
def touch_moveduit(self, touch): | |
print 'previous', touch.prev_location | |
print 'current', touch.location | |
pass | |
class listerInside2(): | |
def openFile(self, bestandsnaam): | |
bestand = open(bestandsnaam, 'r') | |
inhoud = bestand.read() | |
console.clear() | |
print inhoud | |
class listerInside (Scene): | |
def setup(self): | |
self.LISTER_IN_PROGRESS = False | |
self.root_layer = Layer(self.bounds) | |
p = self.root_layer | |
mw=lister(self) | |
mw.readFile(testBestand) | |
mw.showFile() | |
self.LISTER_IN_PROGRESS = True | |
#self=mw | |
def draw(self): | |
if self.LISTER_IN_PROGRESS == True: | |
background(0, 0, 0) | |
else: | |
background(0, 1, 0) | |
self.root_layer.update(self.dt) | |
self.root_layer.draw() | |
class lister(Scene): | |
def __init__(self, pScene): | |
print 'LISTER_IN_PROGRESS', pScene.LISTER_IN_PROGRESS | |
# This will be called before the first frame is drawn. | |
#Bewaren bron rootlayer | |
self.scene = pScene | |
self.callingScene = pScene | |
self.oldRoot = pScene.root_layer | |
self.root_layer = Layer(pScene.bounds) | |
p = self.root_layer | |
m = self | |
p.m = self | |
self.MainWin = listerWindow(p, p.frame, self) | |
pass | |
def setMessage(self, Message): | |
self.MainWin.setMessage(Message) | |
def readFile(self, bestandsnaam): | |
bestand = open(bestandsnaam, 'r') | |
inhoud = bestand.read() | |
self.setMessage(inhoud) | |
def showFile(self): | |
self.scene.LISTER_IN_PROGRESS = True | |
self.scene.root_layer = self.root_layer | |
#self.scene = self | |
def draw(self): | |
print 'lister running' | |
self.root_layer.update(self.dt) | |
self.root_layer.draw() | |
def touch_began(self, touch): | |
#new_frame = Rect(touch.location.x - 100, touch.location.y - 100, 200, 200) | |
#self.root_layer.animate('frame', new_frame, duration=2.0, curve=curve_bounce_out) | |
pass | |
def touch_moved(self, touch): | |
pass | |
def touch_ended(self, touch): | |
removeAll() | |
def removeAll(self): | |
self.MainWin.remove_layer() | |
self.scene.root_layer = self.oldRoot | |
#self.scene = self.callingScene | |
self.scene.LISTER_IN_PROGRESS = False | |
#list = lister() | |
#list.openFile(testBestand) | |
#openFile(testBestand) | |
run(listerInside()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment