Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- class textCollectingWindow():
- def __init__(self,title,linesOfText,prompt,btnText):
- self.linesOfText = linesOfText
- self.amActive = True
- self.theText = None
- self.root = tk.Tk()
- self.root.title(title)
- self.promptElement = tk.Label(self.root, text=prompt)
- self.promptElement.pack()
- self.entryBox = tk.Text(self.root, height=linesOfText)
- self.entryBox.pack()
- self.button = tk.Button(self.root, text = btnText,
- command=self.storeText)
- self.button.pack()
- def updateDisplay(self):
- newLineChars = 0
- try:
- self.root.update()
- for char in self.entryBox.get("1.0", tk.END):
- if char == '\n':
- newLineChars += 1
- if newLineChars == self.linesOfText+1:
- self.storeText()
- except:
- self.amActive = False
- def getState(self):
- return self.amActive
- def storeText(self):
- self.theText = self.entryBox.get("1.0", tk.END)
- self.theText = self.theText[:len(self.theText)-1]
- self.root.withdraw()
- self.root.destroy()
- def getText(self):
- return self.theText
- codeGetter = textCollectingWindow('Code editor',2,'Enter two lines of code:','Add code')
- import pygame
- pygame.init()
- Width = 500; WindowDimensions = (Width, Width)
- displayCaption = 'pygame testing display.py'
- FPS = 60;
- colours = {'yellow':[255,230,0],'light blue':[150, 190, 255],'black':[0,0,0],
- 'white':[255,255,255],'orange':[255,200,0]}
- gameDisplay = pygame.display.set_mode(WindowDimensions)
- pygame.display.set_caption(displayCaption)
- clock = pygame.time.Clock()
- close = False
- i = 0
- for k in range(120):
- i += 1
- if i > 100:
- i = 100
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- quit()
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_a:
- close = True
- if close == True:
- break
- if i < 60:
- gameDisplay.fill(colours['black'])
- elif i < 80:
- gameDisplay.fill(colours['white'])
- else:
- gameDisplay.fill(colours['light blue'])
- pygame.display.update()
- clock.tick(FPS)
- while True:
- if codeGetter.getState() == False:
- theCode = codeGetter.getText()
- print(theCode)
- break
- codeGetter.updateDisplay()
- del codeGetter
- close = False
- i = 0
- while True:
- i+= 1
- i = i%100
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- quit()
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_a:
- close = True
- if close == True:
- break
- if i < 50:
- gameDisplay.fill(colours['yellow'])
- else:
- gameDisplay.fill(colours['orange'])
- pygame.display.update()
- clock.tick(FPS)
- codeGetter = textCollectingWindow('Code editor',2,'Enter two lines of code:','Add code')
- while True:
- if codeGetter.getState() == False:
- theCode = codeGetter.getText()
- print(theCode)
- break
- codeGetter.updateDisplay()
- while True:
- i+= 1
- i = i%100
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- quit()
- if i < 50:
- gameDisplay.fill(colours['yellow'])
- else:
- gameDisplay.fill(colours['orange'])
- pygame.display.update()
- clock.tick(FPS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement