Exemple #1
0
 def __init__(self, message, sender):
     Gui.__init__(self)
     self.title('Popup')
     self.la(text='From: %s' % sender)
     self.la(text=message)
     self.bu(text='Close', command=self.destroy)
     self.mainloop()
Exemple #2
0
 def __init__(self, message, sender):
     Gui.__init__(self)
     self.title('Popup')
     self.la(text='From: %s' % sender)
     self.la(text=message)
     self.bu(text='Close', command=self.destroy)
     self.mainloop()
Exemple #3
0
    def quit(self):
        """Shuts down the World."""
        # tell other threads that the world is gone
        self.exists = False

        # destroy closes the window
        self.destroy()

        # quit terminates mainloop (but since mainloop can get called
        # recursively, quitting once might not be enough!)
        Gui.quit(self)
Exemple #4
0
    def __init__(self, debug=False, pedantic=False):
        """Initializes Lumpy.

        Args:
            debug: boolean that makes the outlines of the frames visible.
            pedantic: boolean whether to show aliasing for simple values.

        If pedantic is false, simple values are replicated, rather
        than, for example, having all references to 1 refer to the
        same int object.
        """
        Gui.__init__(self, debug)
        self.pedantic = pedantic
        self.withdraw()

        # initially there is no object diagram, no class diagram
        # and no representation of the stack.
        self.od = None
        self.cd = None
        self.stack = None

        # instance_vars maps from classes to the instance vars
        # that are drawn for that class; for opaque classes, it
        # is an empty list.

        # an instance of an opaque class is shown with a small empty box;
        # the contents are not shown.
        self.instance_vars = {}

        # the following classes are opaque by default
        self.opaque_class(Lumpy)
        self.opaque_class(object)
        self.opaque_class(type(make_thing))  # function
        self.opaque_class(Exception)
        self.opaque_class(set)  # I don't remember why

        # any object that belongs to a class in the Tkinter module
        # is opaque (the name of the module depends on the Python version)
        self.opaque_module(tkinter_module)

        # by default, class objects and module objects are opaque
        classobjtype = type(Lumpy)
        self.opaque_class(classobjtype)
        modtype = type(inspect)
        self.opaque_class(modtype)

        # the __class__ of a new-style object is a type object.
        # when type objects are drawn, show only the __name__
        self.opaque_class(type)

        self.make_reference()
Exemple #5
0
    def __init__(self, delay=0.5, *args, **kwds):
        Gui.__init__(self, *args, **kwds)
        self.delay = delay
        self.title('World')

        # keep track of the most recent world
        World.current_world = self

        # set to False when the user presses quit.
        self.exists = True

        # list of animals that live in this world.
        self.animals = []

        # if the user closes the window, shut down cleanly
        self.protocol("WM_DELETE_WINDOW", self.quit)
    def __init__(self, args=['']):
        Gui.__init__(self)
        self.parse_args(args)
        self.namer = Namer()

        self.locals = sim_locals
        self.globals = sim_globals

        self.views = {}
        self.w = self
        self.threads = []
        self.running = False
        self.delay = 0.2
        self.setup()
        self.run_init()
        for col in self.cols:
            col.create_thread()
 def __init__(self):
     Gui.__init__(self)
     self.title('GraphWorld')
     self.setup()
 def __init__(self):
     Gui.__init__(self)
     self.title('GraphWorld')
     self.setup()
 def destroy(self):
     """Closes the top window."""
     self.running = False
     Gui.destroy(self)
Exemple #10
0
root = "./"
img_file_paths = []
for path, subdirs, files in os.walk(root):
    for name in files:
        file_path = os.path.join(path, name)
        #neu open duoc file bang image, thi file do chinh la image, neu ko dc thi bo qua
        try:
            with Image.open(file_path) as im:
                img_file_paths.append(file_path)
                print(file_path, im.format, "%dx%d" % im.size, im.mode)
        except IOError:
            pass
print(img_file_paths)

g = Gui()
canvas = g.ca(width=200, height=200)
image_path = './python_mini.GIF'
label1 = g.la(text=image_path)

#show image to canvas
image = Image.open(image_path)
photo = ImageTk.PhotoImage(image)  #convert to ImageTk
myimg = canvas.image([0, 0], image=photo)


#click event
def callback(event):
    print("clicked at", event.x, event.y)
    global img_file_paths