本文整理汇总了Python中tkinter.Canvas.image方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.image方法的具体用法?Python Canvas.image怎么用?Python Canvas.image使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Canvas
的用法示例。
在下文中一共展示了Canvas.image方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: demo1
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import image [as 别名]
def demo1():
try:
if sys.version_info[0] == 3:
from tkinter import Tk, Canvas, PhotoImage, NW, SW
else:
from Tkinter import Tk, Canvas, PhotoImage, NW, SW
except ImportError:
Tk = Canvas = None
if Tk:
from pykbool import connect
contour = [(491.1025968497233, 19.886736214605065), (491.1025968497233, 5.524093392945851), (455.34269902086, 5.524093392945851), (455.34269902086, 19.886736214605065), (353.68241805023416, 17.677098857426728), (353.68241805023416, 8.838549428713364), (323.20136228182207, 8.838549428713364), (323.20136228182207, 17.677098857426728), (210.81311196253725, 14.362642821659207), (210.81311196253725, 3.3144560357675132), (175.05321413367392, 3.3144560357675132), (175.05321413367392, 14.362642821659207), (73.22264793529162, 14.362642821659207), (73.22264793529162, 10.0), (34.05704555129843, 10.0), (32.18390804597701, 110.48186785891704), (10.0, 110.48186785891704), (10.0, 162.40834575260803), (48.36100468284376, 156.88425235966218), (75.09578544061303, 156.88425235966218), (128.56534695615156, 162.40834575260803), (178.62920391656024, 176.77098857426725), (226.81992337164752, 196.65772478887232), (249.9787143465304, 211.02036761053148), (291.18773946360153, 246.374565325385), (328.65048957002983, 283.9384003974168), (337.5053214133674, 298.30104321907595), (337.5053214133674, 341.3889716840536), (448.1907194550873, 350.22752111276696), (448.1907194550873, 333.6552409339294), (685.7386121753938, 350.22752111276696), (683.8654746700724, 356.856433184302), (771.3920817369094, 364.5901639344262), (774.9680715197957, 318.18777943368104), (767.816091954023, 318.18777943368104), (789.272030651341, 60.765027322404364), (796.4240102171137, 60.765027322404364), (800.0, 8.838549428713364), (757.088122605364, 8.838549428713364), (757.088122605364, 23.20119225037257), (644.6998722860792, 19.886736214605065), (644.6998722860792, 8.838549428713364), (610.8131119625373, 5.524093392945851), (608.9399744572158, 19.886736214605065)]
holea = [(162.62239250744997, 127.0541480377546), (189.35717326521925, 135.89269746646795), (239.42103022562793, 159.09388971684052), (287.6117496807152, 187.81917536015894), (308.8974031502767, 205.49627421758566), (348.2332907620264, 246.374565325385), (366.1132396764581, 266.26130153999003), (389.272030651341, 301.6154992548435), (450.0638569604087, 307.13959264778936), (451.7667092379736, 57.45057128663686), (355.38527032779905, 55.24093392945852), (355.38527032779905, 66.28912071535022), (323.20136228182207, 66.28912071535022), (323.20136228182207, 55.24093392945852), (210.81311196253725, 55.24093392945852), (210.81311196253725, 60.765027322404364), (173.35036185610898, 60.765027322404364), (173.35036185610898, 55.24093392945852), (73.22264793529162, 51.926477893691), (71.51979565772669, 116.00596125186286), (107.27969348659005, 119.32041728763039)]
holeb = [(749.9361430395913, 60.765027322404364), (498.254576415496, 57.45057128663686), (494.67858663260967, 294.9865871833085), (566.0280970625798, 301.6154992548435), (566.0280970625798, 292.77694982613014), (591.0600255427842, 292.77694982613014), (589.3571732652192, 303.8251366120218), (730.3533418475947, 315.9781420765027)]
connected_polygon = connect([contour, holea, holeb])
root = Tk()
root.title(string='connect holes to contour / fill resulting polygon')
canvas1 = Canvas(root, width=900, height=415, background='white')
canvas1.pack()
canvas1.create_polygon(contour, outline='blue', fill='')
canvas1.create_text(contour[0], text='C(1)')
canvas1.create_text(contour[20], text='C(i)')
canvas1.create_text(contour[-1], text='C(n)')
canvas1.create_polygon(holea, outline='red', fill='')
canvas1.create_text(holea[0], text='H1(1)')
canvas1.create_text(holea[9], text='H1(i)')
canvas1.create_text(holea[-1], text='H1(n)')
canvas1.create_polygon(holeb, outline='green', fill='')
canvas1.create_text(holeb[0], text='H2(1)')
canvas1.create_text(holeb[2], text='H2(i)')
canvas1.create_text(holeb[-1], text='H2(n)')
canvas1.create_text((10, 350), text='# More info in setup.py\n'
'from pykbool import connect\n'
'contour=[(... , ...) ... ]; hole1=[(... , ...) ... ]; hole2=...\n'
'polygon=connect([contour, hole1, hole2, ...])', anchor=SW)
canvas2 = Canvas(root, width=900, height=415, background='white')
canvas2.pack()
image=PhotoImage(file=os.path.join('data','demo.gif'))
canvas2.create_image((0,0), image=image, anchor=NW)
canvas2.image=image
canvas2.create_polygon(connected_polygon, outline='black', fill='grey')
canvas2.create_text(connected_polygon[0], text='P1')
canvas2.create_text(connected_polygon[62], text='Pi')
canvas2.create_text(connected_polygon[-1], text='Pn')
root.mainloop()
示例2: progress
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import image [as 别名]
def progress( self ):
o=os.popen("cd {0} && snakemake --dryrun --rerun-incomplete > {0}/Reports/checkpoint".format(self.workpath.get()))
o.close()
F=open("{0}/Reports/checkpoint".format(self.workpath.get()),"r").read()
rules2={}
rules=re.findall(r'rule .+:',F)
for i in rules:
i=re.sub("rule ","",i)
i=re.sub(":","",i)
rules2[i]=0
F=open("{0}/Reports/{1}.dot".format(self.workpath.get(), self.Pipeline.get() ),"r").read()
for i in rules2.keys():
F=re.sub(r'('+i+')(\".+?)\".+?\"',r'\1_pending\2"0.0 0.0 0.0"',F)
# F=re.sub(i,"",F)
G=open("{0}/Reports/{1}-{2}.dot".format(self.workpath.get(),self.Pipeline.get(),"progress"),"w")
G.write(F)
G.close()
o=os.popen("cd {0}/Reports && dot -Tpng -o {0}/Reports/{1}-progress.png {0}/Reports/{1}-progress.dot;convert {0}/Reports/{1}-progress.png {0}/Reports/{1}-progress.gif".format(self.workpath.get(),self.Pipeline.get()))
# tkinter.messagebox.showerror("o",o)
PL=self.Pipeline.get() #pipelineget()
gf=Toplevel()
gf.title("CCBR Pipeliner: {0} Progress Graph".format(PL))
cgf = Canvas(gf,bg="white")
# gff=Frame(cgf,width=300,height=300)
xscrollbar = Scrollbar(gf, orient=HORIZONTAL)
xscrollbar.pack(side = BOTTOM, fill=X )
xscrollbar.config(command=cgf.xview)
yscrollbar = Scrollbar(gf,orient=VERTICAL)
yscrollbar.pack(side = RIGHT, fill=Y )
yscrollbar.config(command=cgf.yview)
cgf.config(xscrollcommand=xscrollbar.set, yscrollcommand=yscrollbar.set)
cgf.config(width=600,height=600)
cgf.pack(expand=1,fill=BOTH,side=RIGHT)
cgf.config(scrollregion=(0,0,1000,5000))
try:
time.sleep(5)
img = PhotoImage(file="{0}/Reports/{1}-progress.gif".format(self.workpath.get(),PL))
except:
time.sleep(5)
img = PhotoImage(file="{0}/Reports/{1}-progress.gif".format(self.workpath.get(),PL))
cgf.create_image(0,0,image=img, anchor="nw")
cgf.image=img
示例3: workflow
# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import image [as 别名]
def workflow(self):
PL=self.Pipeline.get() #pipelineget()
gf=Toplevel()
#MkaS=os.popen("./makeasnake.py 2>&1 | tee -a "+workpath.get()+"/Reports/makeasnake.log").read()
gf.title("CCBR Pipeliner: "+ PL + " Workflow Graph")
cgf = Canvas(gf,bg="white")
#gff=Frame(cgf,width=300,height=300)
xscrollbar = Scrollbar(gf, orient=HORIZONTAL)
xscrollbar.pack(side = BOTTOM, fill=X )
xscrollbar.config(command=cgf.xview)
yscrollbar = Scrollbar(gf,orient=VERTICAL)
yscrollbar.pack(side = RIGHT, fill=Y )
yscrollbar.config(command=cgf.yview)
cgf.config(xscrollcommand=xscrollbar.set, yscrollcommand=yscrollbar.set)
cgf.config(width=600,height=600)
cgf.pack(expand=1,fill=BOTH,side=RIGHT)
cgf.config(scrollregion=(0,0,5000,20000))
img = PhotoImage(file=self.workpath.get()+"/Reports/"+PL+".gif")
cgf.create_image(0,0,image=img, anchor="nw")
cgf.image=img