来自gui import * in python 3?

时间:2013-05-05 01:00:03

标签: user-interface python-3.x importerror

我正在尝试这个:

import os, sys
from Gui import *
import Image as PIL
import ImageTk

class ImageBrowser(Gui):

    def __init__(self):
        Gui.__init__(self)

        self.button = self.bu(command=self.quit, relief=FLAT)

    def image_loop(self, dirname='.'):

        files = os.listdir(dirname)
        for file in files:
            try:
                self.show_image(file)
                print (file)
                self.mainloop()
            except IOError:
                continue
            except:
                break

    def show_image(self, filename):

        image = PIL.open(filename)
        self.tkpi = ImageTk.PhotoImage(image)
        self.button.config(image=self.tkpi)

def main(script, dirname='.'):
    g = ImageBrowser()
    g.image_loop(dirname)

if __name__ == '__main__':
    main(*sys.argv)

我收到的错误是:     来自Gui进口*     ImportError:没有名为Gui的模块

我假设“来自Gui import *”在python 3中不起作用,有没有人知道如何在python 3中执行此操作?非常感谢你(

1 个答案:

答案 0 :(得分:3)

如果你在谈论Gui module that comes with Swampy,那么 为了在Python3中使用Gui,您需要安装Python3 version of Swampy