Namespaces
Variants
Actions
(Redirected from Gráficos em PySymbian)

Archived:Gráficos em PySymbian

Jump to: navigation, search
Archived.png
Aquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.
Dados do artigo

Artigo
Tradução:
Por _katy_
Última alteração feita por hamishwillee em 07 May 2013
==Gráficos em Python==


O código abaixo gera gráficos para entrada de informação de um usuário. Inicialmente o código foi feito para desenhar três gráficos. Maiores informações sobre o código é fornecida através de comentários.


# import modules
import e32, appuifw,graphics
 
# Define quit function
def quit():
app_lock.signal()
 
def draw():
 
# Get number of graphs
t = appuifw.query(u"Enter Number Of Graphs: (Max 9)","number")
 
#title of the application
appuifw.app.title = u"Graphs"
 
# Get range
rrng = appuifw.query(u"Maximum Range Of Graph:","number")
 
# Graph colors
colors = [0x0000ff,0x00ff00,0xff0000,0xffff00,0xc0c0c0,0x808040,0xff00ff,0xf0cb75,0xbe6a0e]
 
# Get graph prameters
y = []
n = []
for j in range(t):
(n1,y1) = appuifw.multi_query(u"Title Of Graph %d:"%(j+1),u"Height Of Graph %d:"%(j+1))
n.append(n1)
y11 = int(y1)
y.append(y11)
 
# Define canvas
canvas=appuifw.Canvas()
appuifw.app.body=canvas
xx,yy = canvas.size
 
# Scaling Graphs according to screen size
arrg = float(yy-50)
mf = arrg/rrng
 
# Draw x,y axis
canvas.line((20,yy-20,xx-32,yy-20), 0)
canvas.line((xx-33,10,xx-33,yy-20),0)
 
# Put indicator points
canvas.text((xx-34,30+(yy-40)*0.75),u"_%d"%(rrng*0.25))
canvas.text((xx-34,30+(yy-40)*0.5),u"_%d"%(rrng/2))
canvas.text((xx-34,30+(yy-40)*0.25),u"_%d"%(rrng*0.75))
canvas.text((xx-34,30),u"_%d"%(rrng))
 
# Draw graphs
h = 30
for i in range(t):
w=(xx-57)/t - 10
s = yy-20-mf*y[i]
canvas.rectangle((h,s,h+w,yy-20), outline=0x000000, fill=colors[i])
x11 = str(y[i])
canvas.text((h,(s-5)),u" %s"%(x11), fill=colors[i])
canvas.text((h,yy), u"%s"%(n[i]), fill=0x4b2192)
h=h+w+10
draw()
 
#the code will allow the user to exit the application when he presses the exit key
appuifw.app.exit_key_handler=quit
app_lock=e32.Ao_lock()
app_lock.wait()

Screenshots

O código apenas parece longo, mas é muito fácil de entender. No momento em que o gráfico é desenhado um screenshot pode ser usado para salvar a imagem que o usuário deseja. Algumas imagens do código acima são mostradas abaixo.

Number of Graphs
Maximum Range
Graph Parameters
Plotted Graphs
This page was last modified on 7 May 2013, at 14:34.
125 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved