本文整理汇总了Python中simpleguitk.create_frame函数的典型用法代码示例。如果您正苦于以下问题:Python create_frame函数的具体用法?Python create_frame怎么用?Python create_frame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_frame函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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()
示例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
示例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()
示例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("")
示例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()
示例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)
示例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
示例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()
示例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}
示例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()
示例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()
示例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()
示例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)
示例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")