Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
全局变量。。。感谢@RonNorris的建议。。。这对我的牙床很有帮助。。。真的很有帮助。。。你解决了我遇到的每一个问题,我是python的高手,所以我在这个领域没有太多经验。。。我在编写init函数时遇到了问题,希望下次再问这个问题。你能解释一下*arg_Python_User Interface_Tkinter - Fatal编程技术网

全局变量。。。感谢@RonNorris的建议。。。这对我的牙床很有帮助。。。真的很有帮助。。。你解决了我遇到的每一个问题,我是python的高手,所以我在这个领域没有太多经验。。。我在编写init函数时遇到了问题,希望下次再问这个问题。你能解释一下*arg

全局变量。。。感谢@RonNorris的建议。。。这对我的牙床很有帮助。。。真的很有帮助。。。你解决了我遇到的每一个问题,我是python的高手,所以我在这个领域没有太多经验。。。我在编写init函数时遇到了问题,希望下次再问这个问题。你能解释一下*arg,python,user-interface,tkinter,Python,User Interface,Tkinter,全局变量。。。感谢@RonNorris的建议。。。这对我的牙床很有帮助。。。真的很有帮助。。。你解决了我遇到的每一个问题,我是python的高手,所以我在这个领域没有太多经验。。。我在编写init函数时遇到了问题,希望下次再问这个问题。你能解释一下*args和**kwargs参数的用途吗?我看不到的任何用法them@IncognitoPossum:当前在此类中,这两个变量不起任何作用。然而,它们在更复杂的代码中确实有其用途。看看 import sys import tkinter as tk f


全局变量。。。感谢@RonNorris的建议。。。这对我的牙床很有帮助。。。真的很有帮助。。。你解决了我遇到的每一个问题,我是python的高手,所以我在这个领域没有太多经验。。。我在编写init函数时遇到了问题,希望下次再问这个问题。你能解释一下*args和**kwargs参数的用途吗?我看不到的任何用法them@IncognitoPossum:当前在此类中,这两个变量不起任何作用。然而,它们在更复杂的代码中确实有其用途。看看
import sys
import tkinter as tk
from PIL import Image,ImageTk,ImageFilter,ImageOps
from msvcrt import getch

def wait():
    getch()
    return

def classify_obj():
    print("In Development")
    return

src = "ímages/"

root = tk.Tk()
root.wm_title("Classify Image")

for i in range(1,17):
    frame1 = tk.Frame(root, width=500, height=400, bd=2)
    frame1.grid(row=1, column=0)
    cv1 = tk.Canvas(frame1, height=390, width=490, background="white", bd=1, relief=tk.RAISED)
    cv1.grid(row=1,column=0)
    im = Image.open(src+str(i)+".jpg")
    if (490-im.size[0])<(390-im.size[1]):
        width = 490
        height = width*im.size[1]/im.size[0]
    else:
        height = 390
        width = height*im.size[0]/im.size[1]
    im.thumbnail((width, height), Image.ANTIALIAS)
    photo = ImageTk.PhotoImage(im)
    cv1.create_image(0, 0, image=photo, anchor='nw')
    claButton = tk.Button(master=root, text='Classify', height=2, width=10, command=classify_obj)
    claButton.grid(row=0, column=1, padx=2, pady=2)
    frame2 = tk.Frame(root, width=500, height=400, bd=1)
    frame2.grid(row=1, column=1)
    cv2 = tk.Canvas(frame2, height=390, width=490, bd=2, relief=tk.SUNKEN)
    cv2.grid(row=1,column=1)
    broButton = tk.Button(master=root, text='Next', height=2, width=8, command=wait)
    broButton.grid(row=0, column=0, padx=2, pady=2)
    print(i)

tk.mainloop()
import tkinter as tk
from PIL import Image,ImageTk,ImageFilter,ImageOps
from msvcrt import getch

src = 'images/'
i = 1

