本文整理汇总了Python中Object.Object类的典型用法代码示例。如果您正苦于以下问题:Python Object类的具体用法?Python Object怎么用?Python Object使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Object类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_game
def new_game():
global player, inventory, game_msgs, game_state, dungeon_level
#create object representing the player
entity_component = Entity(5)
GameState.player = Object(0, 0, '@', 'player', libtcod.white, blocks=True, entity=entity_component)
GameState.player.level = 1
#generate map (at this point it's not drawn to the screen)
dungeon_level = 1
Map.make_map()
initialize_fov()
game_state = 'playing'
GameState.inventory = []
#create the list of game messages and their colors, starts empty
GameState.game_msgs = []
#a warm welcoming message!
GUI.message('Welcome stranger! Prepare to perish in the Tombs of the Ancient Kings.', libtcod.red)
#initial equipment: a dagger
equipment_component = Equipment(slot='right hand', power_bonus=2)
obj = Object(0, 0, '-', 'dagger', libtcod.sky, equipment=equipment_component)
GameState.inventory.append(obj)
equipment_component.equip()
obj.always_visible = True
示例2: __init__
def __init__(self):
Object.__init__(self)
config = CNCConfig()
self.units = config.ReadFloat("ProgramUnits", 1.0) # set to 25.4 for inches
self.alternative_machines_file = config.Read("ProgramAlternativeMachinesFile", "")
self.raw_material = RawMaterial() # // for material hardness - to determine feeds and speeds.
machine_name = config.Read("ProgramMachine", "emc2b")
self.machine = self.GetMachine(machine_name)
import wx
default_output_file = (wx.StandardPaths.Get().GetTempDir() + "/test.tap").replace("\\", "/")
self.output_file = config.Read(
"ProgramOutputFile", default_output_file
) # // NOTE: Only relevant if the filename does NOT follow the data file's name.
self.output_file_name_follows_data_file_name = config.ReadBool(
"OutputFileNameFollowsDataFileName", True
) # // Just change the extension to determine the NC file name
self.python_program = ""
self.path_control_mode = config.ReadInt("ProgramPathControlMode", PATH_CONTROL_UNDEFINED)
self.motion_blending_tolerance = config.ReadFloat(
"ProgramMotionBlendingTolerance", 0.0
) # Only valid if m_path_control_mode == eBestPossibleSpeed
self.naive_cam_tolerance = config.ReadFloat(
"ProgramNaiveCamTolerance", 0.0
) # Only valid if m_path_control_mode == eBestPossibleSpeed
示例3: __init__
def __init__(self, whichType, position = None, velocity = None, acceleration = None, flipped = False, projectile = False):
"""
Creates a basic Entity of a specific type.
"""
Object.__init__(self, whichType, position, flipped = flipped)
Entity.Entities.append(self)
Object.Objects.pop(-1)
#Collision
self.collideState = None
self.collidingLeft,self.collidingRight,self.collidingTop,self.collidingBottom = [False] * 4
#Physics
self.acceleration = acceleration
if acceleration == None:
self.acceleration = Vector()
self.velocity = velocity
if velocity == None:
self.velocity = Vector()
self.wallSliding = False
self.slidingSide = None
self.projectile = projectile
self.destroy = False
示例4: loadBlenderProperties
def loadBlenderProperties(self, object):
Object.loadBlenderProperties(self, object)
try:
self.size = object.getProperty('size').getData()
except AttributeError:
# use the default size
self.set_size()
self.name = object.getName()
示例5: __init__
def __init__(self, name = '' ):
Object.__init__( self, name )
# Electrical Stuff
self.port_dict = {}
self.net_dict = {}
self.inst_dict = {}
self.param_dict = {}
self.port_name_list = []
示例6: serialize
def serialize(self, writer):
Object.serialize(self, writer)
writer(('position',) + tuple(self.position))
writer(('size',) + tuple(self.size))
writer(('rotation', self.rotation))
writer(('scale',) + tuple(self.scale))
writer(('shear',) + tuple(self.shear))
writer(('spin',) + tuple(self.spin))
if self.drivethrough == 1:
writer('drivethrough')
if self.shootthrough == 1:
writer('shootthrough')
示例7: define
def define(self, aName):
obj = Object()
obj.nName = aName
obj.pNext = None
if self.symbolTable[self.nCurrentLevel] is None:
self.symbolTable[self.nCurrentLevel] = obj
self.symbolTableLast[self.nCurrentLevel] = obj
else:
objTemp = self.symbolTableLast[self.nCurrentLevel]
objTemp.pNext = obj
self.symbolTableLast[self.nCurrentLevel] = obj
return obj
示例8: loadBlenderProperties
def loadBlenderProperties(self, object):
Object.loadBlenderProperties(self, object)
try:
self.drive_through = object.getProperty('driveThrough').getData()
except AttributeError:
# No property, set default
self.drive_through = 0
try:
self.shoot_through = object.getProperty('shootThrough').getData()
except AttributeError:
# No property, set default
self.shoot_through = 0
示例9: __init__
def __init__(self, name = '', module_ref_name = '' ):
Object.__init__( self, name )
# Electrical Stuff
self.module_ref_name = module_ref_name # String
self.module_ref = None # vv.Module Instance
self.port_dict = {}
self.param_dict = {}
# Derived Electrical Stuff
self.num_inputs = 0
self.num_outputs = 0
示例10: __init__
def __init__(self, path=None):
"""Sets up and starts the `AppServer`.
`path` is the working directory for the AppServer
(directory in which AppServer is contained, by default)
This method loads plugins, creates the Application object,
and starts the request handling loop.
"""
self._running = 0
self._startTime = time.time()
global globalAppServer
if globalAppServer:
raise ProcessRunning('More than one AppServer'
' or __init__() invoked more than once.')
globalAppServer = self
# Set up the import manager:
self._imp = ImportManager()
ConfigurableForServerSidePath.__init__(self)
Object.__init__(self)
if path is None:
path = os.path.dirname(__file__) # os.getcwd()
self._serverSidePath = os.path.abspath(path)
self._webKitPath = os.path.abspath(os.path.dirname(__file__))
self._webwarePath = os.path.dirname(self._webKitPath)
self.recordPID()
self._verbose = self.setting('Verbose')
self._plugIns = []
self._requestID = 0
self.checkForInstall()
self.config() # cache the config
self.printStartUpMessage()
sys.setcheckinterval(self.setting('CheckInterval'))
self._app = self.createApplication()
self.loadPlugIns()
# @@ 2003-03 ib: shouldn't this just be in a subclass's __init__?
if self.isPersistent():
self._closeEvent = Event()
self._closeThread = Thread(target=self.closeThread,
name="CloseThread")
# self._closeThread.setDaemon(1)
self._closeThread.start()
self._running = 1
示例11: __init__
def __init__(self, warehouse, uid, action_topic, cmd_vel_topic, scan_topic, odom_topic, amcl_topic, vision_topic, tf_prefix, robot_description):
Agent.__init__(self, warehouse, uid, action_topic)
Object.__init__(self, uid, shapely.geometry.Point(tuple(robot_description['pos'])), shapely.geometry.Polygon([tuple(v) for v in robot_description['footprint']]))
Vessel.__init__(self, uid)
self.orientation = 0 #radian
rospy.Subscriber(cmd_vel_topic, geometry_msgs.msg.Twist, self.cmd_vel_handler)
self.robot_description = robot_description
if scan_topic:
self.scan_pub = rospy.Publisher(scan_topic, sensor_msgs.msg.LaserScan)
self.scan_data = sensor_msgs.msg.LaserScan()
self.scan_data.header.frame_id = tf_prefix + '/base_link'
self.scan_data.angle_min = self.robot_description['laser_angle_min']
self.scan_data.angle_max = self.robot_description['laser_angle_max']
self.scan_data.angle_increment = self.robot_description['laser_angle_increment']
self.scan_data.range_min = self.robot_description['laser_range_min']
self.scan_data.range_max = self.robot_description['laser_range_max']
else:
self.scan_pub = None
if odom_topic:
self.odom_pub = rospy.Publisher(odom_topic, nav_msgs.msg.Odometry)
self.odom_broadcaster = tf.TransformBroadcaster()
self.odom_data = nav_msgs.msg.Odometry()
self.odom_data.header.frame_id = tf_prefix + '/odom'
self.odom_data.child_frame_id = tf_prefix + '/base_link'
self.init_pos = self.pos
self.init_orientation = self.orientation
self.init_time = rospy.Time.now()
else:
self.odom_pub = None
if amcl_topic:
self.amcl_pub = rospy.Publisher(amcl_topic, geometry_msgs.msg.PoseWithCovarianceStamped)
self.amcl_data = geometry_msgs.msg.PoseWithCovarianceStamped()
self.amcl_data.header.frame_id = '/map'
else:
self.amcl_pub = None
self.vision_pub = rospy.Publisher(vision_topic, warehouse_simulator.msg.AbstractVision)
for command in self.robot_description['actions'].keys():
self.add_command(command)
self.add_command('vel')
self.battery = Battery(self.robot_description['battery_max_quantity'], self.robot_description['battery_max_quantity'], self.robot_description['battery_recharge_rate'])
self.vel = geometry_msgs.msg.Twist()
self.vel_odom = geometry_msgs.msg.Twist()
self.vel_target = geometry_msgs.msg.Twist()
self.broken = False
示例12: __str__
def __str__(self):
output = [Object.__str__(self)]
for property in self.properties:
arg = list(getattr(self, property.name))
output.append(property.pack(arg))
return "".join(output)
示例13: __init__
def __init__(self, sequence, \
id, subtype, name, \
desc, \
parent, \
contains, \
modify_time, \
*args, **kw):
Object.__init__(self, sequence, id, subtype, name, desc, parent, contains, modify_time)
assert subtype == self.subtype, "Type %s does not match this class %s" % (subtype, self.__class__)
if len(self.properties) != len(args):
raise TypeError("The args where not correct, they should be of length %s" % len(self.properties))
for property, arg in zip(self.properties, args):
self.length += property.length(arg)
setattr(self, property.name, arg)
示例14: __init__
def __init__(self,
name ='',
nettype = 'wire',
msb = 0,
lsb = 0
):
Object.__init__( self, name )
self.nettype = nettype
self.msb = msb
self.lsb = lsb
self.size = 0
self.sigtype = 'normal' # or 'clock' or 'reset' - should be an enumneration
self.module_ref = None
self.Calc_Size()
示例15: modifyModel
def modifyModel(field, newvalue):
dest = field.split(".")
nl = 0
key = None
# The first element is always the nature of the object
if dest[nl] == "object":
key = Object.findObject(dest[nl + 1])
nl = nl + 2
elif dest[nl] == "relation":
key = Object.findRelation(dest[nl + 1])
nl = nl + 2
elif dest[nl] == "library":
if dest[nl + 1] == "object":
key = Object.findLibObject(dest[nl + 2])
elif dest[nl + 1] == "relations":
key = Object.findLibRelation(dest[nl + 2])
else:
print ("There is no " + dest[nl + 1] + " field in the library!")
return
nl = nl + 3
else:
print ("The first field name is not recognized!")
return
# If we want to change the parent, we will change the string "extends"
if dest[nl] == "extends":
key = key.parent
key.parent = newvalue
nl += 1
# If we want to change properties, we will change one of its properties
elif dest[nl] == "properties":
key = key.properties
key[dest[nl + 1]] = newvalue
nl = nl + 2
# If we want to change 'relations', we will change the name of the relation
elif dest[nl] == "relations":
key = key.relations
key.remove(dest[nl + 1])
key.append(newvalue)
# If we want to change 'objects', we will change the name of the object
elif dest[nl] == "objects":
key = key.objects
key.remove(dest[nl + 1])
key.append(newvalue)
else:
print ("The field name is not recognized !")