from Gui import * in python 3?

浪子不回头ぞ 提交于 2019-12-02 20:39:57

问题


I'm trying this:

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)

I'm getting an error that says: from Gui import * ImportError: No module named Gui

I'm assuming "from Gui import *" doesn't work in python 3, does anyone know how to do this in python 3? Thank you so much (:


回答1:


If you are talking about the Gui module that comes with Swampy, then in order to use Gui with Python3, you'll need to install the Python3 version of Swampy.



来源:https://stackoverflow.com/questions/16380392/from-gui-import-in-python-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!