在我的程序中,我想创建一个锚定在屏幕左上角的tkinter画布,但画布默认位于屏幕上的另一个位置。以下是这一情况的图像:
以下是我当前的代码:#!/usr/bin/python
import tkinter
from tkinter import *
from PIL import Image, ImageTk
root = Tk()
root.title("Infrared Camera Interface")
root.resizable(width=FALSE, height=FALSE)
class MyApp:
def __init__(self, parent):
self.C = tkinter.Canvas(root, bg="white", height=560, width=450)
#Set the dimensions of the window
parent.minsize(width=600, height=600)
parent.maxsize(width=600, height=600)
#Prepare the image object being loaded into the stream camera
self.imgName = 'Dish.png'
self.img = Image.open(self.imgName)
self.img = self.img.resize((560, 450), Image.ANTIALIAS)
#Display the image onto the stream
self.displayimg = ImageTk.PhotoImage(self.img)
self.C.create_image(0,0,image = self.displayimg, anchor = NW)
self.C.pack()
myapp = MyApp(root)
root.mainloop()
如何将画布定位到屏幕的左上角?在