ich habe mich gerade gefragt, wie ich eine GUI um ein Programm baue.
Als Anwendungsbeispiel:
Code: Alles auswählen
import time
print('" text1..."')
time.sleep(3)
print('text1')
a = input('')
if a == 'a':
print('text3')
sincerly
Lou
Code: Alles auswählen
import time
print('" text1..."')
time.sleep(3)
print('text1')
a = input('')
if a == 'a':
print('text3')
Code: Alles auswählen
[code]import pygame
import sys
import time
pygame.init()
cSec = 0
cFrame = 0
FPS = 0
fps_font = pygame.font.Font("/usr/local/share/fonts/Arial.ttf", 20)
def show_fps():
fps_overlay = fps.font.render((str(FPS), True, 0, 0, 0)
window.blit(fps_overlay, (0, 0)):
def create_window():
global window, window_height, window_width, window_title
window_width, window_height = 800, 600
window_title = "The tale"
pygame.display.set_caption(window_title)
window = pygame.display.set_mode((window_width, window_height), pygame.HWSURFACE|pygame.DOUBLEBUF)
def count_fps():
global cSec, cFrame, FPS
if cSec == time.strftime("%S"):
cFrame += 1
else:
FPS = cFrame
cFrame = 0
cSec = time.straftime("%S")
create_window()
isRunning = True
while isRunning:
for event in pygame.event.get():
if event.type == pygame.QUIT:
isRunning = False
window.fill((255, 0, 255))
show_fps()
pygame.display.update()
pygame.quit()
sys.exit()
window.blit(fps_overlay, (0, 0)):
^
SyntaxError: invalid syntax
Code: Alles auswählen
File "übung.py", line 15
window.blit(fps_overlay, (0, 0))
^
SyntaxError: invalid syntax
Code: Alles auswählen
import pygame
import sys
import time
WINDOW_WIDTH = 800
WINDOW_HEIGHT = 600
def show_fps(window, font, fps):
fps_overlay = font.render("{:.1f}".format(fps), True, 0, 0, 0)
window.blit(fps_overlay, (0, 0))
def create_window():
pygame.init()
pygame.display.set_caption("The tale")
return pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT), pygame.HWSURFACE|pygame.DOUBLEBUF)
def main():
window = create_window()
font = pygame.font.Font("/usr/local/share/fonts/Arial.ttf", 20)
last_time = 0
while True:
current_time = time.time()
fps = 1 / (current_time - last_time)
last_time = current_time()
for event in pygame.event.get():
if event.type == pygame.QUIT:
break
window.fill((255, 0, 255))
show_fps(window, font, fps)
pygame.display.update()
pygame.quit()
if __name__ == '__main__':
main()