Форум сайта python.su
Если тема еще актуальна, так можете попробовать pygame. Похожую задачу я решил, выполняется отлично.
Вот код программы, в нем в принципе описано что и как, да и в интернете есть материал для рисования, и так сказать анимации, в общем удачи, должно все получиться.
# -*- coding: cp1251 -*-
import pygame
from pygame.locals import *
from sys import exit
import math
import time
import glob
path_aim = 'D:/D/input_aim/'
paths_to_aim = glob.glob(path_aim + '*.aim')
print paths_to_aim
width = 600
height = 600
center_x = width / 2 #width
center_y = height / 2 #height
pygame.init()
screen = pygame.display.set_mode((width, height), 0, 32)
def dannue(paths_to_aim):
all_KA = []
for path in paths_to_aim:
f = open(path, 'r')
f_read = f.readlines()
f.close()
ob_name = f_read[0][22:29]
from_file = []
for i in range(11, len(f_read), 3):
data = f_read[i][31:41]
time = f_read[i][42:50]
az = f_read[i + 2][7:13]
um = f_read[i + 2][18:24]
vitok = f_read[i][22:30]
al = (ob_name, data, time, az, um, vitok)
all_KA.append(al)
return all_KA
all_KA = dannue(paths_to_aim)
def draw_trass(all_KA):
text = 0
rev_last = 0
x_1, y_1 = (0, 0)
for data in all_KA:
az = float(data[3])
um = float(data[4])
rev = data[5]
if text == 0 or rev != rev_last:
#print rev
#c.create_text((x, y), text = data[0], fill = 'yellow')
text = 1
x_1, y_1 = (0, 0)
rev_last = rev
zenith = (height / 2) * (90.0 - um) / 90.0
x = (width / 2) + zenith * (math.sin(math.radians(az)))
y = (height / 2) - zenith * (math.cos(math.radians(az)))
if (x_1, y_1) == (0, 0):
x_1 = x
y_1 = y
#c.create_line((x - 1, y - 1), (x, y), fill = 'yellow')
pygame.draw.line(screen, (0, 100, 255), (x_1, y_1), (x, y))
x_1 = x
y_1 = y
#print x_1, y_1
#pygame.display.update()
def convert_time(file_d, d):
#29.06.2009 03:35: 7
#0123456789 012345678
year = int(file_d[d][1][6:])
month = int(file_d[d][1][3:5])
day = int(file_d[d][1][0:2])
hh = int(file_d[d][2][0:2])
mm = int(file_d[d][2][3:5])
ss = int(file_d[d][2][6:])
time_sec = time.mktime((year, month, day, hh, mm, ss, 0, 0, 0))
return time_sec
while 1:
for event in pygame.event.get():
if event.type == QUIT:
exit()
screen.fill((0, 0, 0))
draw_trass(all_KA)
for d in range(len(all_KA)):
#print all_KA[d]
try:
t = convert_time(all_KA, d)
t_1 = convert_time(all_KA, (d + 1))
#print t_1, t
t_curent = time.time()
#print 'ok'
if t < t_curent < t_1:
az = float(all_KA[d][3])
um = float(all_KA[d][4])
zenith = (width / 2) * (90.0 - um) / 90.0
x = (width / 2) + zenith * (math.sin(math.radians(az)))
y = (height / 2) - zenith * (math.cos(math.radians(az)))
#print x, y
pygame.draw.circle(screen, (255, 0, 0), (x, y), 10)
# Create a font
font = pygame.font.Font(None, 17)
# Render the text
text = font.render(all_KA[d][0], True, (255,
255, 255), (0, 0, 0))
# Create a rectangle
textRect = text.get_rect()
# Center the rectangle
textRect.centerx = x + 10
textRect.centery = y + 10#screen.get_rect().centery
# Blit the text
screen.blit(text, textRect)
#pygame.display.update()
except:
pass
pygame.display.update()
Отредактировано (Июль 2, 2009 23:26:43)
Офлайн