当前位置: 首页>>代码示例>>Python>>正文


Python Canvas.place方法代码示例

本文整理汇总了Python中tkinter.Canvas.place方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.place方法的具体用法?Python Canvas.place怎么用?Python Canvas.place使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.Canvas的用法示例。


在下文中一共展示了Canvas.place方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loo_pilv

# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import place [as 别名]
def loo_pilv(aken, pildi_list, mitu_pilve):
    """Create desired amount of clouds and call out a function to make them move."""
    arv = 0
    pilve_koht_x = 0
    while mitu_pilve != arv:
        kiirus = 30
        pilt = random.choice(pildi_list)
        pilv = Canvas(aken, width=100, height=55, bg="blue", highlightthickness=0)
        pilv.create_image(50, 30, image=pilt)
        pilv.place(x=pilve_koht_x, y=0)
        pilv.pack()
        pilve_koht_y = random.randint(0, 85)
        liiguta_pilve(pilv, pilve_koht_x, pilve_koht_y, kiirus, aken, pildi_list)
        pilve_koht_x += 100
        arv += 1
开发者ID:rener2,项目名称:python-course,代码行数:17,代码来源:NeljasIseseisevYlesanne.py

示例2: overview

# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import place [as 别名]
    def overview(self, Medikom):
        # get content
        tasks_results, information_results = Medikom.get_titles()

        # clear screen
        canvas = Canvas(self, width=self.WIN_WIDTH, height=self.WIN_HIGHT * 2)
        canvas.place(x=0, y=0)

        # headers
        tasks_label = Label(self, text='Aufgaben', font='Liberation 14')
        tasks_label.place(
            x=0, y=0, width=self.WIN_WIDTH/2, height=self.ROW_HIGHT)
        info_label = Label(self, text='Informationen', font='Liberation 14')
        info_label.place(
            x=self.WIN_WIDTH/2, y=0,
            width=self.WIN_WIDTH/2, height=self.ROW_HIGHT)

        self.list_entries(Medikom, tasks_results, 0)
        self.list_entries(Medikom, information_results, 1)

        # lower window part
        canvas.create_line(
            self.SPACE_ONE, (self.n + 1.5) * (self.ROW_HIGHT + self.ROW_SPACE),
            self.WIN_WIDTH - self.SPACE_ONE, (self.n + 1.5) * (self.ROW_HIGHT + self.ROW_SPACE),
            fill='#000001', width=1)

        add_task_button = Button(self, text='+',
            command=Callable(self.view_new_title, Medikom, 0))
        add_task_button.place(
            x=self.WIN_WIDTH / 4 - self.SPACE_TWO / 2,
            y=self.n * (self.ROW_HIGHT + self.ROW_SPACE),
            width=self.SPACE_TWO, height=self.ROW_HIGHT)

        add_info_button = Button(self, text='+',
            command=Callable(self.view_new_title, Medikom, 1))
        add_info_button.place(
            x=0.75 * self.WIN_WIDTH - self.SPACE_TWO / 2,
            y=self.n * (self.ROW_HIGHT + self.ROW_SPACE),
            width=self.SPACE_TWO, height=self.ROW_HIGHT)

        if self.selected_id is None:
            selection_label = Label(
                self, text='Kein Eintrag ausgewählt.', font='Liberation 10')
            selection_label.place(
                x=self.WIN_WIDTH / 2 - 0.125 * self.WIN_WIDTH,
                y=(self.n + 1) * (self.ROW_HIGHT + self.ROW_SPACE),
                width=self.WIN_WIDTH / 4, height=self.ROW_HIGHT)
开发者ID:g-murzik,项目名称:medikom,代码行数:49,代码来源:medikom_front_end.py

示例3: Application

# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import place [as 别名]
class Application(object):

    def __init__(self):

        self.master = Tk()
        self.master.geometry(newGeometry = '300x300')
        # Fenêtre tkinter

        self.menu = Menu(self.master)

        self.filemenu = Menu(self.menu,
                             tearoff = 0)
        self.filemenu.add_command(label = "Open", command = self.open)
        self.filemenu.add_separator()
        self.filemenu.add_command(label = "Exit", command = self.master.destroy)
        self.menu.add_cascade(label = "File",
                              menu = self.filemenu)

        self.master.config(menu = self.menu)
        # On crée un menu

        self.canvas = Canvas(master=self.master,
                             width=200,
                             height=200,
                             bg='#cccccc')

        self.canvas.place(x=150,
                          y=100,
                          anchor='center')

        Label(master=self.master,
              text='Image',
              font='YuMinchoDemibold',
              foreground='white',
              background='#535353').place(x=120,
                                          y=190)

    def open(self):

        self.image_path = askopenfilename(initialdir = os.path.dirname(os.path.join(os.getcwd(), __file__)),
                                          filetypes = (("png files",".png"),
                                                       ("jpg files",".jpg"),
                                                       ("all files (risk)", ".")),
                                          defaultextension = ".png",
                                          title = "Open picture file")
        # on demande le fichier à ouvrir

        if self.image_path == "":
            # Si l'utilisateur choisit annuler
            return None
        else:
            pass

        self.pyimage = PhotoImage(file = self.image_path)
        print(self.image_path)
        self.PILimage = pil.open(self.image_path)

        if self.PILimage.size[0] > 200 or\
           self.PILimage.size[1] > 200:

            if self.PILimage.size[0] >= self.PILimage.size[1]:
                x = 200
                pourcentage = int(((200*100)/self.PILimage.size[0]))
                y = self.PILimage.size[1] - (self.PILimage.size[1]* (100 - pourcentage) /100)
            else:
                y = 200
                pourcentage = int(((200 * 100) / self.PILimage.size[1]))
                x = self.PILimage.size[0] - (self.PILimage.size[0] * (100 - pourcentage) / 100)

            Label(master = self.master,
                  text = 'Image resized \nfor view ({}%)'.format(pourcentage),
                  font = 'YuMinchoDemibold 6',
                  fg = 'black').place(x=190,y=200)
            print('cc3')
            self.PILimage.resize((int(x),int(y)), pil.BILINEAR).save("tmp.png")
            self.pyimage = PhotoImage(file="tmp.png")
            os.remove('tmp.png')
            # On redimensionne l'image pour la preview

        self.image_tag = self.canvas.create_image(100,
                                                  100,
                                                  anchor = 'center',
                                                  image = self.pyimage)
        # On affiche l'image

        Label(master = self.master,
              text = 'Image original size:',
              font = 'YuMinchoDemibold 7',
              relief = 'groove').place(x = 20, y = 230)
        Label(master=self.master,
              text='({},{})'.format(self.PILimage.size[0],self.PILimage.size[1]),
              font='YuMinchoDemibold 8').place(x=37, y=250)

        Label(master=self.master,
              text='Choisir taille thumbnail:',
              font='YuMinchoDemibold 7',
              relief='groove').place(x=140, y=230)

        liste_valeurs = (30,50,100)