def showImage():
    global i
    # You need to do file exists error checking here.
    try:
        im = Image.open(src+str(i)+".jpg")
    except:
        print("No image file named", src+str(i)+".jpg")
        return
    if (490-im.size[0])<(390-im.size[1]):
        width = 490
        height = width*im.size[1]/im.size[0]
    else:
        height = 390
        width = height*im.size[0]/im.size[1]
    im.thumbnail((width, height), Image.ANTIALIAS)
    photo = ImageTk.PhotoImage(im)
    label.configure(image=photo)
    label.image = photo
    i += 1
    return

def classify_obj():
    print("In Development")
    return

root = tk.Tk()
root.wm_title("Classify Image")

frame1 = tk.Frame(root, width=500, height=400, bd=2)
frame1.grid(row=1, column=0)
cv1 = tk.Canvas(frame1, height=390, width=490, background="white", bd=1, relief=tk.RAISED)
label = tk.Label(cv1)
cv1.create_window(0, 0, anchor='nw', window=label)
cv1.grid(row=1,column=0)
claButton = tk.Button(master=root, text='Classify', height=2, width=10, command=classify_obj)
claButton.grid(row=0, column=1, padx=2, pady=2)
frame2 = tk.Frame(root, width=500, height=400, bd=1)
frame2.grid(row=1, column=1)
cv2 = tk.Canvas(frame2, height=390, width=490, bd=2, relief=tk.SUNKEN)
cv2.grid(row=1,column=1)
broButton = tk.Button(master=root, text='Next', height=2, width=8, command=showImage)
broButton.grid(row=0, column=0, padx=2, pady=2)

showImage()
tk.mainloop()
import tkinter as tk
from PIL import Image,ImageTk
import os


class ImageClassifyer(tk.Frame):


    def __init__(self, parent, *args, **kwargs):

        tk.Frame.__init__(self, parent, *args, **kwargs)

        self.root = parent
        self.root.wm_title("Classify Image")   
        src = "./TestImages/"

        self.list_images = []
        for d in os.listdir(src):
            self.list_images.append(d)

        self.frame1 = tk.Frame(self.root, width=500, height=400, bd=2)
        self.frame1.grid(row=1, column=0)
        self.frame2 = tk.Frame(self.root, width=500, height=400, bd=1)
        self.frame2.grid(row=1, column=1)

        self.cv1 = tk.Canvas(self.frame1, height=390, width=490, background="white", bd=1, relief=tk.RAISED)
        self.cv1.grid(row=1,column=0)
        self.cv2 = tk.Canvas(self.frame2, height=390, width=490, bd=2, relief=tk.SUNKEN)
        self.cv2.grid(row=1,column=0)

        claButton = tk.Button(self.root, text='Classify', height=2, width=10, command=self.classify_obj)
        claButton.grid(row=0, column=1, padx=2, pady=2)
        broButton = tk.Button(self.root, text='Next', height=2, width=8, command = self.next_image)
        broButton.grid(row=0, column=0, padx=2, pady=2)

        self.counter = 0
        self.max_count = len(self.list_images)-1
        self.next_image()

    def classify_obj(self):
        print("In Development")

    def next_image(self):

        if self.counter > self.max_count:
            print("No more images")
        else:
            im = Image.open("{}{}".format("./TestImages/", self.list_images[self.counter]))
            if (490-im.size[0])<(390-im.size[1]):
                width = 490
                height = width*im.size[1]/im.size[0]
                self.next_step(height, width)
            else:
                height = 390
                width = height*im.size[0]/im.size[1]
                self.next_step(height, width)

    def next_step(self, height, width):
        self.im = Image.open("{}{}".format("./TestImages/", self.list_images[self.counter]))
        self.im.thumbnail((width, height), Image.ANTIALIAS)
        self.root.photo = ImageTk.PhotoImage(self.im)
        self.photo = ImageTk.PhotoImage(self.im)

        if self.counter == 0:
            self.cv1.create_image(0, 0, anchor = 'nw', image = self.photo)

        else:
            self.im.thumbnail((width, height), Image.ANTIALIAS)
            self.cv1.delete("all")
            self.cv1.create_image(0, 0, anchor = 'nw', image = self.photo)
        self.counter += 1


if __name__ == "__main__":
    root = tk.Tk() 
    MyApp = ImageClassifyer(root)
    tk.mainloop()