本文整理汇总了Python中simplegui.create_frame函数的典型用法代码示例。如果您正苦于以下问题:Python create_frame函数的具体用法?Python create_frame怎么用?Python create_frame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_frame函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
self.drag_manager = DragManager()
self.apoint = Point((10,110))
self.drag_manager.add_dragable_item(self.apoint)
self.bpoint = Point((30,110))
self.drag_manager.add_dragable_item(self.bpoint)
self.cpoint = Point((50,110))
self.drag_manager.add_dragable_item(self.cpoint)
self.arectangle = Rectangle((20,20),(40,220)) # a square is a rectangle smh
#self.drag_manager.add_dragable_item(self.arectangle)
self.arectangle1 = Rectangle((40,200),(300,220))
self.arectangle2 = Rectangle((280,20),(300,220))
self.arectangle3 = Rectangle((20,20),(300,40))
self.acircle = Circle((100,300),50)
self.drag_manager.add_dragable_item(self.acircle)
self.aball = Ball()
#self.drag_manager.add_dragable_item(self.aball)
#self.aball.walls.append(self.arectangle)
self.apaddle = Paddle((45,41),(55,91))
self.apaddle.walls.append(self.arectangle1)
self.apaddle.walls.append(self.arectangle3)
self.bpaddle = Paddle((265,41),(275,91))
self.bpaddle.walls.append(self.arectangle1)
self.bpaddle.walls.append(self.arectangle3)
self.ab2 = Ball((43,151),5,(-100.0,55.0))
self.ab2.color = "purple"
self.ab2.walls.append(self.arectangle)
self.ab2.walls.append(self.arectangle1)
self.ab2.walls.append(self.arectangle2)
self.ab2.walls.append(self.arectangle3)
self.ab2.walls.append(self.apaddle)
self.ab2.walls.append(self.bpaddle)
self.drag_manager.add_dragable_item(self.bpaddle)
self.drag_manager.add_dragable_item(self.apaddle)
self.drag_manager.add_dragable_item(self.ab2)
self.atri = Triangle((25,200),(40,240),(60,150))
self.drag_manager.add_dragable_item(self.atri)
self.frame = simplegui.create_frame('Testing', 400, 400)
self.frame.set_draw_handler(self.draw)
self.frame.set_mouseclick_handler(self.mouse_click_handler)
self.frame.set_mousedrag_handler(self.mouse_drag_handler)
self.frame.set_keydown_handler(self.key_down)
self.frame.start()
开发者ID:semisided1,项目名称:cousera-iip,代码行数:60,代码来源:user39_p5sfay9PXvgTHc2_11.py
示例2: rock_spawner
def rock_spawner():
global rock_group
if started:
if len(rock_group) < 12:
rock_pos = [random.randrange(0, WIDTH), random.randrange(0, HEIGHT)]
rock_vel = [random.random() * ROCK_VEL_FACTOR - ROCK_VEL_FACTOR / 2, random.random() * ROCK_VEL_FACTOR - ROCK_VEL_FACTOR / 2]
rock_avel = random.random() * ROCK_AVEL_FACTOR - ROCK_AVEL_FACTOR / 2
a_rock = Sprite(rock_pos, rock_vel, 0, rock_avel, asteroid_image, asteroid_info)
# add rock to group only if its not colliding with the ship
if not a_rock.collide(my_ship):
rock_group.add(a_rock)
# Main part
# Declare frame
frame = simplegui.create_frame("Asteroids", WIDTH, HEIGHT)
# initialize ship and two sprites
my_ship = Ship([WIDTH / 2, HEIGHT / 2], [0, 0], 0, ship_image, ship_info)
rock_group = set([])
explosions_group = set([])
missiles_group = set([])
# register handlers
frame.set_keyup_handler(keyup)
frame.set_keydown_handler(keydown)
frame.set_mouseclick_handler(click)
frame.set_draw_handler(draw)
timer = simplegui.create_timer(1000.0, rock_spawner)
# get things rolling
timer.start()
frame.start()
开发者ID:dkonst001,项目名称:Python-examples,代码行数:32,代码来源:new2.py
示例3: handle_gui_frame
def handle_gui_frame():
gframe = simplegui.create_frame( "Electronic Stop Watch", 200, 200)
gframe.set_draw_handler(draw_text_to_canvas)
gframe.add_button( "Start", start_stop_watch, 150)
gframe.add_button( "Stop", stop_stop_watch, 150)
gframe.add_button( "Reset", reset_stop_watch, 150)
gframe.start()
开发者ID:otasowieosifo,项目名称:courserepo,代码行数:7,代码来源:stopwatch.py
示例4: gameWindow_init
def gameWindow_init():
global pong_frame, reset_timer
# Create Game Window
pong_frame = simplegui.create_frame("Pong", roomRect.getWidth(), roomRect.getHeight(), 300)
game_instructions = []
game_instructions.append(pong_frame.add_label("Welcome to Pong!"))
game_instructions.append(pong_frame.add_label(""))
game_instructions.append(pong_frame.add_label("Up and Down arrow keys control the Blue paddle"))
game_instructions.append(pong_frame.add_label(""))
game_instructions.append(pong_frame.add_label("W and S keys control the Red paddle"))
game_instructions.append(pong_frame.add_label(""))
game_instructions.append(pong_frame.add_label("Click anywhere in the game window to start"))
game_instructions.append(pong_frame.add_label(""))
game_instructions.append(pong_frame.add_label("May the force be with you."))
game_instructions.append(pong_frame.add_label(""))
# Game Window Buttons and Controls
# resetButton = pong_frame.add_button("New Game", new_game, 150)
pong_frame.add_button("Single Player (vs Computer)", singlePlayer, 250)
pong_frame.add_button("2 Player (Restart)", twoPlayer, 250)
# Timers
reset_timer = simplegui.create_timer(1000, reset_pause)
# Register event handlers
pong_frame.set_keydown_handler(keydown)
pong_frame.set_keyup_handler(keyup)
pong_frame.set_draw_handler(draw)
pong_frame.set_mouseclick_handler(mouseclick_startGame)
开发者ID:4karsh,项目名称:my_git_repos,代码行数:30,代码来源:Pong_optimized.py
示例5: setup_frame
def setup_frame():
# initialize stuff
global timer, quiz, questions
quiz = Quiz(questions)
frame = simplegui.create_frame("QUIZ", WIDTH, HEIGHT)
timer = simplegui.create_timer(1000, timer_handler)
frame.set_canvas_background("Pink")
# register handlers
#frame.set_keyup_handler(keyup)
#frame.set_keydown_handler(keydown)
#frame.set_mouseclick_handler(click)
frame.set_draw_handler(draw)
frame.add_label("Game Controls")
frame.add_button("Restart", restart, 100)
frame.add_button("Next Question", nextQuestion, 100)
frame.add_button("Review Question", prev, 100)
# frame.add_button("Reset Question", resetQuestion, 100)
frame.add_label("Select Your Answer")
frame.add_button("A", selectA, 100)
frame.add_button("B", selectB, 100)
frame.add_button("C", selectC, 100)
frame.add_button("D", selectD, 100)
# get things rolling
init_game()
frame.start()
开发者ID:amits91,项目名称:quiz,代码行数:25,代码来源:Question.py
示例6: __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
self._item_label = self._frame.add_button(
LABEL_STRING + self._item_type, self.toggle_item, 200)
self._frame.add_button("Humans flee", self.flee, 200)
self._frame.add_button("Zombies stalk", self.stalk, 200)
self._frame.add_button("Auto Flee (toggle)", self.auto_flee, 200)
self._frame.add_button("Auto Stalk (toggle)", self.auto_stalk, 200)
self._frame.add_button("Full Pursuit (toggle stalk and flee)",
self.full_pursuit, 200)
self._frame.set_mouseclick_handler(self.add_item)
self._frame.set_draw_handler(self.draw)
self._stalk_on = False
self._flee_on = False
开发者ID:creasyw,项目名称:Courses,代码行数:25,代码来源:test1.py
示例7: start
def start(self):
self.frame = simplegui.create_frame(self.title,
self.width,
self.height)
self.frame.set_draw_handler(self.draw)
self.frame.start()
self.my_setup()
开发者ID:CodeSkool,项目名称:SimpleGUI2Pygame,代码行数:7,代码来源:state_demo.py
示例8: __init__
def __init__(self):
self.frame = simplegui.create_frame("Flappy Bird", GAME_WIDTH, GAME_HEIGHT)
self.frame.start()
self.background = Background()
self.bird = Bird()
self.register_handlers()
self.pipe_creator = PipeCreator()
开发者ID:zincsoda,项目名称:flappy_bird,代码行数:7,代码来源:7_create_and_remove_pipes.py
示例9: get_frame
def get_frame(self):
frame = simplegui.create_frame(
self.title,
self.width,
self.height)
frame.set_canvas_background(self.bg_color)
return frame
开发者ID:Jovito,项目名称:SimpleGUI2Pygame,代码行数:7,代码来源:20_questions_cs.py
示例10: __init__
def __init__(self):
self.button_manager = ButtonManager()
self.draw_manager = DrawManager()
self.garbage = Garbage()
self.draw_manager.add_draw_item(self.garbage)
self.drag_manager = DragManager(self, self.garbage)
self.drag_manager.add_dragable_item(self.garbage)
self.fridge = Fridge()
self.draw_manager.add_draw_item(self.fridge)
self.add_word_button = AddWordButton(self,"add word",(390,20),(450,40))
self.button_manager.add_button(self.add_word_button)
self.draw_manager.add_draw_item(self.add_word_button)
self.drag_manager.add_dragable_item(self.add_word_button)
self.frame = simplegui.create_frame('fridge poetry',600, 780,0)
self.frame.set_draw_handler(self.draw)
self.frame.set_mouseclick_handler(self.mouse_click_handler)
self.frame.set_mousedrag_handler(self.mouse_drag_handler)
self.frame.start()
开发者ID:semisided1,项目名称:cousera-iip,代码行数:27,代码来源:user39_wvz2tEacHD46Vlo_2.py
示例11: init
def init():
# initialize frame
global my_ship, a_missile, frame, timer, upgrade_number, upgrade_dist
frame = simplegui.create_frame("Asteroids, by dare7", WIDTH, HEIGHT)
upgrade_number = frame.add_button("+1 missile for %s$" % str(upgrade_cost), upgrade_count, 180)
upgrade_dist = frame.add_button("+1 missile range %s$" % str(upgrade_cost), upgrade_range, 180)
frame.add_button("Reset all", full_reset, 180)
frame.add_button("Quit", quit, 180)
# initialize ship and two sprites
my_ship = Ship([WIDTH / 2, HEIGHT / 2], [0, 0], 0, ship_image, ship_info)
#a_rock = Sprite([WIDTH / 3, HEIGHT / 3], [1, 1], 0, 0, asteroid_image, asteroid_info)
#a_missile = Sprite([2 * WIDTH / 3, 2 * HEIGHT / 3], [-1,1], 0, 0, missile_image, missile_info, missile_sound)
# register handlers
frame.set_draw_handler(draw)
frame.set_keydown_handler(key_down)
frame.set_keyup_handler(key_up)
frame.set_mouseclick_handler(click)
frame.add_label("Shoot stars!")
frame.add_label("Earn money!")
frame.add_label("Avoid collision!")
frame.add_label("Upgrade ship!")
frame.add_label("")
frame.add_label("Controls:")
frame.add_label("Up: accelerate")
frame.add_label("Left, right: turn")
frame.add_label("Space: shoot")
timer = simplegui.create_timer(1000.0, rock_spawner)
# get things rolling
timer.start()
frame.start()
开发者ID:dare7,项目名称:Coursera-An-Introduction-to-Interactive-Programming-in-Python,代码行数:32,代码来源:Rice_Rocks.py
示例12: __init__
def __init__(self, numpairs, card_size, columns):
# Set board width, height
self.width = (card_size[0] * columns) + (CARD_MARGIN * columns + CARD_MARGIN)
numrows = (numpairs * 2)/columns
if (numpairs * 2)%columns > 0:
numrows += 1
self.height = (card_size[1] * numrows) + (CARD_MARGIN * numrows + CARD_MARGIN) + SCORE_MARGIN
# Create the frame and buttons
self.frame = simplegui.create_frame("Memory", self.width, self.height)
self.frame.add_button("Reset", self.reset_game)
# Set cards
self.numpairs = numpairs
self.card_size = card_size
self.columns = columns
self.cards = Cards(self.numpairs, self.card_size, self.columns)
# Set scoreboard
self.scoreboard = Scoreboard()
# Register event handlers
self.frame.set_mouseclick_handler(self.on_mouseclick)
self.frame.set_draw_handler(self.draw)
# Start the frame
self.frame.start()
开发者ID:jaysonthepirate,项目名称:memorygame,代码行数:27,代码来源:memorygame.py
示例13: __init__
def __init__(self):
self.frame = simplegui.create_frame('2048', 490, 490)
self.frame.add_button('New Game', self.start)
self.frame.set_keydown_handler(self.keydown)
self.frame.set_draw_handler(self.draw)
self.text = self.frame.add_label('')
self.frame.start()
开发者ID:mistert14,项目名称:mistert-skulpt,代码行数:7,代码来源:2048_Hardcore.py
示例14: new_game
def new_game(range):
print "\n\n Let's play guess the number, fellow!"
# initialize global variables used in your code here
global secret_number # computer secret number
global allowed_guesses # max guesses by the player
global guesses_count# saving number of guesses on each match
global chooserange #range chosen
# init guesses count as 1 on each match (first try)
guesses_count = 1
if int(range) == 1000:
secret_number = range1000()
allowed_guesses = 10
chooserange = 1000
else:
secret_number = range100()
allowed_guesses = 7
chooserange = 100
# to see what is the secret number range which computer
# is choosing to play with
# please uncomment the following line
#print "secret number", secret_number
frame = simplegui.create_frame("Guess the number",200,200)
frame.add_button("Range 0-100", range_handler100)
frame.add_button("Range 0-1000", range_handler1000)
frame.add_input('Guess the number:', input_guess, 100)
frame.start()
开发者ID:stephanyzd,项目名称:Interative_Python_Programming,代码行数:31,代码来源:mini_project_02.py
示例15: start
def start(self):
self.img_loader.start()
frame = simplegui.create_frame(
self.title,
self.width,
self.height
)
frame.set_draw_handler(self.draw_handler)
frame.set_mouseclick_handler(self.mouse_click_handler)
frame.set_canvas_background("#87CEEB")
frame.start()
self.init_balls()
self.init_clouds(2)
self.cloud_timer = simplegui.create_timer(
10 * 1000,
self.add_cloud)
self.cloud_timer.start()
frame.add_button("Clear sky", self.clear_clouds)
# frame.add_button("Add cloud", self.add_cloud)
self.rs_button = frame.add_button("Enable radius shrink", self.toggle_radius_shrink)
开发者ID:flc,项目名称:juggle-codeskulptor,代码行数:26,代码来源:juggle.py
示例16: __init__
def __init__(self):
self.wins = 0
self.losses = -1
self.deck = Deck()
random.shuffle(self.deck.cards)
#print(str(self.deck))
self.dealer_hand = Hand(( 10, 50),"Dealer")
self.player_hand = Hand((100,210),"Player 1")
self.draw_manager = DrawManager()
self.button_manager = ButtonManager()
self.game_label = Label(self,"BlackJack",(200,20), (400,35))
self.game_label.color = "Black"
self.game_label.text_color = "Green"
self.game_label.font_size = 36
self.deal_button = DealButton(self,"Deal",(20,400),(100,440))
self.deal_button.color = 'Green'
self.button_manager.add_button(self.deal_button)
self.draw_manager.add_draw_item(self.deal_button)
self.hit_button = HitButton(self,"Hit",(110,400),(190,440))
self.hit_button.color = 'Gold'
self.button_manager.add_button(self.hit_button)
self.draw_manager.add_draw_item(self.hit_button)
self.stand_button = StandButton(self,"Stand",(200,400),(280,440))
self.stand_button.color = 'Red'
self.button_manager.add_button(self.stand_button)
self.draw_manager.add_draw_item(self.stand_button)
self.result_label = Label(self,"Good Luck", (350,400),(500,440) )
self.draw_manager.add_draw_item(self.result_label)
self.wins_label = Label(self,"Wins - 0", (510,400),(600,420) )
self.draw_manager.add_draw_item(self.wins_label)
self.losses_label = Label(self,"Losses - 0", (510,420),(600,440) )
self.draw_manager.add_draw_item(self.losses_label)
self.deal_button.click()
self.result_label.text = "Good Luck"
self.draw_manager.add_draw_item(self.game_label)
self.draw_manager.add_draw_item(self.player_hand)
self.draw_manager.add_draw_item(self.dealer_hand)
self.tic_tm = TimerManager(1000)
#self.tic_tm.add_listener(self, Signal("tic"))
self.frame = simplegui.create_frame('BlackJack',630, 500,100)
self.frame.set_draw_handler(self.draw_handler)
self.frame.set_mouseclick_handler(self.mouse_click_handler)
self.frame.start()
开发者ID:semisided1,项目名称:cousera-iip,代码行数:59,代码来源:user39_N4eqXbfsXpdvwOO_13.py
示例17: new_game
def new_game():
# initialize global variables used in your code here
global count
frame = simplegui.create_frame("guess number" , 300 ,300)
frame.add_button("range100" , range100)
frame.add_button("range1000" , range1000)
frame.add_input("input_guess" , input_guess , 100)
# remove this when you add your code
frame.start()
开发者ID:chenpeikai,项目名称:Rice_python,代码行数:9,代码来源:guess_the_number.py
示例18: Stopwatch
def Stopwatch():
frame = simplegui.create_frame("StopWatch",300,200)
frame.start()
Reset()
frame.add_button("Start",Start,100)
frame.add_button("Stop",Stop,100)
frame.add_button("Reset",Reset,100)
frame.add_label('')
frame.add_button("Dual-Game (Optional)",Dual_game,150)
frame.set_draw_handler(draw)
开发者ID:jguo1,项目名称:Coursera-projects,代码行数:10,代码来源:#3+-+Stopwatch+(dual+version).py
示例19: __init__
def __init__(self, tree):
"""
Create GUI
"""
self._tree = tree
self._canvas_width, self._canvas_height = self.get_box_size(tree)
self._frame = simplegui.create_frame("Draw a tree", self._canvas_width, self._canvas_height)
self._frame.set_canvas_background("White")
self._frame.set_draw_handler(self.draw)
self._frame.start()
开发者ID:hwesterink,项目名称:PythonCourseraRice,代码行数:10,代码来源:PoC2_draw_tree.py
示例20: __init__
def __init__(self):
self.stage = Stage()
self.bird = Bird()
self.score = Score()
self.pipes = Pipes()
self.frame = simplegui.create_frame("Flappy Bird", FRAME_WIDTH, FRAME_HEIGHT)
self.game_is_over = False
self.is_started = False
self.is_robot_on = False
self.register_handlers()
开发者ID:zincsoda,项目名称:flappy_bird,代码行数:10,代码来源:original.py
注:本文中的simplegui.create_frame函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论