所以我一直在构建一个由picamera填充的网格样式布局。我有相机在运行,网格窗口打开,但我似乎不知道为什么图像没有填充到网格中。我相信这个错误出现在我的主要“网格”课程中,但我不确定,看着屏幕我的眼睛受伤了。 这是到目前为止的代码:
import sys
import time
import picamera
from PIL import Image
import Tkinter as tk
from Tkinter import *
import os
import glob
import PIL
import ImageTk
camera = picamera.PiCamera()
camera.resolution = (100, 100)
camera.AWB_MODES
camera.EXPOSURE_MODES
time.sleep(2)
print ('camera on')
for i in range(10):
camera.capture("/home/pi/Pictures/image_%i.jpeg" %(i,))
time.sleep(2)
print('taking img')
if i == 10:
break
print('making grid')
class Grid(tk.Frame):
def _init_(self,parent):
Tkinter.TK.__init__(self,parent)
self.parent = parent
grid.pack()
self.grid.pack(fill="both", expand="true")
self.grid_columnconfigure(row=0, column=0, weight=1, sticky=N+S+E+W)
self.grid_rowconfigure(row=0, column=0, weight=1, sticky=N+S+E+W)
self.initialize()
print('initialize')
def initialize(self):
self.grid()
for row in range(4):
for column in range(4):
for infile in glob.glob(os.path.join("/home/pi/Pictures/",'*.jpeg')):
image = PIL.Image.open(infile)
photo = ImageTk.PhotoImage(image)
label= Label(image=photo)
label.image=photo
label.pack()
print('come on window COMPLETE')
if __name__ =="__main__":
app =Grid(None)
app.mainloop()
我一直在使用打印命令解决问题。但他们只指出“打印初始化”没有显示。如果你有一分钟我会喜欢一些帮助。