本文整理汇总了Python中console.Console类的典型用法代码示例。如果您正苦于以下问题:Python Console类的具体用法?Python Console怎么用?Python Console使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Console类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
def render(self, screen):
"""
Surface tekent layer, de rest gaat op de layer, en screen tekent de surface.
:param screen: self.screen van partyscreen
"""
self.surface.blit(self.layer, (0, self.lay_rect.y - self.rect.y))
self.layer.blit(self.background, (0, 0))
# zwarte background achter de titel. is voor scrollen.
pygame.draw.rect(self.surface, COLORKEY, pygame.Rect(TITLERECT))
self.surface.blit(self.title, (self.title_x, self.title_y))
# zwarte omranding ná de titel, omdat de titel uitsteekt.
pygame.draw.rect(self.surface, self.linecolor, self.surface.get_rect(), 1)
for index, row in enumerate(self.view_matrix):
for row_nr, columnx in enumerate(self.total_columns):
if columnx[0] == ColumnType.icon:
self.layer.blit(
row[row_nr],
(columnx[1], self.columnsy + self.iconoffset + index * self.rowheight))
elif columnx[0] == ColumnType.text:
self.layer.blit(
row[row_nr],
(columnx[1], self.columnsy + index * self.rowheight))
else:
Console.error_unknown_column_key()
raise KeyError
if self.lay_rect.y - self.rect.y < 0:
self.surface.blit(self.up_arrow, (self.box_width + ARROWRIGHT, ARROWTOP))
if self.lay_rect.y - self.rect.y - BOTTOMSPACER > self.rect.height - self.layer_height:
self.surface.blit(self.down_arrow, (self.box_width + ARROWRIGHT, self.box_height + ARROWBOTTOM))
screen.blit(self.surface, self.rect.topleft)
示例2: explore
def explore(fpath):
_, ext = splitext(fpath)
ftype = 'data' if ext in ('.h5', '.hdf5') else 'simulation'
print("Using {} file: '{}'".format(ftype, fpath))
if ftype == 'data':
globals_def, entities = entities_from_h5(fpath)
simulation = Simulation(globals_def, None, None, None, None,
entities.values(), 'h5', fpath, None)
period, entity_name = None, None
else:
simulation = Simulation.from_yaml(fpath)
# use output as input
simulation.data_source = H5Source(simulation.data_sink.output_path)
period = simulation.start_period + simulation.periods - 1
entity_name = simulation.default_entity
dataset = simulation.load()
data_source = simulation.data_source
data_source.as_fake_output(dataset, simulation.entities_map)
data_sink = simulation.data_sink
entities = simulation.entities_map
if entity_name is None and len(entities) == 1:
entity_name = entities.keys()[0]
if period is None and entity_name is not None:
entity = entities[entity_name]
period = max(entity.output_index.keys())
eval_ctx = EvaluationContext(simulation, entities, dataset['globals'],
period, entity_name)
try:
c = Console(eval_ctx)
c.run()
finally:
data_source.close()
if data_sink is not None:
data_sink.close()
示例3: start_console
def start_console():
print("Welcome to the Shadowrun Combat Manager")
print("type \"exit\" to close. Type \"help\" for a list of commands for for details on a specific command")
print()
console = Console()
add_default_commands(console)
console.run_console()
示例4: __init__
def __init__(self):
self.rng = RNG()
self.entities = []
self.active_entities = []
self.dungeon = None
self.message_log = None
self.menu = None
self.overlay = None
self.tile_types = {}
self.materials = {}
self.words = {}
self.status_effects = {}
self.traits = {}
self.abilities = {}
self.breeds = {}
self.prefabs = {}
self.active_region = []
self.player = None
self.fps=0
self.map_con = Console("Dungeon Map",MAP_X,MAP_Y,MAP_W,MAP_H)
self.panel_con = Console("Side Panel",PANEL_X,PANEL_Y,PANEL_W,PANEL_H)
self.log_con = Console("Message Log",LOG_X,LOG_Y,LOG_W,LOG_H)
self.state = STATE_PLAYING
self.input_state = INPUT_NORMAL
self.key = libtcod.Key()
self.mouse = libtcod.Mouse()
示例5: explore
def explore(fpath):
_, ext = splitext(fpath)
ftype = 'data' if ext in ('.h5', '.hdf5') else 'simulation'
print("Using %s file: '%s'" % (ftype, fpath))
if ftype == 'data':
globals_def, entities = entities_from_h5(fpath)
data_source = H5Data(None, fpath)
h5in, _, globals_data = data_source.load(globals_def, entities)
h5out = None
simulation = Simulation(globals_def, None, None, None, None,
entities.values(), None)
period, entity_name = None, None
else:
simulation = Simulation.from_yaml(fpath)
h5in, h5out, globals_data = simulation.load()
period = simulation.start_period + simulation.periods - 1
entity_name = simulation.default_entity
entities = simulation.entities_map
if entity_name is None and len(entities) == 1:
entity_name = entities.keys()[0]
if period is None and entity_name is not None:
entity = entities[entity_name]
period = max(entity.output_index.keys())
eval_ctx = EvaluationContext(simulation, entities, globals_data, period,
entity_name)
try:
c = Console(eval_ctx)
c.run()
finally:
h5in.close()
if h5out is not None:
h5out.close()
示例6: __init__
class Sandy:
_settings = {}
def __init__(self):
self.console = Console()
def start_console(self):
self.console.run()
示例7: write_cfg
def write_cfg(self):
"""
Schrijf settings naar config bestand.
"""
with open(SETTINGSFILE, 'wb') as f:
pickle.dump([self.fullscreen, self.window_frame], f)
Console.write_settings()
示例8: write_cfg
def write_cfg(self):
"""
Schrijf settings naar config bestand.
"""
with open(SETTINGSFILE, 'wb') as f:
pickle.dump([self.music, self.sound], f)
Console.write_settings()
示例9: Widget
class Widget(QDialog):
def __init__(self, parent=None):
super(Widget, self).__init__(parent)
self.View = View(config.enosPath)
self.console = Console()
self.View.setFocusPolicy(Qt.StrongFocus)
lt = QVBoxLayout()
lt.addWidget(self.View)
lt.addWidget(self.console)
self.setLayout(lt)
self.View.focusOut.connect(self.switchFocus)
# fake View's focus out
self.View.focusOutEvent('')
self.console.setFocus()
self.focus = 'console'
self.console.focusOut.connect(self.switchFocus)
def keyPressEvent(self, ev):
ch = ev.text()
super(Widget, self).keyPressEvent(ev)
def switchFocus(self):
if self.focus == 'console':
self.View.setFocus()
self.focus = 'View'
else:
self.console.setFocus()
self.focus = 'console'
示例10: delete
def delete(filename):
"""
Delete een opgeslagen spelbestand.
:param filename: het gekozen bestandsnaam uit de lijst
"""
Console.delete_gamedata()
filename = os.path.join(SAVEPATH, filename)
os.remove(filename)
示例11: ConsoleTests
class ConsoleTests(unittest.TestCase):
def setUp(self):
self.console = Console("Test","Test Console")
def test_console_lookup(self):
"""
Console lookup should do a few things:
1) It should return the object from supported_consoles
2) It should return the same instance every time
3) It should return None when the console of that name is not found
"""
# 1
self.assertTrue(console_lookup("GBA") in supported_consoles)
# 2
self.assertEqual(console_lookup("GBA"),gba)
self.assertEqual(console_lookup("GBA"),gba)
# 3
self.assertTrue(console_lookup("Random String") == None)
# @unittest.skip("Not yet implemented")
# def test_find_all_roms(self):
# pass
#
# @unittest.skip("Not yet implemented")
# def test_find_all_roms_for_console(self):
# pass
def test_roms_directory(self):
"""
The ROMs directory for a console should be the ROMs directory from
filesystem_helper, except the directory name should be equal to the
shortname for the console
"""
gba_dir = self.console.roms_directory()
self.assertEqual(os.path.dirname(gba_dir),filesystem_helper.roms_directory())
self.assertEqual(os.path.basename(gba_dir),self.console.shortname)
def test_executables_directory(self):
"""
The executables directory for a console should be a directory located
in the main executables directory, and the consoles directory should be
named the same as the shortname of the console
"""
gba_dir = self.console.executables_directory()
self.assertEqual(os.path.dirname(gba_dir),filesystem_helper.executables_directory())
self.assertEqual(os.path.basename(gba_dir),self.console.shortname)
def test_icon_path(self):
"""
The icon path for a console should be in the icons directory, and the
file should be named the shortname of the console with a .png extension
"""
gba_path = self.console.icon_path()
self.assertEqual(os.path.dirname(gba_path),filesystem_helper.icons_directory())
self.assertEqual(os.path.basename(gba_path),self.console.shortname + ".png")
示例12: setup_console
def setup_console(self):
#setup dock
dockWidget = QtGui.QDockWidget('console', self)
dockWidget.setAllowedAreas(Qt.BottomDockWidgetArea)
self.addDockWidget(Qt.BottomDockWidgetArea, dockWidget)
#setup console in it
console = Console()
console.setFixedHeight(100)
dockWidget.setWidget(console)
self.console = console
示例13: do_help
def do_help(self, arg):
if arg in ('status', 'query', 'result', 'config', 'exit'):
Console.do_help(self, arg)
else:
print "\n".join(['These are the accepted commands.',
'Type help <command> to get help on a specific command.',
'',
'status Show summary of system status.',
'query Manipulate and run query.',
'result Show result of a query.',
'config Set config variables.',
'exit Exit application.'])
示例14: execute_script
def execute_script(script, test_code, extra_locals, files):
soft, hard = resource.getrlimit(resource.RLIMIT_CPU)
resource.setrlimit(resource.RLIMIT_CPU, (10, hard))
checker = Console(locals_=extra_locals, files=files)
feedback = checker.run_tests(script, test_code)
output = checker.output
return_code = 0
if feedback:
return_code = 1
new_locals = checker.get_locals()
resource.setrlimit(resource.RLIMIT_CPU, (soft, hard))
return return_code, output, feedback, new_locals
示例15: remove
def remove(self, hero):
"""
Haal heroes weg uit de party
:param hero: Hero Object
"""
if hero.RAW == 'alagos':
Console.error_leader_not_leave_party()
raise AttributeError
elif hero.RAW in self:
del self[hero.RAW]
else:
Console.error_hero_not_in_party(hero.NAM, self.NAM)
raise AttributeError