本文整理汇总了Python中simpleguitk.create_frame函数的典型用法代码示例。如果您正苦于以下问题:Python create_frame函数的具体用法?Python create_frame怎么用?Python create_frame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_frame函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setupGUI
def setupGUI():
"""
Setup frame and other control objects for GUI
"""
global Frame,txtCurrentHeading,txtDesiredHeading,txtThrottle,txtRudder,btnCircle,btnJoystickControl
#Frame
Frame = gui.create_frame('Minnow Simulator', width, height)
Frame.set_draw_handler(drawHandler)
#========Text Boxes =====================================
txtCurrentHeading = Frame.add_input("Current Heading",txtHandler,100)
txtDesiredHeading = Frame.add_input("Desired Heading",txtHandler,100)
txtThrottle = Frame.add_input("Throttle Value",txtHandler,100)
txtRudder = Frame.add_input("Rudder Value",txtHandler,100)
#======= Buttons ==============================================
btnNorth = Frame.add_button("North",northHandler,50)
btnSouth = Frame.add_button("South",southHandler,50)
btnEast = Frame.add_button("East",eastHandler,50)
btnWest = Frame.add_button("West",westHandler,50)
lblCircle = Frame.add_label('Move_Circle')
btnCircleStart = Frame.add_button("start",circleStartHandler,25)
#====== Joystick Control =====================================================
lblJoystickControl = Frame.add_label('Joystick_Control')
btnJoystickControl = Frame.add_button("ON",joyControlHandler,50)
开发者ID:monica-p,项目名称:YorkU-Minnow,代码行数:28,代码来源:user_interface.py
示例2: demo2
def demo2():
# Create a frame and assign callbacks to event handlers
frame = simplegui.create_frame("Home", 300, 200)
frame.add_button("Click me", click)
frame.set_draw_handler(draw)
# Start the frame animation
frame.start()
开发者ID:tdongsi,项目名称:python,代码行数:8,代码来源:SimpleGuiDemo.py
示例3: __init__
def __init__(self):
"""
Initializer to create frame, sets handlers and initialize list of balls to be empty
"""
self.simulation = Simulation()
self._frame = simplegui.create_frame("ball/ball collision simulator",
CANVAS_WIDTH, CANVAS_HEIGHT)
self._frame.set_draw_handler(self.draw)
self._frame.set_mouseclick_handler(self.click)
self._prev_time = time.time()
self._frame_rate = 60.0
开发者ID:novneetnov,项目名称:Principles-Of-Computing---II,代码行数:11,代码来源:poc_physics_linear.py
示例4: __init__
def __init__(self):
"""
Create a frame and load the cancer data
"""
self._frame = simplegui.create_frame("Cancer risk visualization", CANVAS_WIDTH, CANVAS_HEIGHT)
self._frame.set_canvas_background("White")
self._frame.set_draw_handler(self.draw)
self._frame.add_input("Enter cutoff (scaled by 0.00001)", self.enter_cutoff, 200)
self._frame.add_button("Print data table in CSV", self.print_table, 200)
self._data_table = self.load_data()
self.enter_cutoff("0.0")
self._USA_Counties = simplegui.load_image(MAP_URL)
self._frame.start()
开发者ID:GauravKataria,项目名称:Algorithmic_Thinking_Coursera,代码行数:13,代码来源:user38_counties_simplegui_0.py
示例5: setup_frame
def setup_frame(self):
"""
Create GUI frame and add handlers.
"""
self._frame = simplegui.create_frame("Tic-Tac-Toe",
GUI_WIDTH,
GUI_HEIGHT)
self._frame.set_canvas_background('White')
# Set handlers
self._frame.set_draw_handler(self.draw)
self._frame.set_mouseclick_handler(self.click)
self._frame.add_button("New Game", self.newgame)
self._label = self._frame.add_label("")
开发者ID:chrisnatali,项目名称:minimax,代码行数:14,代码来源:poc_ttt_gui.py
示例6: createWorld
def createWorld(self):
world = gui.create_frame("Robot World",self.worldX,self.worldY)
world.set_canvas_background(GUI.WORLD_COLOR)
self.txtSetDist = world.add_input("Set Distance", self.txtDestDistance,50)
self.btnSetDist = world.add_button("Set Distance",self.setDistHandler,50)
self.btnMove = world.add_button("Move",self.moveHandler, 50)
timer = gui.create_timer(500,self.timerHandler)
world.set_draw_handler(self.renderingHandler)
timer.start()
world.start()
开发者ID:monica-p,项目名称:YorkU-Minnow,代码行数:14,代码来源:GUI.py
示例7: __init__
def __init__(self, wildfire):
"""
Create frame and timers, register event handlers
"""
self._fire = wildfire
self._grid_height = self._fire.get_grid_height()
self._grid_width = self._fire.get_grid_width()
self._frame = simplegui.create_frame("Interactive BFS demo",
self._grid_width * CELL_SIZE, self._grid_height * CELL_SIZE)
self._frame.set_canvas_background("White")
self._frame.add_button("Clear all", self.clear, 100)
self._frame.add_button("Step", self.step, 100)
self._frame.add_button("Ten steps", self.ten_steps, 100)
self._frame.set_mouseclick_handler(self.add_cell_index)
self._frame.set_draw_handler(self.draw)
开发者ID:novneetnov,项目名称:Principles-Of-Computing---II,代码行数:15,代码来源:poc_wildfire_gui_bfs.py
示例8: createFrame
def createFrame():
global FRAME_WIDTH, FRAME_HEIGHT
FRAME_NAME = 'Stopwatch - THE GAME'
#create frame
frame = simplegui.create_frame(FRAME_NAME, FRAME_WIDTH, FRAME_HEIGHT)
#add buttons to frame
frame = addButtons(frame)
#register frame event handlers
frame = setEventHandlers(frame)
return frame
开发者ID:CardenB,项目名称:pyGames,代码行数:15,代码来源:StopWatchGame.py
示例9: __init__
def __init__(self, game):
self._game = game
self._rows = game.get_grid_height()
self._cols = game.get_grid_width()
self._frame = simplegui.create_frame('2048',
self._cols * TILE_SIZE + 2 * BORDER_SIZE,
self._rows * TILE_SIZE + 2 * BORDER_SIZE)
self._frame.add_button('New Game', self.start)
self._frame.set_keydown_handler(self.keydown)
self._frame.set_draw_handler(self.draw)
self._frame.set_canvas_background("#BCADA1")
self._tiles = simplegui.load_image(IMAGE_URL)
self._directions = {"up": UP, "down": DOWN,
"left": LEFT, "right": RIGHT}
self._frame.start()
开发者ID:lingchunkai,项目名称:2048_ai,代码行数:15,代码来源:poc_2048_gui.py
示例10: __init__
def __init__(self, game):
self._cols = game.get_grid_height()
self._rows = game.get_grid_width()
self._frame = simplegui.create_frame(
"2048", self._rows * TILE_SIZE + 2 * BORDER_SIZE, self._cols * TILE_SIZE + 2 * BORDER_SIZE
)
self._frame.add_button("New Game", self.start)
self._frame.set_keydown_handler(self.keydown)
self._frame.set_draw_handler(self.draw)
self._frame.set_canvas_background("#A39480")
self._frame.start()
self._game = game
url = "http://codeskulptor-assets.commondatastorage.googleapis.com/assets_2048.png"
self._tiles = simplegui.load_image(url)
self._directions = {"up": UP, "down": DOWN, "left": LEFT, "right": RIGHT}
开发者ID:romperstomper,项目名称:pc,代码行数:15,代码来源:poc_2048_gui.py
示例11: __init__
def __init__(self, game):
"""
Initializer to create frame, sets handlers and initialize game
"""
self._frame = simplegui.create_frame("Mancala Solitaire",
CANVAS_SIZE[0], CANVAS_SIZE[1])
self._frame.set_canvas_background("White")
self._frame.set_draw_handler(self.draw)
self._frame.add_button("New board", self.new_board, 200)
self._frame.add_button("Restart board", self.restart_board, 200)
self._frame.add_button("Make move", self.make_move, 200)
self._frame.set_mouseclick_handler(self.click_move)
# fire up game and frame
self._game = game
self.new_board()
开发者ID:perfectgait,项目名称:simple_mancala,代码行数:16,代码来源:poc_mancala_gui.py
示例12: __init__
def __init__(self):
"""
Initialize the simulation
"""
self._frame = simplegui.create_frame("Monty Hall problem", CANVAS_WIDTH,
CANVAS_HEIGHT, CONTROL_WIDTH)
self._frame.set_canvas_background("White")
self._frame.add_button("Clear", self.clear, CONTROL_WIDTH)
self._frame.add_button("Add door", self.add_door, CONTROL_WIDTH)
self._frame.set_mouseclick_handler(self.click)
self._frame.add_label("")
self._win_label = self._frame.add_label("Wins = 0")
self._lose_label = self._frame.add_label("Loses = 0")
self.clear()
self._frame.set_draw_handler(self.draw)
self._frame.start()
开发者ID:novneetnov,项目名称:Principles-Of-Computing---I,代码行数:16,代码来源:monty_hall_gui.py
示例13: __init__
def __init__(self, puzzle):
"""
Create frame and timers, register event handlers
"""
self._puzzle = puzzle
self._puzzle_height = puzzle.get_height()
self._puzzle_width = puzzle.get_width()
self._frame = simplegui.create_frame("The Fifteen puzzle",
self._puzzle_width * TILE_SIZE,
self._puzzle_height * TILE_SIZE)
self._solution = ""
self._current_moves = ""
self._frame.add_button("Solve", self.solve, 100)
self._frame.add_input("Enter moves", self.enter_moves, 100)
self._frame.add_button("Print moves", self.print_moves, 100)
self._frame.set_draw_handler(self.draw)
self._frame.set_keydown_handler(self.keydown)
self._timer = simplegui.create_timer(50, self.tick)
self._timer.start()
self._frame.start()
开发者ID:flail-monkey,项目名称:principles1,代码行数:21,代码来源:poc_fifteen_gui.py
示例14: __init__
def __init__(self, simulation):
"""
Create frame and timers, register event handlers
"""
self._simulation = simulation
self._grid_height = self._simulation.get_grid_height()
self._grid_width = self._simulation.get_grid_width()
self._frame = simplegui.create_frame("Zombie Apocalypse simulation",
self._grid_width * CELL_SIZE,
self._grid_height * CELL_SIZE)
self._frame.set_canvas_background("White")
self._frame.add_button("Clear all", self.clear, 200)
self._item_type = OBSTACLE
label = LABEL_STRING + NAME_MAP[self._item_type]
self._item_label = self._frame.add_button(label,
self.toggle_item, 200)
self._frame.add_button("Humans flee", self.flee, 200)
self._frame.add_button("Zombies stalk", self.stalk, 200)
self._frame.set_mouseclick_handler(self.add_item)
self._frame.set_draw_handler(self.draw)
开发者ID:chrisnatali,项目名称:zombie,代码行数:21,代码来源:poc_zombie_gui.py
示例15: __init__
def __init__(self, game):
"""
Create frame and timers, register event handlers
"""
self.game = game
self.frame = simplegui.create_frame("Word Wrangler",
CANVAS_WIDTH, CANVAS_HEIGHT, 250)
self.frame.set_canvas_background("Blue")
self.enter_input = self.frame.add_input("Enter word for new game",
self.enter_start_word, 250)
labelmsg = "Stars correspond to hidden words formed using letters "
labelmsg += "from the entered word. Hidden words are listed in alphabetical order"
self.frame.add_label(labelmsg, 250)
self.frame.add_label("", 250)
self.guess_label = self.frame.add_input("Enter a word",
self.enter_guess, 250)
self.frame.add_label("For a hint, click on a starred word", 250)
self.frame.set_mouseclick_handler(self.peek)
self.frame.set_draw_handler(self.draw)
self.enter_input.set_text("python")
self.game.start_game("python")
开发者ID:flail-monkey,项目名称:principles1,代码行数:23,代码来源:poc_wrangler_gui.py
示例16: __init__
def __init__(self, game):
"""
Initialize GUI
"""
self._game = game
self._tiling_size = self._game.get_tiling_size()
self.init_grid()
canvas_width = 2 * EDGE_LENGTH + (3 * self._tiling_size * EDGE_LENGTH / 2)
canvas_height = (self._tiling_size + 1) * HEX_HEIGHT
self._frame = simplegui.create_frame("Tantrix Solitaire demo",
canvas_width, canvas_height)
self._frame.add_button("Is legal?", self.check_legal, 200)
self._frame.add_button("Yellow loop of length 10?", self.yellow_loop, 200)
self._frame.add_button("Red loop of length 10?", self.red_loop, 200)
self._frame.add_button("Blue loop of length 10?", self.blue_loop, 200)
self._frame.set_draw_handler(self.draw)
self._frame.set_canvas_background("White")
self._frame.set_mouseclick_handler(self.click)
self._frame.set_mousedrag_handler(self.drag)
self._frame.start()
self._mouse_drag = False
开发者ID:novneetnov,项目名称:Principles-Of-Computing---II,代码行数:23,代码来源:poc_tantrix_gui.py
示例17: enter
canvas.draw_text(message,(position[0],position[1]), 23, "Red")
# define enter handler
def enter(inp):
global message
message = inp
# define timer handler
def tick():
global position
x = random.randint(0,width)
y = random.randint(0,highest)
position[0] = x
position[1] = y
# create frame
frame = simplegui.create_frame("Test",width,highest)
timer = simplegui.create_timer(1000, tick)
# register draw handler
frame.set_draw_handler(draw)
frame.add_input("Enter Message",enter, 100)
# start frame
timer.start()
frame.start()
开发者ID:severalfly,项目名称:MyTest,代码行数:29,代码来源:canvasDraw.py
示例18: click
# CodeSkulptor runs Python programs in your browser.
# Click the upper left button to run this simple demo.
# CodeSkulptor runs in Chrome 18+, Firefox 11+, and Safari 6+.
# Some features may work in other browsers, but do not expect
# full functionality. It does NOT run in Internet Explorer.
import simpleguitk as simplegui
message = "Welcome!"
# Handler for mouse click
def click():
global message
message = "Good job!"
# Handler to draw on canvas
def draw(canvas):
canvas.draw_text(message, [50,112], 48, "Red")
# Create a frame and assign callbacks to event handlers
frame = simplegui.create_frame("Home", 300, 200)
frame.add_button("Click me", click)
frame.set_draw_handler(draw)
# Start the frame animation
frame.start()
开发者ID:yusong-shen,项目名称:POC_miniProject1,代码行数:27,代码来源:hello.py
示例19: start_timer
hits = 0
timer.stop()
# Event handler for timer with 0.1 sec interval
def start_timer():
global started, time
if started == True:
time += 1
# Draw handler
def draw(canvas):
canvas.draw_text(format(time), [80, 170], 40, "Teal")
canvas.draw_text(str(hits) + "/" + str(count), [225, 45], 20, "Magenta")
# Create frame
frame = simplegui.create_frame("Stopwatch Game", 300, 300)
timer = simplegui.create_timer(100, start_timer)
# Register event handlers
frame.set_draw_handler(draw)
frame.add_button("Stop", stop_button, 100)
frame.add_button("Start", start_button, 100)
frame.add_button("Reset", reset, 100)
# start frame
frame.start()
timer.start()
开发者ID:cyrne2,项目名称:stopwatch,代码行数:30,代码来源:stopwatch.py
示例20: keyup
if key == simplegui.KEY_MAP['left']:
selected_shape.rotate(-fine_tuning)
if key == simplegui.KEY_MAP['right']:
selected_shape.rotate(fine_tuning)
if key == simplegui.KEY_MAP['up']:
selected_shape.rotate(-coarse_tuning)
if key == simplegui.KEY_MAP['down']:
selected_shape.rotate(coarse_tuning)
##def keyup(key):
## global selected_shape
## if selected_shape is not None:
## if key in [simplegui.KEY_MAP['left'], simplegui.KEY_MAP['right'], simplegui.KEY_MAP['up'], simplegui.KEY_MAP['down']]:
## selected_shape.rotate(0)
# 创建用户界面
frame = simplegui.create_frame("七巧板", WIDTH, HEIGHT)
frame.set_canvas_background("White")
frame.set_draw_handler(draw)
frame.set_mouseclick_handler(click)
frame.set_mousedrag_handler(drag)
frame.set_keydown_handler(keydown)
#frame.set_keyup_handler(keyup)
# 创建按钮
frame.add_button("重新开始", init, 80)
init()
frame.start()
开发者ID:wzmdream,项目名称:similarity_check,代码行数:30,代码来源:qiqiaoban_solution.py
注:本文中的simpleguitk.create_frame函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论