#.........这里部分代码省略.........
开发者ID:Pythalex,项目名称:PyResize,代码行数:103,代码来源:PyResize.py

示例4: QuickHull

# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import place [as 别名]
class QuickHull(Tk):
	def __init__(self,points):
		Tk.__init__(self)
		board = Frame(self)
		self.title("Diagram") 

		width = 800 #setting height and width
		height = 600

		windowx = self.winfo_screenwidth()
		windowy = self.winfo_screenheight()
		x = (windowx - width)/2		#getting center
		y = (windowy - height)/2

		self.geometry("%dx%d+%d+%d" % (width,height,x,y)) #creates window of size _width by _height, and positions it at the center of the screen

		board.pack(fill=BOTH, expand=1)
	
		self.canvas = Canvas(board,height=600,width=800,background="white")
		self.canvas.place(x=0,y=0)
		
		self.drawPoints(points) #Draw points and the first line from the highest an lowest points
		

					

		
		def point(event):  #Add points by clicking on the screen
			self.canvas.create_text(event.x, event.y,text = "+")
			points.append([event.x,event.y])

		def start():
			if(points != []):
				startB.destroy()
				quickHullStart(points)
				self.nextButton()
	
		self.canvas.bind("<Button-1>", point)
		
		startB = Button(self, text = "Start QuickHull", command = start)
		startB.pack()
	
		
	
		self.mainloop()
	
				
	def nextButton(self):					#Button that steps forward one step in the QuickHull
		def callBack():
			self.animate()

		continueB = Button(self, text="-->",command=callBack)
		continueB.place(x=350,y=550)


	def animate(self):						#animation loop
		if(triList == []):
			self.onExit()
			return
		self.canvas.create_polygon(triList.pop(0),fill="red",outline="black")
			





	def onExit(self):  #Window popup signaling that the Quick Hull is complete
		alert = Tk()
		finish = Window(alert)
		finish.config(title="Complete",w = 200, h=50)
		finish.positionWindow()

		done = Label(alert,text="QuickHull Complete")
		done.pack()

		ok = Button(alert,text="OK",command=alert.destroy)
		ok.pack()
		alert.mainloop()
		return
		


	def drawPoints(self,points):			#Draw points Imported from a file
		for p in points:
			self.canvas.create_text(p[0],p[1],text="+")
开发者ID:liangtianumich,项目名称:QuickHull,代码行数:87,代码来源:QuickHull.py

示例5: Tk

# 需要导入模块: from tkinter import Canvas [as 别名]
# 或者: from tkinter.Canvas import place [as 别名]
from tkinter import Tk, Canvas, PhotoImage
import time
import numpy as np

tk = Tk()
canvas = Canvas(tk, width=1000, height=1000)
canvasicon = Canvas(tk, width=300, height=300)
canvaslogo = Canvas(tk, width=300, height=300)
canvasstat = Canvas(tk, width=300, height=300)
canvas.grid(column=0, row=0)
canvasicon.grid(column=1, row=0)
canvaslogo.place(x=1000, y=0)
canvasstat.place(x=1000, y=700)
tk.update_idletasks()
tk.update()
contact_bool = False
launch_bool = False
body_landed = None
dist_body_landed = None
closest_body = None
crash = False
center_shiftx = 0
center_shifty = 0
total_shiftx = 0
total_shifty = 0
contact_number = 0
gravity_constant = 6.67384 * (10**-11)
orbital_velocity_text = canvasstat.create_text(155, 100, text=None, font=('Courier', 10))
velocity_text = canvasstat.create_text(80, 150, text=None, font=('Courier', 10))
name_text = canvasstat.create_text(97, 50, text=None, font=('Courier', 10))
logo = PhotoImage(file='logo.gif')
开发者ID:aroitman,项目名称:Gravity-Sim,代码行数:33,代码来源:gravity3.py


注:本文中的tkinter.Canvas.place方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。