在我的程式中,我想建立一個錨定在螢幕左上角的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()
如何将畫布定位到螢幕的左上角?在