本文整理汇总了Python中engine.Engine.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.stop方法的具体用法?Python Engine.stop怎么用?Python Engine.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类engine.Engine
的用法示例。
在下文中一共展示了Engine.stop方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Car
# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import stop [as 别名]
class Car(object):
# constructor
def __init__(self):
config = ConfigParser()
config.sections()
config.read('config.ini')
self.engineLeft = Engine(config.getint('EngineLeft', 'A'), config.getint('EngineLeft', 'B'), config.getint('EngineLeft', 'E'), 'EngineLeft')
self.engineRight = Engine(config.getint('EngineRight', 'A'), config.getint('EngineRight', 'B'), config.getint('EngineRight', 'E'), 'EngineRight')
# stop engine
def stop(self):
self.engineLeft.stop()
self.engineRight.stop()
# drive forward
def forward(self, speed):
self.engineLeft.forward(speed)
self.engineRight.forward(speed)
# drive backward
def backward(self, speed):
self.engineLeft.backward(speed)
self.engineRight.backward(speed)
# turn right
def turnRight(self, turn):
self.engineRight.setTurn(turn)
# turn left
def turnLeft(self, turn):
self.engineLeft.setTurn(turn)
示例2: GesDemo
# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import stop [as 别名]
class GesDemo():
'''User Interface class'''
def __init__(self):
'''Initialize the User Interface and the GES Engine'''
self.engine = Engine()
self.clips = {}
# we import the gtk objects from glade and create our GtkStore and TreeView
self.builder = Gtk.Builder()
self.builder.add_from_file(os.path.join(os.path.curdir, \
"py-ges-demo.glade"))
self.builder.connect_signals(self)
self.timeline_treeview = self.builder.get_object("timeline_treeview")
#id, uri, start, duration, in point
self.timeline_store = Gtk.ListStore(int, str, long, long, long)
self.timeline_treeview.set_model(self.timeline_store)
self.timeline_current_iter = None #To keep track of the cursor
self.start_entry = self.builder.get_object("start_entry")
self.duration_scale = self.builder.get_object("duration_scale")
self.in_point_scale = self.builder.get_object("in_point_scale")
self.window = self.builder.get_object("window")
self.window.show_all()
def _clip_selected(self, widget):
'''Method connected to the selection-changed signal of the TreeView'''
model, row_iter = self.timeline_treeview.get_selection().get_selected()
if row_iter is None:
self.engine.prioritize(None)
else:
idf = self.timeline_store.get_value(row_iter, 0)
self.engine.prioritize(self.clips[idf][5])
print "active clip: ", self.clips[idf]
self._update_properties_box(idf)
def _update_properties_box(self, idf):
'''Method to update the properties box with the information of the selected clip'''
clip = self.clips[idf]
self.start_entry.set_text(str(clip[1]))
self.duration_scale.set_range(0, clip[4] - clip[3])
self.duration_scale.set_value(clip[2])
self.in_point_scale.set_range(0, clip[4])
self.in_point_scale.set_value(clip[3])
def _play_activate_cb(self, widget):
'''Method connected to the Play button'''
self.engine.play()
def _stop_activate_cb(self, widget):
'''Method connected to the Stop button'''
self.engine.stop()
def _add_file_activated_cb(self, widget):
'''Method connected to the Add File button'''
filechooser = Gtk.FileChooserDialog(action=Gtk.FileChooserAction.OPEN,
buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
response = filechooser.run()
if response != Gtk.ResponseType.OK:
filechooser.destroy()
return
filepath = filechooser.get_filename()
if filepath and os.access(filepath, os.R_OK):
filechooser.destroy()
self.add_file(filepath)
def add_file(self, filepath):
'''Method that adds the file to the GtkStore and GESTimeline'''
idf = len(self.clips) # id field is a counter
uri = Gst.filename_to_uri (filepath) # conver the filepath into a valid URI
duration, tlobj = self.engine.add_file(uri) # add the uri to the GESTimeline
# add to the GtkStore and internal list
self.timeline_store.append([idf, os.path.basename(filepath), 0,
duration, 0])
# clips[id] = uri, start, duration, in_point, max_duration, timelineobj
self.clips[idf] = [uri, 0, duration, 0, duration, tlobj]
def _delete_activate_cb(self, widget):
'''Method connected to the Delete button'''
print "delete"
def _start_changed(self, widget):
'''Method connected to the Changed event of the start entry'''
new_start = widget.get_text()
print "new start entered", new_start
# find the selected clip
model, row_iter = self.timeline_treeview.get_selection().get_selected()
idf = self.timeline_store.get_value(row_iter, 0)
self.clips[idf][1] = new_start
# set the new value to the Gtk TreeStore
try:
#.........这里部分代码省略.........
示例3: Wolfgang
# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import stop [as 别名]
#.........这里部分代码省略.........
# A list of tracks (and URIs) in a dic of albums in a dic of artists:
if not Gst.uri_is_valid(uri):
uri = Gst.filename_to_uri(uri)
if artist not in self.library:
self.library[artist] = {}
artist_iter = self.library_store.append(None, [artist])
if album not in self.library[artist]:
self.library[artist][album] = []
self.library_store.append(artist_iter, [album])
else:
if album not in self.library[artist]:
column = 0
artist_iter = self.library_store.get_iter_first()
while (artist != \
self.library_store.get_value (artist_iter, column)) and \
(artist != None):
artist_iter = self.library_store.iter_next (artist_iter)
self.library[artist][album] = []
self.library_store.append(artist_iter, [album])
self.library[artist][album].append([title, uri, track])
"""
UI methods and callbacks
"""
def previous(self, unused_widget=None):
if self.queue_current_iter is None:
return False
prev_iter = self.queue_store.iter_previous(self.queue_current_iter)
if prev_iter is None:
return False
self.uri = self.queue_store.get_value(prev_iter, 2)
self.engine.stop()
self.play()
# remove the ♪ cursor
self.queue_store.set_value(self.queue_current_iter, 0, "")
self.queue_store.set_value(prev_iter, 0, "♪")
self.queue_current_iter = prev_iter
self.next_button.set_sensitive(True)
if not self.queue_store.iter_previous(self.queue_current_iter):
self.previous_button.set_sensitive(False)
def _play_pause(self, widget):
"""
Callback for the Play pushbutton
"""
if widget.props.active:
self.play()
else:
self.pause()
def next(self, unused_widget=None):
if self.queue_current_iter is None:
return False
next_iter = self.queue_store.iter_next(self.queue_current_iter)
if next_iter is None:
return False
self.uri = self.queue_store.get_value(next_iter, 2)
self.engine.stop()
self.play()
# remove the ♪ cursor
self.queue_store.set_value(self.queue_current_iter, 0, "")
self.queue_store.set_value(next_iter, 0, "♪")
self.queue_current_iter = next_iter
self.previous_button.set_sensitive(True)
示例4: __init__
# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import stop [as 别名]
class Application:
def __init__(self):
self.clock = pygame.time.Clock()
self.fps = 30.0
self.camera = None
self.handler = None
self.engine = None
self.audio = None
def set_caption(self):
pygame.display.set_caption("RTS Project - {:.2f}".format(self.clock.get_fps()))
def start(self):
self.engine = Engine(800, 600)
load_textures(self.engine)
while True:
r = self.menu_loop()
if not r:
break
self.engine.stop()
print('Goodbye')
def menu_loop(self):
m = Menu(self.engine)
m.menu_start()
while True:
s = m.update()
m.render()
self.engine.render()
if s['clicked'] is not None:
break
if s['clicked'] in ['Campaign', 'Skirmish']:
game = Game('Test 1', FutureWar)
worldmap = Map.from_csv("World map", "textures", MAP_PATH + r"\worldmap.csv")
#worldmap = Map.from_csv("World map", "textures", MAP_PATH + r"\smallmap.csv")
print("worldmap width = ", worldmap.width)
print("worldmap height = ", worldmap.height)
world = game.set_world(worldmap)
player = game.create_player("Bob", "RedScum", Colors.YELLOW, 100, 100, 0, 0)
game.create_player("Hicks", "BlueAngels", Colors.SKY_BLUE, 0, 0, 0, 0)
game.create_player("Neutral", "BlueAngels", Colors.GREY, 20, 20, 0, 0)
game.create_unit("Bob", "Soldier", 1, 1, 1.0)
game.create_unit("Bob", "Elite", 3, 3, 0.5)
game.create_unit("Bob", "Heavy", 2, 5, 0.5)
game.create_unit("Neutral", "Defender", 20, 20, 1.0)
#plant = Building(Hicks, x=4, y=4, profile=FutureWar.get_profile("barracks"), constructed=1, plife=0.50)
#s1 = Unit(Hicks, x=9, y=9, profile=FutureWar.get_profile("soldier"), plife=0.50)
#writeln(f"plant life = {plant.life}")
self.camera = Camera(800, 600, world, player, self.engine)
self.handler = InputHandler(self.camera, auto_scroll_zone=-1)
self.audio = AudioHandler(AUDIO_PATH)
#self.audio.play("ds.ogg")
r = self.game_loop(game)
return r
elif s['clicked'] == 'Options':
pass
elif s['clicked'] == 'Quit':
return False
def in_game_menu_loop(self):
m = Menu(self.engine)
m.menu_pause()
while True:
s = m.update()
m.render()
self.engine.render()
if s['clicked'] is not None: break
if s['clicked'] == 'Options':
pass
else:
return s['clicked']
def game_loop(self, game):
start_time = pygame.time.get_ticks()
self.clock.tick(self.fps)
while True:
res_gam = game.update()
res_han = self.handler.update()
self.camera.render()
self.engine.render()
self.clock.tick(self.fps)
self.set_caption()
if not res_han:
self.audio.pause()
r = self.in_game_menu_loop()
if r != 'Resume':
break
self.audio.resume()
self.handler.resume()
if not res_gam:
r = 'Game Finished'
break
if r in ('Game Finished', 'Quit'):
print('Game has ended.')
end_time = pygame.time.get_ticks()
#.........这里部分代码省略.........
示例5: open
# 需要导入模块: from engine import Engine [as 别名]
# 或者: from engine.Engine import stop [as 别名]
__author__ = 'peter.tillotson'
from engine import Engine
import logging, os, yaml
cwd = os.getcwd()
if cwd.endswith('src'):
os.chdir('..')
config = yaml.load( open('config.yml') )
levels = {
'debug': logging.DEBUG,
'critical' : logging.CRITICAL,
'error': logging.ERROR,
'info' : logging.INFO,
'warn' : logging.WARN
}
level = levels.get(config['defaults']['logging']['level'].strip().lower())
format = config['defaults']['logging']['format']
logging.basicConfig(level=level, format=format)
engine = Engine( config )
try:
engine.start()
engine.stop()
except Exception as e:
logging.exception(e)
finally:
engine.close()