turtle setuppython_Python turtle.setup方法代碼示例
本文整理匯總了Python中turtle.setup方法的典型用法代碼示例。如果您正苦於以下問題:Python turtle.setup方法的具體用法?Python turtle.setup怎麽用?Python turtle.setup使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在模塊turtle的用法示例。
在下文中一共展示了turtle.setup方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Python代碼示例。
示例1: setup_screen
點讚 6
# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import setup [as 別名]
def setup_screen(title, background='white', screen_size_x=640, screen_size_y=320, tracer_size=200):
print('Set up Screen')
turtle.title(title)
turtle.setup(screen_size_x, screen_size_y)
turtle.hideturtle()
turtle.penup()
turtle.backward(240)
turtle.tracer(tracer_size)
turtle.bgcolor(background) # Set the background colour of the screen
開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:11,
示例2: __init__
點讚 6
# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import setup [as 別名]
def __init__(
self,
screen_width = 800,
screen_height = 600,
background_color = "black",
title = "Simple Game Library by /u/wynand1004 AKA @TokyoEdTech",
splash_time = 3):
# Setup using Turtle module methods
turtle.setup(width=screen_width, height=screen_height)
turtle.bgcolor(background_color)
turtle.title(title)
turtle.tracer(0) # Stop automatic screen refresh
turtle.listen() # Listen for keyboard input
turtle.hideturtle() # Hides default turtle
turtle.penup() # Puts pen up for defaut turtle
turtle.setundobuffer(0) # Do not keep turtle history in memory
turtle.onscreenclick(self.click)
# Game Attributes
self.SCREEN_WIDTH = screen_width
self.SCREEN_HEIGHT = screen_height
self.DATAFILE = "game.dat"
self.SPLASHFILE = "splash.gif" # Must be in the same folder as game file
self.fps = 30.0 # Lower this on slower computers or with large number of sprites
self.title = title
self.gravity = 0
self.state = "showsplash"
self.splash_time = splash_time
self.time = time.time()
# Clear the terminal and print the game title
self.clear_terminal_screen()
print (self.title)
# Show splash
self.show_splash(self.splash_time)
# Pop ups
開發者ID:wynand1004,項目名稱:SPGL,代碼行數:43,
示例3: setup_screen
點讚 5
# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import setup [as 別名]
def setup_screen(title, background='white', screen_size_x=640, screen_size_y=320, tracer_size=800):
print('Set up Screen')
turtle.title(title)
turtle.setup(screen_size_x, screen_size_y)
turtle.hideturtle()
turtle.penup()
turtle.backward(240)
# Batch drawing to the screen for faster rendering
turtle.tracer(tracer_size)
turtle.bgcolor(background) # Set the background colour of the screen
開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:12,
示例4: setup_screen
點讚 5
# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import setup [as 別名]
def setup_screen(title, background = 'white'):
print('Set up Screen')
turtle.title(title)
turtle.setup(640, 600)
turtle.hideturtle()
turtle.penup()
turtle.tracer(200)
turtle.bgcolor(background) # Set the background colour of the screen
開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:10,
示例5: setup_screen
點讚 5
# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import setup [as 別名]
def setup_screen(title, background='white', screen_size_x=640, screen_size_y=320, tracer_size=200):
""" Sets up Turtle screen with useful defaults """
print('Set up Screen')
turtle.title(title)
turtle.setup(screen_size_x, screen_size_y)
turtle.hideturtle()
turtle.penup()
turtle.backward(240)
turtle.tracer(tracer_size)
turtle.bgcolor(background) # Set the background colour of the screen
開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:12,
示例6: init_pen
點讚 5
# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import setup [as 別名]
def init_pen():
'''
初始化畫筆的一些屬性
'''
t.pensize(4) # 設置畫筆的大小
t.colormode(255) # 設置GBK顏色範圍為0-255
t.color((255, 155, 192), "pink") # 設置畫筆顏色和填充顏色(pink)
t.setup(900, 500) # 設置主窗口的大小為900*500
t.speed(10) # 設置畫筆速度為10
開發者ID:MiracleYoung,項目名稱:You-are-Pythonista,代碼行數:11,
示例7: __init__
點讚 5
# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import setup [as 別名]
def __init__(
self,
screen_width = 800,
screen_height = 600,
background_color = "black",
title = "Simple Game Library by /u/wynand1004 AKA @TokyoEdTech",
splash_time = 3):
# Setup using Turtle module methods
turtle.setup(width=screen_width, height=screen_height)
turtle.bgcolor(background_color)
turtle.title(title)
turtle.tracer(0) # Stop automatic screen refresh
turtle.listen() # Listen for keyboard input
turtle.hideturtle() # Hides default turtle
turtle.penup() # Puts pen up for defaut turtle
turtle.setundobuffer(0) # Do not keep turtle history in memory
turtle.onscreenclick(self.click)
# Game Attributes
self.FPS = 30.0 # Lower this on slower computers or with large number of sprites
self.SCREEN_WIDTH = screen_width
self.SCREEN_HEIGHT = screen_height
self.DATAFILE = "game.dat"
self.SPLASHFILE = "splash.gif" # Must be in the same folder as game file
self.title = title
self.gravity = 0
self.state = "showsplash"
self.splash_time = splash_time
self.time = time.time()
# Clear the terminal and print the game title
self.clear_terminal_screen()
print (self.title)
# Show splash
self.show_splash(self.splash_time)
# Pop ups
開發者ID:wynand1004,項目名稱:SPGL,代碼行數:43,
示例8: setup_window
點讚 4
# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import setup [as 別名]
def setup_window():
# Set up the window
turtle.title('Circles in My Mind')
turtle.setup(WIDTH, HEIGHT, 0, 0)
turtle.colormode(255) # Indicates RGB numbers will be in the range 0 to 255
turtle.hideturtle()
# Batch drawing to the screen for faster rendering
turtle.tracer(2000)
# Speed up drawing process
turtle.speed(10)
turtle.penup()
開發者ID:johnehunt,項目名稱:advancedpython3,代碼行數:14,
示例9: main
點讚 4
# 需要導入模塊: import turtle [as 別名]
# 或者: from turtle import setup [as 別名]
def main():
# use sys.argv if needed
print('genterating spirograph...')
# create parser
descStr ="""This program draws spirographs using the Turtle module.
When run with no arguments, this program draws random spirographs.
Terminology:
R: radius of outer circle.
r: radius of inner circle.
l: ratio of hole distance to r."""
parser = argparse.ArgumentParser(description=descStr) # 創建參數解析器對象
parser.add_argument('--sparams',nargs=3,dest='sparams',required=False,
help="The three arguments in sparams:R,r,l.") # 向解析器添加可選參數
# parse args
args=parser.parse_args() # 調用函數進行實際的解析
# set to 80% screen width
turtle.setup(width=0.8)
# set cursor shape
turtle.shape('turtle')
# set title
turtle.title("Spirographs!")
# add key handler for saving image
turtle.onkey(saveDrawing,"s")
# start listening
turtle.listen()
# hide main turtle cursor
turtle.hideturtle()
# checks args and draw # 首先檢查是否有參數賦給--sparams.如果有,就從字符串中提取他們,用“列表解析”將他們轉換成浮點數
if args.sparams:
params=[float(x) for x in args.sparams]
# draw spirograph with given parameters
# black by default
col=(0.0,0.0,0.0)
spiro=Spiro(0,0,col,*params)
spiro.draw()
else:
# creat animator object
spiroAnim=SpiroAnimator(4)
# add key handler to toggle turtle cursor
turtle.onkey(spiroAnim.toggleTurtles,"t")
# add key handler to toggle turtle cursor
turtle.onkey(spiroAnim.restart,"space")
# start turtle main loop
turtle.mainloop()
# call main
開發者ID:DeqianBai,項目名稱:Python-Project,代碼行數:60,
注:本文中的turtle.setup方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。
turtle setuppython_Python turtle.setup方法代碼示例相关推荐
- python terminator_Python turtle.Terminator方法代碼示例
本文整理匯總了Python中turtle.Terminator方法的典型用法代碼示例.如果您正苦於以下問題:Python turtle.Terminator方法的具體用法?Python turtle. ...
- python turtle color_Python turtle.color方法代碼示例
本文整理匯總了Python中turtle.color方法的典型用法代碼示例.如果您正苦於以下問題:Python turtle.color方法的具體用法?Python turtle.color怎麽用?P ...
- python里turtle.circle什么意思_Python turtle.circle方法代碼示例
本文整理匯總了Python中turtle.circle方法的典型用法代碼示例.如果您正苦於以下問題:Python turtle.circle方法的具體用法?Python turtle.circle怎麽 ...
- java jdbc reparecall_Java Connection.prepareCall方法代碼示例
本文整理匯總了Java中java.sql.Connection.prepareCall方法的典型用法代碼示例.如果您正苦於以下問題:Java Connection.prepareCall方法的具體用法 ...
- bls java_Java PairingFactory.getPairing方法代碼示例
本文整理匯總了Java中it.unisa.dia.gas.plaf.jpbc.pairing.PairingFactory.getPairing方法的典型用法代碼示例.如果您正苦於以下問題:Java ...
- root_path运用python_Python current_app.root_path方法代碼示例
本文整理匯總了Python中flask.current_app.root_path方法的典型用法代碼示例.如果您正苦於以下問題:Python current_app.root_path方法的具體用法? ...
- java path.resolve_Java Path.resolve方法代碼示例
本文整理匯總了Java中java.nio.file.Path.resolve方法的典型用法代碼示例.如果您正苦於以下問題:Java Path.resolve方法的具體用法?Java Path.reso ...
- java中elements_Java Element.elements方法代碼示例
本文整理匯總了Java中org.dom4j.Element.elements方法的典型用法代碼示例.如果您正苦於以下問題:Java Element.elements方法的具體用法?Java Eleme ...
- java nextintln_Java Document.getRootElement方法代碼示例
本文整理匯總了Java中org.dom4j.Document.getRootElement方法的典型用法代碼示例.如果您正苦於以下問題:Java Document.getRootElement方法的具 ...
最新文章
- Android Activity和Intent机制学习笔记
- 【docker】【Gitlab】gitlab中clone项目时,IP地址是一串数字(内网Gitlab的IP地址不正确)的问题解决...
- mysql通过data目录恢复数据库
- java 图片合成 红色失真_Java - 处理某些图片泛红
- excel支持python吗_没有 Python,微软宣布 Excel 新增 JavaScript 支持
- R学习-- 数组和矩阵
- jquery绑定的事件对ajax刷新出的数据不生效,on可能受jquery版本影响
- (47)FPGA面试题LATCH和DFF的区别
- 给树莓派安装手柄驱动
- 使用J-Link打印日志——SEGGER Real-Time Transfer(RTT)工具的移植使用
- STVP烧录失败提示“cannot communicate with tool”或者“The device is protected”
- android虚拟应用沙箱,Android的SandBox(沙箱)
- 【ubuntu系统下装win10双系统】
- 代码之外——禅心慧语
- R语言逻辑回归的预测概率怎么算
- 数字字符串转为数字 C语言实现
- 一个故事讲解公钥私钥和数字签名,很深刻!
- LattePanda 之深入学习 Firmata通讯
- mysql默认民族_56个民族及民族代码的sql语句
- 天气预报 增加公历节日信息(1.确定时间2.第几周第几天) 和 农历节日信息 体力活+外码