本文整理汇总了Python中program.Program.run方法的典型用法代码示例。如果您正苦于以下问题:Python Program.run方法的具体用法?Python Program.run怎么用?Python Program.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类program.Program
的用法示例。
在下文中一共展示了Program.run方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from program import Program [as 别名]
# 或者: from program.Program import run [as 别名]
def main():
app = None
try:
from program import Program # основной класс программы
# Запуск приложения.
app = Program()
app.run()
except Exception as exc:
print(traceback.format_exc())
traceback.print_exc(file=open("{}/error.log".format(
os.path.split(os.path.abspath(sys.argv[0]))[0]), "w"))
if app: # очищаем экран приложения от всех виджетов
app.start_screen.clear_widgets()
class Error(App):
"""Выводит экран с текстом ошибки."""
def callback_report(self, *args):
"""Функция отправки баг-репорта"""
try:
import webbrowser
import six.moves.urllib
txt = six.moves.urllib.parse.quote(
self.win_report.txt_traceback.text.encode(
"utf-8"))
url = "https://github.com/HeaTTheatR/KivyCleanMasterDemo" \
"/issues/new?body=" + txt
webbrowser.open(url)
except Exception:
sys.exit(1)
def build(self):
self.win_report = BugReporter(
callback_report=self.callback_report, txt_report=str(exc),
icon_background="Data/Images/logo.png")
return self.win_report
Error().run()
示例2: main
# 需要导入模块: from program import Program [as 别名]
# 或者: from program.Program import run [as 别名]
def main():
args = parse_args()
debug.IS_DEBUG = args.debug
src = args.src
public_var_definition = re.compile(PUBLIC_VAR_DEFINITION_PATTERN)
func_definition = re.compile(FUNC_DEFINITION_PATTERN)
attribs_definition = re.compile(ATTRIBS_DEFINITION_PATTERN)
line = src.readline()
while line:
line = line.strip()
if line.startswith(';') or len(line) == 0:
line = src.readline()
continue
# public variables
elif line.startswith('@'):
result = public_var_definition.match(line)
if result is None:
raise Exception('FUCK')
values = result.groupdict()
globs[values['name']] = parse_llvm_str(values['value'])
elif line.startswith('define'):
# functions
result = func_definition.match(line)
if result is not None:
values = result.groupdict()
funcs[values['name']] = {'return_type': values['return_type'],
'attribs': values['attribs'],
'params': parse_func_params(values['params']),
'content': parse_func(src)}
else:
raise Exception('FUCK')
elif line.startswith('attributes'):
result = attribs_definition.match(line)
if result is not None:
values = result.groupdict()
attribs[values['name']] = values['content']
else:
raise Exception('FUCK')
elif line.startswith('target'):
parts = line.split(' ')
unknown['target'][parts[1]] = parts[3]
else:
print('ignoring: ' + line)
line = src.readline()
if debug.IS_DEBUG:
print('unkonwn:')
print(unknown)
print('globs:')
print(globs)
print('funcs')
print(funcs)
print('attribs:')
print(attribs)
prog = Program(unknown, globs, funcs, attribs)
print "=============== RUNNING ==============="
prog.run()
示例3: GushPiBot
# 需要导入模块: from program import Program [as 别名]
# 或者: from program.Program import run [as 别名]
#.........这里部分代码省略.........
self.add_component("Audio", self.audio)
def create_echo(self):
self.echo = Echo(self.display)
self.echo.stop_handler.add(self.wheels.stop)
self.add_component("Echo", self.echo)
def create_keyboard(self):
self.keyboard = Keyboard(self.display.stdscr)
self.keyboard.handlers["UP"].add(self.wheels.forwards)
self.keyboard.handlers["DOWN"].add(self.wheels.backwards)
self.keyboard.handlers["LEFT"].add(self.wheels.left)
self.keyboard.handlers["RIGHT"].add(self.wheels.right)
self.keyboard.handlers["."].add(self.wheels.stop)
self.keyboard.handlers["{"].add(self.wheels.slow_left)
self.keyboard.handlers["}"].add(self.wheels.slow_right)
self.keyboard.handlers["CTRL+X"].add(self.pi_shutdown)
self.keyboard.handlers["PAGEDOWN"].add(self.menu.next)
self.keyboard.handlers["PAGEUP"].add(self.menu.prev)
self.keyboard.handlers["RETURN"].add(self.menu.select)
self.keyboard.handlers["ESC"].add(self.exit)
try:
self.keyboard.handlers["#"].add(self.webcam.take_photo)
except AttributeError:
pass
self.add_component("Keyboard", self.keyboard)
def create_webserver(self):
self.webserver = Webserver()
self.webserver.post_handlers["up"] = self.wheels.forwards
self.webserver.post_handlers["down"] = self.wheels.backwards
self.webserver.post_handlers["left"] = self.wheels.left
self.webserver.post_handlers["right"] = self.wheels.right
self.webserver.post_handlers["stop"] = self.wheels.stop
self.webserver.post_handlers["menu_next"] = self.menu.next
self.webserver.post_handlers["menu_prev"] = self.menu.prev
self.webserver.post_handlers["menu_select"] = self.menu.select
self.webserver.post_handlers["menu_text"] = self.menu.text
try:
self.webserver.post_handlers["photo"] = self.webcam.take_photo
except AttributeError:
pass
self.webserver.serve()
self.add_component("Webserver", self.webserver)
def create_menu(self):
self.display.display("GushPiBot...\nCreating menu")
self.menu = Menu(self.display)
def update_menu(self):
for item in self.components:
item.update_menu(self.menu)
menu = self.menu.add_folder("System")
self.menu.add_function("Exit", self.exit, menu)
self.menu.add_function("Shutdown RasPi", self.pi_shutdown, menu)
self.menu.add_function("IP Address", self.display_ip, menu)
try:
self.menu.speech = self.speech
except AttributeError:
pass
def run(self, program=None):
if program:
self.display.display("GushPiBot...\nRunning...")
self.program.set(program)
self.program.view()
self.program.run()
else:
self.display.display("GushPiBot...\nListening...")
while self.loop_cycle():
time.sleep(0.1)
def display_ip(self):
p = Popen("hostname -I", shell=True, stdout=PIPE)
output = p.communicate()[0].split("\n")[0]
self.display.display_at(1, 0, output.ljust(16))
def exit(self):
self.display.display("GushPiBot...\nExiting...")
self.active = False
def loop_cycle(self):
for item in self.components:
item.check()
return self.active
def cleanup(self):
for item in self.components:
try:
item.cleanup()
except:
pass
def pi_shutdown(self):
self.display.display("Pi Shutdown")
try:
self.speech.speak("Shutting down Raspberry Pi")
except AttributeError:
pass
call('halt', shell=False)
示例4: Main
# 需要导入模块: from program import Program [as 别名]
# 或者: from program.Program import run [as 别名]
def Main():
program = Program()
program.run(42)
示例5: Program
# 需要导入模块: from program import Program [as 别名]
# 或者: from program.Program import run [as 别名]
from canvas import Screen
from world import World
from forms import Point, Line, Cube, Polygon, House, PointyRoof, TriangleRoof, SlopedRoofXpositive, SlopedRoofXnegative, RandomRoof, Street
from program import Program
# Setting up a 3D scene:
# (1) Initialize a Program:
# This is the frame which holds the program
# (2) Setup a camera:
# This camera references a canvas that is drawn to the screen by the program
# (3) Initialize a world:
# Setup the world and fill it with shapes which have to be displayable
# (4) Look at the world through the camera.
# (5) Run the program.
program = Program()
cam = Camera(program.getScreen())
world = World()
world.addShapes([
Street(Point(-4, 0, -10), 1.5, 1, 10)
])
cam.lookAt(world)
program.run()