本文整理汇总了Python中visual.label函数的典型用法代码示例。如果您正苦于以下问题:Python label函数的具体用法?Python label怎么用?Python label使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了label函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init_visual
def init_visual(self, only_wiiobj=False):
visual_pos = ((0, 0, 0), (7,7,0), (14,14,0))
if not only_wiiobj:
#vpython
visual.scene.width=self.param["width"] * 3
visual.scene.height=self.param["height"]
visual.scene.title = "3D WiiMote Simulation"
visual.scene.forward = visual.vector(1,0,0) # not to error ?
visual.scene.up = visual.vector(0,0,1)
visual.scene.forward = visual.vector(-1,1,-1)
visual.scene.center = (7,7,0)
visual.scene.scale = (0.07, 0.07, 0.07)
visual.scene.autoscale = 0
visual.scene.x = 0
visual.scene.y = 30
self.visual["axis"] = [(visual.arrow(pos=visual_pos[i], color=visual.color.red, axis=(3,0,0), headwidth=1, shaftwidth=0.5, fixedwidth=1),
visual.arrow(pos=visual_pos[i], color=visual.color.green, axis=(0,3,0), headwidth=1, shaftwidth=0.5, fixedwidth=1),
visual.arrow(pos=visual_pos[i], color=visual.color.blue, axis=(0,0,3), headwidth=1, shaftwidth=0.5, fixedwidth=1))
for i in xrange(3)]
self.visual["text"] = [visual.label(text="accel", pos=(1, -1, -4), color=visual.color.white),
visual.label(text="gyro", pos=(8, 6, -4), color=visual.color.white),
visual.label(text="accel + gyro", pos=(15, 13, -4), color=visual.color.white),]
self.visual["wiiobj"] = [visual.box(pos=visual_pos[i], length=2, height=6, width=1, color=visual.color.white, axis=(1,0,0)) #x=length, y=height, z=width
for i in xrange(3)]
return
示例2: __init__
def __init__(self, room_=1, beam_axis_=0, target_pos_=(0,0,0)):
self.labScene = visual.display(title="7Be(d,n)8B Experiment", width=800, height=600, background=GetRGBcode(153,204,255))
axisx = visual.box(pos=(0,0,0), axis=(10.0,0,0), width=0.05, height=0.05, color=visual.color.red)
axisy = visual.box(pos=(0,0,0), axis=(0,10.0,0), width=0.05, height=0.05, color=visual.color.blue)
axisz = visual.box(pos=(0,0,0), axis=(0,0,10.0), width=0.05, height=0.05, color=visual.color.green)
labelx = visual.label(pos=(5.0,0,0), text="Z-Axis")
labely = visual.label(pos=(0,5.0,0), text="Y-Axis")
labelz = visual.label(pos=(0,0,5.0), text="X-Axis")
self.labScene.center = target_pos_
self.labScene.autoscale = False
self.room = room_
self.beam_axis = beam_axis_
self.target_pos = target_pos_
self.Floors = []
self.Walls = []
self.Columns = []
self.Others = []
self.BuildRoom()
if(self.room == 1 or self.room == 2):
chamber_radius = 0.25
self.Beamline1 = visual.cylinder(pos=Translate(self.target_pos,GetCartesianCoords(chamber_radius, math.pi/2.0, DegToRad(180+self.beam_axis))), axis=ConvIM3(71.75,0,-71.75*math.tan(DegToRad(180-self.beam_axis))), radius=ConvIM(1.75), color=visual.color.blue) # East beamline
self.Beamline2 = visual.cylinder(pos=Translate(self.target_pos,GetCartesianCoords(chamber_radius, math.pi/2.0, DegToRad(self.beam_axis))), axis=ConvIM3(-217.5,0,217.5*math.tan(DegToRad(180-self.beam_axis))), radius=ConvIM(1.75), color=visual.color.blue) # West beamline
self.OneMeterChamber = visual.cylinder(pos=self.target_pos, axis=(0,chamber_radius*2,0), radius=chamber_radius, color=visual.color.blue)
self.OneMeterChamber.pos[1] = -0.5
示例3: show_protective
def show_protective(nparticles):
# create scene
scene = visual.display(title='Protective zones', width=600, height=400, center=(0,0,0))
scene.select()
# read in positions, state and protective zones
positions = (numpy.genfromtxt('position.dat'))[:nparticles]
state = (numpy.genfromtxt('state.dat'))[:nparticles]
zones = (numpy.genfromtxt('fpt.dat'))[:nparticles]
# go through particles and display them
for i in range(nparticles):
# color the spheres according to state
cball = visual.color.green
if (state[i,0]==1):
cball = visual.color.red
else:
cball = visual.color.blue
if (state[i,3]==1):
cball = visual.color.yellow
if (state[i,3]==2):
cball = visual.color.orange
visual.sphere(pos=(positions[i,0], positions[i,1], positions[i,2]), radius=zones[i], color=cball)
visual.label(pos=(positions[i,0], positions[i,1], positions[i,2]), text='{0:d}'.format(i))
示例4: drawCameraFrame
def drawCameraFrame(): # create frame and draw its contents
global cam_box, cent_plane, cam_lab, cam_tri, range_lab, linelen, fwd_line
global fwd_arrow, mouse_line, mouse_arrow, mouse_lab, fov, range_x, cam_dist, cam_frame
global ray
cam_frame = vs.frame( pos = vs.vector(0,2,2,), axis = (0,0,1))
# NB: contents are rel to this frame. start with camera looking "forward"
# origin is at simulated scene.center
fov = vs.pi/3.0 # 60 deg
range_x = 6 # simulates scene.range.x
cam_dist = range_x / vs.tan(fov/2.0) # distance between camera and center.
ray = vs.vector(-20.0, 2.5, 3.0).norm() # (unit) direction of ray vector (arbitrary)
# REL TO CAMERA FRAME
cam_box = vs.box(frame=cam_frame, length=1.5, height=1, width=1.0, color=clr.blue,
pos=(cam_dist,0,0)) # camera-box
cent_plane = vs.box(frame=cam_frame, length=0.01, height=range_x*1.3, width=range_x*2,
pos=(0,0,0), opacity=0.5 ) # central plane
cam_lab = vs.label(frame=cam_frame, text= 'U', pos= (cam_dist,0,0), height= 9, xoffset= 6)
cam_tri = vs.faces( frame=cam_frame, pos=[(0,0,0), (0,0,-range_x), (cam_dist,0,0)])
cam_tri.make_normals()
cam_tri.make_twosided()
range_lab = vs.label(frame=cam_frame, text= 'R', pos= (0, 0, -range_x), height= 9, xoffset= 6)
linelen = scene_size + vs.mag( cam_frame.axis.norm()*cam_dist + cam_frame.pos)
# len of lines from camera
fwd_line = drawLine( vs.vector(cam_dist,0,0), linelen, vs.vector(-1,0,0))
fwd_arrow = vs.arrow(frame=cam_frame, axis=(-2,0,0), pos=(cam_dist, 0, 0), shaftwidth=0.08,
color=clr.yellow)
vs.label(frame=cam_frame, text='C', pos=(0,0,0), height=9, xoffset=6, color=clr.yellow)
mouse_line = drawLine ( vs.vector(cam_dist,0,0), linelen, ray )
mouse_arrow = vs.arrow(frame=cam_frame, axis=ray*2, pos=(cam_dist,0,0), shaftwidth=0.08,
color=clr.red)
mouse_lab = vs.label(frame=cam_frame, text= 'M', height= 9, xoffset= 10, color=clr.red,
pos= -ray*(cam_dist/vs.dot(ray,(1,0,0))) + (cam_dist,0,0))
示例5: set_label
def set_label(self):
txtlabel = ''
if (self.config['display']['extended_label'] != 0):
if (self.obj["orig_ip_protocol"] in (6,17)):
txtlabel = 'ORIG SRC: %s:%d\n DST: %s:%d\nREPL SRC: %s:%d\n DST: %s:%d\n' % (self.obj["orig_ip_saddr_str"], self.obj["orig_l4_sport"], self.obj["orig_ip_daddr_str"], self.obj["orig_l4_dport"] ,\
self.obj["reply_ip_saddr_str"], self.obj["reply_l4_sport"], self.obj["reply_ip_daddr_str"], self.obj["reply_l4_dport"])
elif (self.obj["orig_ip_protocol"] == 1):
txtlabel = 'ORIG SRC: %s\n DST: %s\nREPL SRC: %s\n DST: %s\nCODE: %d TYPE: %d\n' % (self.obj["orig_ip_saddr_str"], \
self.obj["orig_ip_daddr_str"], self.obj["reply_ip_saddr_str"], \
self.obj["reply_ip_daddr_str"], self.obj["icmp_code"], self.obj["icmp_type"])
else:
txtlabel = 'ORIG SRC: %s\n DST: %s\nREPL SRC: %s\n DST: %s\n' % (self.obj["orig_ip_saddr_str"],self.obj["reply_ip_saddr_str"], self.obj["orig_ip_daddr_str"], self.obj["reply_ip_daddr_str"])
else:
if (self.obj["orig_ip_protocol"] in (6,17)):
txtlabel = 'SRC: %s:%d\nDST: %s:%d\n' % (self.obj["orig_ip_saddr_str"], self.obj["orig_l4_sport"], self.obj["orig_ip_daddr_str"], self.obj["orig_l4_dport"])
else:
txtlabel = 'SRC: %s\nDST: %s\n' % (self.obj["orig_ip_saddr_str"], self.obj["orig_ip_daddr_str"])
if (self.obj["orig_ip_protocol"] == 6):
txtlabel += 'PROTO: TCP'
elif (self.obj["orig_ip_protocol"] == 17):
txtlabel += 'PROTO: UDP'
elif (self.obj["orig_ip_protocol"] == 1):
txtlabel += 'PROTO: ICMP'
if (self.obj["ct_event"] == 1):
self.label = visual.label(pos=self.pos, xoffset = -10, yoffset = 10, text='%s' % (txtlabel))
elif (self.obj["ct_event"] == 4):
self.label = visual.label(pos=self.pos, xoffset = -10, yoffset = 10, text='%s\nIN: %d, OUT: %d bits\nDURATION: %f sec' % (txtlabel, self.obj["reply_raw_pktlen"],self.obj["orig_raw_pktlen"] , self.axis.x))
self.label.visible = 0
示例6: plot3D
def plot3D(self):
axis_length = 10.0
xaxis = vs.arrow(pos = (-5, -5, 0), axis = (axis_length, 0, 0), shaftwidth = 0.01)
yaxis = vs.arrow(pos = (-5, -5, 0), axis = (0, axis_length, 0), shaftwidth = 0.01)
balls = []
for (i, j) in zip(self.x, self.T):
balls.append(vs.sphere(pos = ((j / self.time) * axis_length * 0.9- 4.9, (i / self.v) * axis_length * 0.9 - 4.9, 0), radius = 0.2, color = vs.color.red))
xlabel = vs.label(text = "Time/s", pos = (5, -5, 0))
ylabel = vs.label(text = "Displacement/m", pos = (-5, 5, 0))
示例7: plot3D
def plot3D():
axis_length=10.0
vs.xaxis=vs.arrow(pos=(-5,-5,0),axis=(axis_length,0,0),shaftwidth=0.05)
vs.yaxis=vs.arrow(pos=(-5, -5, 0), axis=(0, axis_length, 0), shaftwidth=0.05)
balls=[]
for (i,j) in zip(N,t):
balls.append(vs.sphere(pos=(((j/time)*axis_length*0.9-4.9,(i/N_O)*axis_length*0.9-4.9,0)),radius=0.2,color=vs.color.red))
vs.xlabel = vs.label(text = "time", pos = (5, -5, 0))
vs.ylabel = vs.label(text = "Number of people", pos = (-5,5,0))
示例8: axes
def axes( frame, colour, sz, posn ): # Make axes visible (of world or frame).
# Use None for world.
directions = [vs.vector(sz,0,0), vs.vector(0,sz,0), vs.vector(0,0,sz)]
texts = ["X","Y","Z"]
posn = vs.vector(posn)
for i in range (3): # EACH DIRECTION
vs.curve( frame = frame, color = colour, pos= [ posn, posn+directions[i]])
vs.label( frame = frame,color = colour, text = texts[i], pos = posn+ directions[i],
opacity = 0, box = False )
示例9: plot3D
def plot3D(self):
axis_length = 10.0
xaxis = vs.arrow(pos = (-5, -5, 0), axis = (axis_length, 0, 0), shaftwidth = 0.01)
yaxis = vs.arrow(pos = (-5, -5, 0), axis = (0, axis_length, 0), shaftwidth = 0.01)
balls = []
for (i, j) in zip(self.n_uranium, self.T):
balls.append(vs.sphere(pos = ((j / self.time) * axis_length * 0.9- 4.9, (i / self.N) * axis_length * 0.9 - 4.9, 0), radius = 0.2, color = vs.color.red))
xlabel = vs.label(text = "time", pos = (5, -5, 0))
ylabel = vs.label(text = "Number of Nuclei", pos = (-5, 5, 0))
while 1:
pass
示例10: frame_rel
def frame_rel(self,frame_rel,*args):
if len(args)==1:
scale = args[0]
else:
if frame_rel == None:
scale = 1
else:
scale = frame_rel.axis.scale
visible = self.visible
visible_label = self.visible_label
visible_frame = self.axis.visible
visible_frame_label = self.axis.visible_label
color = self.color
self.visible = False
del self.__frame_rel
del self.__frame_obj
if frame_rel == None:
self.__frame_rel = None
self.__frame_obj = visual.frame(dis=self.__dis,visible=visible)
else:
self.__frame_rel = frame_rel
self.__frame_obj = visual.frame(frame=self.__frame_rel.__frame_obj,pos=self.__dis,visible=visible)
self.__frame_obj.axis = self.__rot[:,0]
self.__frame_obj.up = self.__rot[:,1]
self.__point_obj = visual.points(frame=self.__frame_obj,pos=(0,0,0),color=color,size=4,size_units="pixels",shape="round")
self.__label_obj = visual.label(frame=self.__frame_obj,text=self.__label,visible=visible_label,
pos=(0,0,0),xoffset=5*scale,yoffset=1*scale,space=5*scale,line=0,height=16*scale,border=0,font='sans',color=color,box=False,opacity=0)
self.axis = axes(frame_obj=self.__frame_obj,visible=visible_frame,visible_label=visible_frame_label,scale=scale)
示例11: __init__
def __init__(self, zoom=False, center=(0, 0, 0), title="Adolphus Viewer"):
"""\
Constructor.
@param zoom: Toggle user zoom enable.
@type zoom: C{bool}
@param center: Location of the center point.
@type center: C{tuple} of C{float}
"""
super(Display, self).__init__(
title=title, center=center, background=(1, 1, 1), foreground=(0.3, 0.3, 0.3), visible=False
)
self.forward = (-1, -1, -1)
self.up = (0, 0, 1)
self.userzoom = zoom
self.range = 1500
self.rmin = 30
self.rmax = 18000
self.message_time = 0
self._stored_view = None
# command/message box
self._messagebox = visual.label(
pos=center,
background=(0, 0, 0),
height=int(VISUAL_SETTINGS["textsize"] * 1.5),
color=(1, 1, 1),
visible=False,
)
示例12: addcar
def addcar(self, pos, color=v.color.green, name="v"):
# Creating car
car = v.frame()
car.start = pos
car.pos = car.start
car.vector = v.vector(0.05, 0, 0)
car.color = color
car.colorori = car.color
body = v.box(frame = car, pos = (0,0,0), size = (2.4*self.thk, 0.6*self.thk, 1.4*self.thk), color = car.colorori)
wheel1 = v.cylinder(frame=car, pos=(0.8*self.thk,-0.2*self.thk,0.8*self.thk), axis=(0,0,-1.6*self.thk), radius=0.25*self.thk, color=(0.6,0.6,0.6))
wheel2 = v.cylinder(frame=car, pos=(-0.8*self.thk,-0.2*self.thk,0.8*self.thk), axis=(0,0,-1.6*self.thk), radius=0.25*self.thk, color=(0.6,0.6,0.6))
head = v.convex(frame=car, color=car.colorori)
head.append(pos=v.vector(0.6, 0.3, -0.7)*self.thk)
head.append(pos=v.vector(0.6, 0.3, 0.7)*self.thk)
head.append(pos=v.vector(-1.2, 0.3, -0.7)*self.thk)
head.append(pos=v.vector(-1.2, 0.3, 0.7)*self.thk)
head.append(pos=v.vector(0.4, 0.7, -0.6)*self.thk)
head.append(pos=v.vector(0.4, 0.7, 0.6)*self.thk)
head.append(pos=v.vector(-0.8, 0.7, -0.6)*self.thk)
head.append(pos=v.vector(-0.8, 0.7, 0.6)*self.thk)
# Creating Label
car.vlabel = v.label(justify='center', pos=car.pos, xoffset=3*self.thk, yoffset=39*self.thk, space=3*self.thk, text=name,height=15, line=0,border=3)
self.cars[name] = car
self.labels[name] = car.vlabel
示例13: plate
def plate(self):
if (self.container):
for obj in self.container.objects:
obj.visible = 0
self.container = visual.frame()
field_length = self.length() + 2*self.config['display']['radius']
field_width = 3*self.config['display']['radius']*self.count + 10
if (self.ordered):
init = self.conns[0].obj[self.orderby]
pborder = 0
t = -1
i = 0
for conn in self.conns:
if (init != conn.obj[self.orderby]):
if ((i % 2) == 1):
bcolor = self.config['colors']['box_light']
else:
bcolor = self.config['colors']['box']
if type(init) == (type(1)):
labeltext = self.orderby + "\n%d" % (init)
elif type(init) == (type('str')):
labeltext = self.orderby + "\n'%s'" % (init)
visual.box(frame=self.container, pos=(field_length/2 - self.level, -(self.config['display']['radius']+1), 3*self.config['display']['radius']*t/2+self.config['display']['radius'] + pborder/2), \
width = (3*self.config['display']['radius']*t - pborder), length = field_length, height = 1, color = bcolor)
visual.label(frame=self.container, pos = (self.config['display']['radius'] -self.level, 0, 3*self.config['display']['radius']*t/2+self.config['display']['radius'] + pborder/2),\
yoffset = 4*self.config['display']['radius'], xoffset = -4* self.config['display']['radius'],text = labeltext)
pborder = 3*self.config['display']['radius']*t+self.config['display']['radius']
init = conn.obj[self.orderby]
i += 1
t += 1
if type(init) == (type(1)):
labeltext = self.orderby + "\n%d" % (init)
elif type(init) == (type('str')):
labeltext = self.orderby + "\n'%s'" % (init)
if ((i % 2) == 1):
bcolor = self.config['colors']['box_light']
else:
bcolor = self.config['colors']['box']
visual.box(frame=self.container, pos=(field_length/2 - self.level, -(self.config['display']['radius']+1), 3*self.config['display']['radius']*t/2+self.config['display']['radius'] + pborder/2), \
width = (3*self.config['display']['radius']*t - pborder), length = field_length, height = 1, color = bcolor)
visual.label(frame=self.container, pos = (self.config['display']['radius'] - self.level, 0, 3*self.config['display']['radius']*t/2+self.config['display']['radius'] + pborder/2),\
yoffset = 4*self.config['display']['radius'], xoffset = -4* self.config['display']['radius'], text = labeltext)
else:
visual.box(frame=self.container, pos = (field_length/2 - self.level, -(self.config['display']['radius']+1),field_width/2), width = field_width, length = field_length, height = 1, color = self.config['colors']['box'])
desctext = 'From %s to %s\n' % (time.strftime("%F %H:%M:%S", time.localtime(self.starttime)), \
time.strftime("%F %H:%M:%S", time.localtime(self.endtime)))
desctext += self.build_str_filter(" and ", "Filtering on ")
visual.label(frame=self.container, pos = (field_length/2 - self.level, self.config['display']['radius']+0.5,0), yoffset = 4*self.config['display']['radius'], text = desctext)
for i in range(self.config['display']['graduation']):
visual.curve(frame=self.container, pos=[(field_length/self.config['display']['graduation']*i - self.level, -(self.config['display']['radius']+1)+1,0), (field_length/self.config['display']['graduation']*i - self.level,-(self.config['display']['radius']+1)+1,field_width)])
for i in range(self.config['display']['graduation']/self.config['display']['tick']+1):
ctime = time.strftime("%H:%M:%S", time.localtime(self.mintime + field_length/self.config['display']['graduation']*self.config['display']['tick']*i))
visual.label(frame=self.container, pos=(field_length/self.config['display']['graduation']*self.config['display']['tick']*i - self.level, -(self.config['display']['radius']+1)+1,0), text = '%s' % (ctime), border = 5, yoffset = 1.5*self.config['display']['radius'])
示例14: __init__
def __init__(self, stacks, position):
"""
Pass a reference to the stacks object that holds all the blocks
and the index of the initial stack of the block
"""
Block.__init__(self, stacks, position)
self.box = box(pos=(position-(stacks.blockCount/2), 0, 0), size=(.9,.9,.9), color=color.blue)
self.label = label(pos=array(self.box.pos) + array([0,0,1]), text=str(position), opacity=0, box=0, line=0)
示例15: setlabel
def setlabel(self, txt,visible=None):
if self.label is not None:
if visible is None:
visible = self.label.visible
self.label.visible = 0
elif visible is None:
visible=0
self.label=visual.label(text=txt, pos=self.pos, space=self.radius, xoffset=10, yoffset=20, visible=visible)