国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

python 模塊調(diào)用練習(xí)(II)

2020-03-26 19:43 作者:一心想當(dāng)網(wǎng)紅的李老師  | 我要投稿

繼續(xù)在練習(xí)1的基礎(chǔ)上加強(qiáng)。

看起來(lái)程序還是有問(wèn)題。因?yàn)槭钦罩鴷?shū)本操作,所以感覺(jué)有點(diǎn)問(wèn)題。程序沒(méi)有報(bào)錯(cuò),但是感覺(jué)好像有些內(nèi)容沒(méi)有顯示。

from tkinter import *

import model


cell_size=5



def setup():

? ? global root,grid_view,cell_size,start_btn,clear_btn,choice

? ??

? ? root=Tk()

? ? root.title('game screen')

? ? grid_view=Canvas(root,width=model.width*cell_size,

? ? ? ? ? ? ? ? ? ? ?height=model.height*cell_size,

? ? ? ? ? ? ? ? ? ? ?borderwidth=0,

? ? ? ? ? ? ? ? ? ? ?bg='white')

? ? start_btn=Button(root,text="start",width=12)

? ? clear_btn=Button(root,text="clear",width=12)

? ? choice=StringVar(root)

? ? choice.set('choose a pattern')

? ? option=OptionMenu(root,choice,"'choose a pattern","grider","grider gun","random")

? ? option.config(width=25)

? ??

? ??

? ? grid_view.grid(row=0,columnspan=3,padx=20,pady=20)

? ? start_btn.grid(row=1,column=0,sticky=W,padx=20,pady=20)

? ? option.grid(row=1,column=1,padx=20)

? ? clear_btn.grid(row=1,column=2,sticky=E,padx=20,pady=20)

?####此處學(xué)習(xí)了tkinter界面布局的方法,還是很有用的。sticky是字體對(duì)其方式,W=west, E=east,很神奇的方式,不過(guò)有書(shū)有介紹,可以看懂。畫(huà)布可以分行列,然后進(jìn)行排布。這個(gè)和wxpython設(shè)置大小和位置的方式有所不同。####

? ??

def update():

? ? global grid_view

? ? grid_view.delete(ALL)

? ??

? ? model.next_gen()

? ? for i in range(0,model.height):

? ? ? ? for j in range (0,model.width):

? ? ? ? ? ? if model.grid_model[i][j]==1:

? ? ? ? ? ? ? ? draw_cell(i,j,'black')

?####調(diào)用其他程序的方式? ? ? ? ? ?

def draw_cell(row, col, color):

? ? global grid_view,cell_size

? ??

? ? if color=='black':

? ? ? ? outline='grid'

? ? else:

? ? ? ? outline='white'

? ? ? ??

? ? grid_view.create_rectangle(row*cell_size,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?col*cell_size,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?row*cell_size+cell_size,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?col*cell_size+cell_size,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?fill=color,outline=outline)

? ??


if __name__=='__main__':

? ? setup()

? ? update()

? ? mainloop()

###主程序運(yùn)行順序

python 模塊調(diào)用練習(xí)(II)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
诸城市| 文成县| 磐石市| 进贤县| 诏安县| 什邡市| 石泉县| 盖州市| 孟村| 封开县| 元阳县| 化德县| 年辖:市辖区| 贵定县| 台中市| 开江县| 资兴市| 三台县| 南雄市| 海口市| 松滋市| 大邑县| 桐梓县| 黑龙江省| 图木舒克市| 清涧县| 上思县| 富锦市| 琼结县| 琼海市| 大关县| 香格里拉县| 会同县| 前郭尔| 仁怀市| 彭州市| 莒南县| 安平县| 策勒县| 康乐县| 广安市|