Exemplo n.º 1
0
class Picture(object):
    def __init__(self, tk_hnd):
        self._img = None
        self._hnd = tk_hnd

    def open_file(self, filename):
        self._img = PhotoImage(file=filename)        
        self.refresh()

    def refresh(self):
        if not self._img:
            return
        self._hnd.configure(image=self._img)

    @property
    def width(self):
        if not self._img:
            return None
        else:
            return self._img.width()

    @property
    def height(self):
        if not self._img:
            return None
        else:
            return self._img.height()
Exemplo n.º 2
0
def eye_image_callback(eye_image_data):
    print("System time: {0}, Device time {1}, Camera id {2}".format(
        eye_image_data['system_time_stamp'],
        eye_image_data['device_time_stamp'], eye_image_data['camera_id']))

    image = PhotoImage(
        data=base64.standard_b64encode(eye_image_data['image_data']))
    print("{0} width {1}, height {2}".format(image, image.width(),
                                             image.height()))
Exemplo n.º 3
0
class SplashScreen(Toplevel):
    def __init__(self, master, image=None, timeout=1000):
        """(master, image, timeout=1000) -> create a splash screen
        from specified image file.  Keep splashscreen up for timeout
        milliseconds"""
        
        Toplevel.__init__(self, master, relief=FLAT, borderwidth=0)
        if master == None: master = Tk()
        self.main = master
        if self.main.master != None: # Why ?
            self.main.master.withdraw()
        self.main.withdraw()
        self.overrideredirect(1)
        self.image = PhotoImage(file=image)
        self.after_idle(self.centerOnScreen)

        self.update()
        if (timeout != 0): self.after(timeout, self.destroy)

    def centerOnScreen(self):
        self.update_idletasks()
        width, height = self.width, self.height = \
                        self.image.width(), self.image.height()

        xmax = self.winfo_screenwidth()
        ymax = self.winfo_screenheight()

        x0 = self.x0 = xmax/2 - width/2
        y0 = self.y0 = ymax/2 - height/2
        
        self.geometry("%dx%d+%d+%d" % (width, height, x0, y0))
        self.createWidgets()

    def createWidgets(self):
        self.canvas = Canvas(self, width=self.width, height=self.height)
        self.canvas.create_image(0,0, anchor=NW, image=self.image)
        self.canvas.pack()

    def destroy(self):
        # self.main.update()
        # self.main.deiconify()
        self.main.withdraw()
        self.withdraw()
Exemplo n.º 4
0
class CollapsibleFrame(Frame):
    def __init__(self,
                 master,
                 text=None,
                 borderwidth=2,
                 width=0,
                 height=16,
                 interior_padx=0,
                 interior_pady=8,
                 background=None,
                 caption_separation=4,
                 caption_font=None,
                 caption_builder=None,
                 icon_x=5):
        Frame.__init__(self, master)
        if background is None:
            background = self.cget("background")

        self.configure(background=background)

        self._is_opened = False

        self._interior_padx = interior_padx
        self._interior_pady = interior_pady

        self._iconOpen = PhotoImage(
            data=
            "R0lGODlhEAAQAKIAAP///9TQyICAgEBAQAAAAAAAAAAAAAAAACwAAAAAEAAQAAADNhi63BMgyinFAy0HC3Xj2EJoIEOM32WeaSeeqFK+say+2azUi+5ttx/QJeQIjshkcsBsOp/MBAA7"
        )
        self._iconClose = PhotoImage(
            data=
            "R0lGODlhEAAQAKIAAP///9TQyICAgEBAQAAAAAAAAAAAAAAAACwAAAAAEAAQAAADMxi63BMgyinFAy0HC3XjmLeA4ngpRKoSZoeuDLmo38mwtVvKu93rIo5gSCwWB8ikcolMAAA7"
        )

        height_of_icon = max(self._iconOpen.height(), self._iconClose.height())
        width_of_icon = max(self._iconOpen.width(), self._iconClose.width())

        containerFrame_pady = (height_of_icon // 2) + 1

        self._height = height
        self._width = width

        self._containerFrame = Frame(self,
                                     borderwidth=borderwidth,
                                     width=width,
                                     height=height,
                                     relief=RIDGE,
                                     background=background)
        self._containerFrame.pack(expand=True,
                                  fill=X,
                                  pady=(containerFrame_pady, 0))

        self.interior = Frame(self._containerFrame, background=background)

        self._collapseButton = Label(self,
                                     borderwidth=0,
                                     image=self._iconOpen,
                                     relief=RAISED)
        self._collapseButton.place(in_=self._containerFrame,
                                   x=icon_x,
                                   y=-(height_of_icon // 2),
                                   anchor=N + W,
                                   bordermode="ignore")
        self._collapseButton.bind("<Button-1>", lambda event: self.toggle())

        if caption_builder is None:
            self._captionLabel = Label(self,
                                       anchor=W,
                                       borderwidth=1,
                                       text=text)
            if caption_font is not None:
                self._captionLabel.configure(font=caption_font)
        else:
            self._captionLabel = caption_builder(self)

            if not isinstance(self._captionLabel, Widget):
                raise Exception(
                    "'caption_builder' doesn't return a tkinter widget")

        self.after(
            0, lambda: self._place_caption(caption_separation, icon_x,
                                           width_of_icon))

    def update_width(self, width=None):
        # Update could be devil
        # http://wiki.tcl.tk/1255
        self.after(0, lambda width=width: self._update_width(width))

    def _place_caption(self, caption_separation, icon_x, width_of_icon):
        self.update()
        x = caption_separation + icon_x + width_of_icon
        y = -(self._captionLabel.winfo_reqheight() // 2)

        self._captionLabel.place(in_=self._containerFrame,
                                 x=x,
                                 y=y,
                                 anchor=N + W,
                                 bordermode="ignore")

    def _update_width(self, width):
        self.update()
        if width is None:
            width = self.interior.winfo_reqwidth()

        if isinstance(self._interior_pady, (list, tuple)):
            width += self._interior_pady[0] + self._interior_pady[1]
        else:
            width += 2 * self._interior_pady

        width = max(self._width, width)

        self._containerFrame.configure(width=width)

    def open(self):
        self._collapseButton.configure(image=self._iconClose)

        self._containerFrame.configure(height=self.interior.winfo_reqheight())
        self.interior.pack(expand=True,
                           fill=X,
                           padx=self._interior_padx,
                           pady=self._interior_pady)

        self._is_opened = True

    def close(self):
        self.interior.pack_forget()
        self._containerFrame.configure(height=self._height)
        self._collapseButton.configure(image=self._iconOpen)

        self._is_opened = False

    def toggle(self):
        if self._is_opened:
            self.close()
        else:
            self.open()
Exemplo n.º 5
0
class Palette_frame(Frame):
    def __init__(self,
                 master,
                 text=None,
                 borderwidth=2,
                 width=0,
                 height=16,
                 interior_padx=0,
                 interior_pady=8,
                 background=None,
                 caption_separation=4,
                 caption_font=None,
                 caption_builder=None,
                 icon_x=5):
        Frame.__init__(self, master)

        self._is_opened = False

        self._interior_padx = interior_padx
        self._interior_pady = interior_pady

        self._iconOpen = PhotoImage(
            data=
            "R0lGODlhEwATAPcAAAAAAAAAAQD/AAIAAQUAAgcFAAoEAAwHABALABQMBBUPARUSAhUTBhgQBBgVCRsUACEWACIcACYgACggACshACwoADElATEpADEtATQkADQpADYxBDctATk0AT8uAEA6AEE1AEU0AUY3AEY7AUc/Ako7AUpFBUxAA1BHAVE6AFRHAFU/AFdGAFdQAFhCAFlUAVpMAFxGAF1DAF5TAGBaAGNIAGRYAGReAmVSAGhMAGpPAGpWAmpfAm1SAG9RAHFXAHFhAXFrAXJbAXJnAHZuA3dYAHxcAnxfAXxkAHxuAH1gAH5qAX5zAIBcAoRiAIRxAIR5AIdmAIhqAIlyAImAAop6AIxmAI9xAY95AY+BAJJtAJRvAJSIAJV5AZWAAJd1AJl0App5AJtxAZuJAJx/AJyKAZyPAJ+UAKB2AKGAAKKIAaSUAKV7AKeAAaeJAKqeA6uQAKuaAKyVAa+BAK+JALCiALOEALORALSWALSiALWaALeqAbmLALuhALyXALyqALywAL6LAMC0AMGfAMGkAMKRAMOWAMOpAMOvAMO6AMqYAMqiAMqyAMunAMuuAMu+AMy5AM2dAs7DANGfAtG7AdKwANPFANWoANXFANihANi4ANi9ANmyANnEANrLANunAN6mAN/MAOC/AODFAOK5AOLRAOOsAOWxAOasAOfFAefWAOm5AenNAOnTAOu/AOyzBezaAO3YAO60Be7dAPDFAPG1APLQAPO9APPLAPPdAPPjAfS2APTBAPTDAPW/APa/APbAAPbDAPbXAPe/APfIAPfPAPi9APjLAPjjAPm9APnXAPnbAPnkAPrRAPrqAPu8APu/APvBAPvDAPvNAPvUAPvXAPvdAPviAPzHAPzLAPzTAfzWAPzdAPzhAPzkAPzlAPzuAP2+AP3MAP3PAP3VAP3ZAP3iAP3kAP3pAP3sAP3tAP3vAP68AP7FAP7IAP7KAP7RAP7TAf7XAP7aAP7dAP7fAP7jAP7lAP7oAP7qAP7xAP/GAP/pAP/uAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFBwACACwAAAAAEwATAAAIuAABCBxIsKDBgwgFRuBhpqHDLCYSjtiTq6LFVmM0aNyoIUKBEoSaiRzZbBSiPyj/EOrzZEKIQr5+AZsJLNgydThzqktEosShZcusCRV6L5/Ro/kSmTjB6J7Tp1CjIiLB1JzVq1izTj3hiJ7Xr2DDHqLaSJ7Zs2jRljtUokSjeHDjyp1LqO2icXjz6t07yK67v4ADC+5bwlC0w4gTKzYkwsMcU5AjS548xwMCDzkya97M2XLCz6ARBgQAIfkEBQYAAgAsAAACABMAEAAAAg+Uj6nL7Q+jnLTai7PeHBUAIfkEBQcAAgAsAAACABIACgAAAgyUj6nL7Q+jnLTaVgAAIfkEBQcAAgAsAwAFAAUAAgAAAgOUjwUAOw=="
        )
        self._iconClose = PhotoImage(
            data=
            "R0lGODlhEwATAPcAAAAAAAAAAgD/AAEAAAEBAAIAAQUEAAoFAAsJAA4LABMOABUSBRcPAhkUABoYBx4XBB8YACEbASQfASgiACoeAC4jAS4nADEsADMvATQnADUuBTYuADk2ATsxADwtAT84AUI7AEQzAEQ5AEZBAEo5Ako9AUpDAU88AVBGAVBLAVQ9AVRCAFZQAVhGAFhLAVtUAV9CAF9LAWFQAmFZAWFaAGJRAGRLAWVHAGVeAGdiAGtTAmtZBGxZAGxkAG1PAG1iAnFdAHFpAXRUAnRWA3RZAXRiAXZeAHhqAXpiAXpvAXtzAYBcAIFrAYJjAoNgAYN1AoV9AYhrAop0AYtlAI2FAY59AY9jAJB4AJFrApFsApJyAZOFAZRoAZSMAZV+AJmCAJuPAJxmAJxzAJ15AJ2IAJ+CAKGQAaGXAaV6AKV7AKeLAKh8AKiRAKmXAatpAqyhAK2BAK+IAbGEALGYALKEBbOlArV6AbWIALaaAbiLALiUArihArqtAb2NAL+uAMCQA8CZAMGkAMGoAMOAAMO1AcWuAMaTAMa7AMeZAcuYA8uZAMunAMy1AM2YAM29Ac6wAM+bANLFAtSeANSoAdS3AdW+AdaCANahAdfMAdmIANqmAN2wAd3EAN3NAt6oAN7BAOCTAOC4AeHWAeKJAOOsAOSaAOStAOXJAOaMAOeQAOqTAOrQAOuyAOu9AOvKAOvWAOvfAuyWAO2gAO6oAO+bAO+2AO+4APGvAPG8APKfAPLeAPPPAPSiAPSoAPS7APTFAPTXAPW1APW4APXAAPXlAPbKAPemAPerAPfOAPfgAPfqAPjVAPjaAPmwAPm8APm/APnMAPq1APq5APrHAPrgAPvCAPvOAPvXAPvrAfzUAPzgAPzmAPztAPzvAP27AP3AAP3FAP3HAP3KAP3MAP3VAP3ZAP3iAP3kAP3qAP3vAP7FAP7IAP7JAP7MAP7PAP7SAP7TAP7XAP7YAP7cAf7eAP7fAP7jAP7nAP7qAP7sAP7uAP/QAP/TAP/bAP/oAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFBwACACwAAAAAEwATAAAIygABCBxIsKDBgwgHGlCwoGFDBQcSAugQRImSJ0+UBPkgEQosYiBB6jojgkRJkx0aCNyyDZ/Ll6sEBZo5c44MgVWuzdvJsyfPZVUEaoHWrqjRduOSjitaTIpALMGkSZ0aTZgwZ1id+dLC4IATVbFo0cpF1teys2iXVWLxotIuZHDRanv5Mh+xHj+SmdvLt6/fVS9kuPJJuOcjEyUWwVvMuLHjOR0yqFFKubLSMREUZKllq7Pnz55rRTEAgMQULKhTq07tJITE17ANBgQAIfkEBQYAAgAsAAACABMADwAACDUABQgcSLCgwYMIExoUIUKhQ4LMHkok2E7gtILRJmo8iMxhvnz4NoocqbCduJMoU6YkyVJAQAAh+QQFBwABACwBAAMAEgANAAAIHgADCBxIsKDBgwgTKlzIkKGVhhAjSpxIMaK4ihEDAgAh+QQFBwABACwCAAMAEAANAAAIIQADCBxIsKDBgwgTKlzIsOFAYQRzOUyYb6LFiwTbYWwYEAA7"
        )

        height_of_icon = max(self._iconOpen.height(), self._iconClose.height())
        width_of_icon = max(self._iconOpen.width(), self._iconClose.width())

        containerFrame_pady = (height_of_icon // 2) + 1

        self._height = height
        self._width = width

        self._containerFrame = Frame(self,
                                     borderwidth=borderwidth,
                                     width=width,
                                     height=height,
                                     relief=RIDGE,
                                     background=background)
        self._containerFrame.pack(expand=True,
                                  fill=X,
                                  pady=(containerFrame_pady, 0))

        self.interior = Frame(self._containerFrame, background=background)

        self._collapseButton = Label(self,
                                     borderwidth=0,
                                     image=self._iconOpen,
                                     relief=RAISED)
        self._collapseButton.place(in_=self._containerFrame,
                                   x=icon_x,
                                   y=-(height_of_icon // 2),
                                   anchor=N + W,
                                   bordermode="ignore")
        self._collapseButton.bind("<Button-1>", lambda event: self.toggle())

        if caption_builder is None:
            self._captionLabel = Label(self,
                                       anchor=W,
                                       borderwidth=1,
                                       text=text)
            if caption_font is not None:
                self._captionLabel.configure(font=caption_font)
        else:
            self._captionLabel = caption_builder(self)

            if not isinstance(self._captionLabel, Widget):
                raise Exception(
                    "'caption_builder' doesn't return a Tkinter widget")

        self.after(
            0, lambda: self._place_caption(caption_separation, icon_x,
                                           width_of_icon))

    def _place_caption(self, caption_separation, icon_x, width_of_icon):
        self.update()
        x = caption_separation + icon_x + width_of_icon
        y = -(self._captionLabel.winfo_reqheight() // 2)

        self._captionLabel.place(in_=self._containerFrame,
                                 x=x,
                                 y=y,
                                 anchor=N + W,
                                 bordermode="ignore")

    def open(self):
        self._collapseButton.configure(image=self._iconClose)

        self._containerFrame.configure(height=self.interior.winfo_reqheight())
        self.interior.pack(expand=True,
                           fill=X,
                           padx=self._interior_padx,
                           pady=self._interior_pady)

        self._is_opened = True

    def close(self):
        self.interior.pack_forget()
        self._containerFrame.configure(height=self._height)
        self._collapseButton.configure(image=self._iconOpen)

        self._is_opened = False

    def toggle(self):
        if self._is_opened:
            self.close()
        else:
            self.open()
Exemplo n.º 6
0
class UI(Tkinter.Tk):
    def __init__(self, parent):
        Tkinter.Tk.__init__(self, parent)
        self.parent = parent
        self.initialize()

    def initialize(self):

        ################ Menu ################
        self.menu1 = Tkinter.Menu(tearoff=0)

        self.fichier = Tkinter.Menu(tearoff=0)
        self.menu1.add_cascade(label="Fichier", menu=self.fichier)
        self.fichier.add_command(label="  Quitter", command=self.quitter)
        self.fichier = Tkinter.Menu(tearoff=0)
        self.menu1.add_cascade(label="Aide", menu=self.fichier)
        self.fichier.add_command(label="  A propos", command=self.apropos)

        self.config(menu=self.menu1)
        ################ /Menu ###############

        self.grid()

        """
        ## champ IP ##
        self.labelIP = Tkinter.Label(self,anchor='w',text="IP du serveur Qemu :")
        self.labelIP.grid(column=0,row=0,sticky='EW')
        
        self.entryVariableIP = Tkinter.StringVar()
        self.entryVariableIP.set("Not supported yet")
        self.entryIP = Tkinter.Entry(self,textvariable=self.entryVariableIP)
        self.entryIP.grid(column=0,row=1,sticky='EW')
        """

        ## champ Port LED verte ##
        self.labelPortVerte = Tkinter.Label(self, anchor="w", text="Port LED verte :")
        self.labelPortVerte.grid(column=0, row=2, sticky="EW")

        self.entryVariablePortVerte = Tkinter.StringVar()
        self.entryVariablePortVerte.set(u"4242")
        self.entryPortVerte = Tkinter.Entry(self, textvariable=self.entryVariablePortVerte)
        self.entryPortVerte.grid(column=0, row=3, sticky="EW")

        ## champ Port LED Bleue ##
        self.labelPortBleue = Tkinter.Label(self, anchor="w", text="Port LED bleue :")
        self.labelPortBleue.grid(column=0, row=4, sticky="EW")

        self.entryVariablePortBleue = Tkinter.StringVar()
        self.entryVariablePortBleue.set(u"4243")
        self.entryPortBleue = Tkinter.Entry(self, textvariable=self.entryVariablePortBleue)
        self.entryPortBleue.grid(column=0, row=5, sticky="EW")

        ## champ Port Bouton ##
        self.labelPortBouton = Tkinter.Label(self, anchor="w", text="Port Bouton :")
        self.labelPortBouton.grid(column=0, row=6, sticky="EW")

        self.entryVariablePortBouton = Tkinter.StringVar()
        self.entryVariablePortBouton.set(u"4244")
        self.entryPortBouton = Tkinter.Entry(self, textvariable=self.entryVariablePortBouton)
        self.entryPortBouton.grid(column=0, row=7, sticky="EW")

        button = Tkinter.Button(self, text="Lancer", command=self.OnButtonLancerClick)
        button.grid(column=0, row=8, sticky="EW")

        self.labelLog = Tkinter.Label(self, anchor="w", text="Log : ")
        self.labelLog.grid(column=0, row=9, sticky="EW")

        self.log = Tkinter.Text(width=20, height=20)
        self.log.grid(column=0, row=10, sticky="EWNS", rowspan=50)
        self.log.insert(Tkinter.END, "")

        button2 = Tkinter.Button(self, text="Vider", command=self.Clear)
        button2.grid(column=0, row=60, sticky="EW")

        scrollbar = Tkinter.Scrollbar(self.log, width=10)
        scrollbar.pack(side="right", fill="y")

        scrollbar.config(command=self.log.yview)
        self.log.config(yscrollcommand=scrollbar.set)

        # Images #
        self.carte = PhotoImage(file="img/carte.gif")
        self.ledBlanche = PhotoImage(file="img/LEDblanche.gif")
        self.ledBleue = PhotoImage(file="img/LEDbleue.gif")
        self.ledVerte = PhotoImage(file="img/LEDverte.gif")
        self.user = PhotoImage(file="img/user.gif")

        self.canvas = Tkinter.Canvas(self, width=self.carte.width(), height=self.carte.height())
        self.canvas.grid(column=2, row=1, rowspan=70)
        self.canvas.create_image(0, 0, anchor="nw", image=self.carte)

        self.canvas.create_image(70, 390, image=self.user, tag="user", anchor="nw")
        self.canvas.create_image(150, 390, image=self.user, tag="reset", anchor="nw")
        self.canvas.tag_bind("reset", "<B1-ButtonRelease>", self.Reset)
        self.canvas.tag_bind("user", "<Button-1>", self.UserPressed)
        self.canvas.tag_bind("user", "<B1-ButtonRelease>", self.UserReleased)

        self.ledGauche = self.canvas.create_image(35, 400, anchor="nw", image=self.ledBlanche)
        self.ledDroite = self.canvas.create_image(190, 400, anchor="nw", image=self.ledBlanche)

        # self.grid_columnconfigure(1,weight=1)
        # self.grid_columnconfigure(0,weight=1) INUTILE
        # self.grid_rowconfigure(0,weight=1) #Gestion verticale de l'agrandissement
        self.resizable(False, False)  # Pas redimentionable !

        # self.geometry(self.geometry())
        self.update()

    def OnButtonLancerClick(self):
        app.event.set()

    def UserPressed(self, none):
        self.log.insert(Tkinter.END, "User button pressed\n")
        app.user_pressed()
        self.log.see(Tkinter.END)

    def UserReleased(self, none):
        self.log.insert(Tkinter.END, "User button released\n")
        app.user_released()
        self.log.see(Tkinter.END)

    def Reset(self, none):
        self.log.insert(Tkinter.END, "Reset button clicked\n")
        self.log.see(Tkinter.END)

    def Clear(self):
        self.log.delete(1.0, Tkinter.END)

    def quitter(self):
        if hasattr(app, "thread"):
            app.close_conn()
        self.quit()

    def printlog(self, m):
        self.labelVariableLog.set(m)
        self.update()

    def apropos(self):
        self.apropos = Fenetre()
class AppAnalysis:


    def __init__(self, root):

        self.canvas = Canvas(root, width = 400, height = 350)
        self.canvas.configure(cursor="crosshair")
        self.canvas.pack(expand=YES, fill=BOTH, side='right')

        self.canvas.bind("<Key>", self.handle_key)
        self.canvas.bind("<Double-Button-1>", self.set_focus)
        self.canvas.bind("<Button-1>", self.set_cursor)
        self.canvas.bind("<Return>", self.remove_highlight)

        self.image, self.ponto1, self.ponto2 = (None, None, None)

        self.menubar = Menu(root)

        filemenu = Menu(self.menubar, tearoff=0)
        filemenu.add_command(label="Open Image", command=self.openImage)
        filemenu.add_command(label="Save", command=self.hello)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=root.quit)
        self.menubar.add_cascade(label="File", menu=filemenu)

        editmenu = Menu(self.menubar, tearoff=0)
        for e in ("Cut","Copy","Paste"):
            editmenu.add_command(label=e, command=self.hello)

        self.menubar.add_cascade(label="Edit", menu=editmenu)

        filtermenu = Menu(self.menubar, tearoff=0)
        filtermenu.add_command(label="Threshold", command=self.thresholdFilter)
        self.menubar.add_cascade(label="Filter", menu=filtermenu)

        reportmenu = Menu(self.menubar, tearoff=0)
        reportmenu.add_command(label="Relatorio.txt",
        command=self.generateReport)
        reportmenu.add_command(label="Relatorio.pdf")
        reportmenu.add_command(label="Email")
        self.menubar.add_cascade(label="Report", menu=reportmenu)

        helpmenu = Menu(self.menubar, tearoff=0)
        helpmenu.add_command(label="About", command=self.hello)
        self.menubar.add_cascade(label="Help", menu=helpmenu)

        root.config(menu=self.menubar)

        self.toolbar = Frame(root)
        self.toolbar.pack(side='left', fill='both')
        clean = Label(self.toolbar, text='Clean')
        clean.bind("<Button-1>", self.clean)
        b = Label(self.toolbar, text='B')
        c = Label(self.toolbar, text='C')
        d = Label(self.toolbar, text='D')

        for w in (clean,b,c,d):
            w.configure(relief="groove", font="Times 12 bold")
            w.pack(fill='both')

    def openImage(self):
        arquivo = tkFileDialog.askopenfile(parent=self.canvas,mode='rb',
        title='Imagem')
        e = ['GIF','JPEG','JPG','BMP','PNG','TIF']
        if(e.__contains__(arquivo.name.split(".")[-1].upper())):
            self.ponto1, self.ponto2 = (None,None)
            img_tmp = Image.open(arquivo)
            #self.img_name = path.dirname(path.abspath(arquivo.name))
            self.img_name = arquivo.name
            print self.img_name
            self.new_img_name = arquivo.name.split('/')[-1] + "_tmp.gif"
            pathtemp = mydir +"/temp/"+ self.new_img_name
            img_tmp.save(pathtemp)
            self.image = PhotoImage(file=pathtemp)
            self.setImage()
            self.canvas.bind("<Button-1>", self.click)
            self.proporcao = ""

    def clean(self, event):
        self.ponto1, self.ponto2 = (None,None)
        self.setImage()
        self.proporcao = ""

    def setImage(self):
        self.canvas.delete(ALL)
        if self.image.width() > 200 and self.image.height > 200:
            self.canvas.config(width = self.image.width())
            self.canvas.config(height = self.image.height())
        self.canvas.create_image(0, 0, image=self.image, anchor=NW)

    def generateReport(self):
        report = GeradorRelatorio(self.img_name)
        report.start()

    def hello(self):
        print "hello!"

    def thresholdFilter(self):
        img = Image.open(self.img_name)
        new_img = img.filter(ImageFilter.BLUR)
        aux = mydir +"/temp/"+ self.new_img_name
        new_img.save(aux)
        self.image = PhotoImage(file=aux)
        self.setImage()

    def click(self, event):
        if not self.ponto1:
            self.canvas.create_oval(event.x, event.y, event.x+5, event.y+5,
            fill="red")
            self.ponto1 = (event.x,event.y)
        else:
            if not self.ponto2:
                self.canvas.create_oval(event.x, self.ponto1[1],
                event.x+5, self.ponto1[1]+5, fill="red")

                self.ponto2 = (event.x,self.ponto1[1])

                pontos = [self.ponto1[0]+1,self.ponto1[1]+2,
                self.ponto2[0]+1,self.ponto2[1]+2]

                self.canvas.create_line(pontos, tags="theline", fill='red')
                x = (self.ponto2[0] + self.ponto1[0]) / 2
                self.canvas.create_text(x, self.ponto1[1]+8, text="1 umm")

    def remove_highlight(self,event):
        self.canvas.delete("highlight")

    def highlight(self, item):
        bbox = self.canvas.bbox(item)
        self.canvas.delete("highlight")
        if bbox:
            i = self.canvas.create_rectangle(
            bbox, fill="white",
            tag="highlight"
            )
            self.canvas.lower(i, item)

    def has_focus(self):
        return self.canvas.focus()

    def has_selection(self):
        return self.canvas.tk.call(self.canvas._w, 'select', 'item')

    def set_focus(self, event):
        if self.canvas.type(CURRENT) != "text":
            return

        self.highlight(CURRENT)

        self.canvas.focus_set()
        self.canvas.focus(CURRENT)
        self.canvas.select_from(CURRENT, 0)
        self.canvas.select_to(CURRENT, END)

    def set_cursor(self, event):
        item = self.has_focus()
        if not item:
            return

        x = self.canvas.canvasx(event.x)
        y = self.canvas.canvasy(event.y)

        self.canvas.icursor(item, "@%d,%d" % (x, y))
        self.canvas.select_clear()

    def handle_key(self, event):
        item = self.has_focus()
        if not item:
            return

        insert = self.canvas.index(item, INSERT)

        if event.char >= " ":
            if self.has_selection():
                self.canvas.dchars(item, SEL_FIRST, SEL_LAST)
                self.canvas.select_clear()
            self.canvas.insert(item, "insert", event.char)
            self.highlight(item)

        elif event.keysym == "BackSpace":
            if self.has_selection():
                self.canvas.dchars(item, SEL_FIRST, SEL_LAST)
                self.canvas.select_clear()
            else:
                if insert > 0:
                    self.canvas.dchars(item, insert-1, insert)
            self.highlight(item)

        elif event.keysym == "Home":
            self.canvas.icursor(item, 0)
            self.canvas.select_clear()
        elif event.keysym == "End":
            self.canvas.icursor(item, END)
            self.canvas.select_clear()
        elif event.keysym == "Right":
            self.canvas.icursor(item, insert+1)
            self.canvas.select_clear()
        elif event.keysym == "Left":
            self.canvas.icursor(item, insert-1)
            self.canvas.select_clear()
        else:
            pass
Exemplo n.º 8
0
def show_cardset(*args):
    global tk_images
    tk_images = []
    if list_box.curselection():
        cs_name = list_box.get(list_box.curselection())
        cs = cardsets_dict[cs_name]
        ls = glob(os.path.join(cs.dir, '[0-9][0-9][a-z]' + cs.ext))
        ls += glob(os.path.join(cs.dir, 'back*' + cs.ext))
        if all_imgs:
            ls += glob(os.path.join(cs.dir, 'bottom*' + cs.ext))
            ls += glob(os.path.join(cs.dir, 'l*' + cs.ext))
        # ls = glob(os.path.join(cs.dir, '*.gif'))
        # if not ls: return
        ls.sort()
        pf = None
        x, y = 10, 10
        width, height = 0, 0
        canvas.delete('all')
        for f in ls:
            if Image:
                filter = {
                    'NEAREST': Image.NEAREST,
                    'BILINEAR': Image.BILINEAR,
                    'BICUBIC': Image.BICUBIC,
                    'ANTIALIAS': Image.ANTIALIAS,
                }[filter_var.get()]
                # filter = Image.BILINEAR
                # filter = Image.BICUBIC
                # filter = Image.ANTIALIAS
                # print f
                im = Image.open(f)
                if zoom != 0:
                    w, h = im.size
                    im = im.convert('RGBA')  # for save transparency
                    if rotate_var.get():
                        # rotate
                        # if filter == Image.ANTIALIAS:
                        #    filter = Image.BICUBIC
                        z = zoom * 5
                        a = abs(pi / 2 / 90 * z)
                        neww = int(w * cos(a) + h * sin(a))
                        newh = int(h * cos(a) + w * sin(a))
                        # print w, h, neww, newh
                        d = int(sqrt(w * w + h * h))
                        dx, dy = (d - w) / 2, (d - h) / 2
                        newim = Image.new('RGBA', (d, d))
                        newim.paste(im, (dx, dy))
                        im = newim
                        im = im.rotate(z, resample=filter)
                        x0, y0 = (d - neww) / 2, (d - newh) / 2
                        x1, y1 = d - x0, d - y0
                        im = im.crop((x0, y0, x1, y1))
                        t = str(z)
                    else:
                        # zoom
                        z = 1.0 + zoom / 10.0
                        z = max(0.2, z)
                        if 1:
                            tmp = Image.new('RGBA', (w + 2, h + 2))
                            tmp.paste(im, (1, 1), im)
                            im = tmp.resize((int(w * z), int(h * z)),
                                            resample=filter)
                        else:
                            im = im.resize((int(w * z), int(h * z)),
                                           resample=filter)
                        t = '%d %%' % int(z * 100)

                    zoom_label.config(text=t)

                else:
                    zoom_label.config(text='')
                image = ImageTk.PhotoImage(im)
            else:
                image = PhotoImage(file=f)
            tk_images.append(image)
            ff = os.path.split(f)[1]
            if pf is None:
                pf = ff[:2]
                x, y = 10, 10
            elif ff[:2] != pf:
                pf = ff[:2]
                x = 10
                y += image.height() + 10
            else:
                x += image.width() + 10
            canvas.create_image(x, y, image=image, anchor=NW)
            # canvas.create_rectangle(x, y, x+image.width(), y+image.height())
            width = max(width, x)
            height = max(height, y)
        width, height = width + image.width() + 10, height + image.height(
        ) + 10
        canvas.config(scrollregion=(0, 0, width, height))
        # print image.width(), image.height()
        label.config(text='''\
Name: %s
Type: %s
Directory: %s''' % (cs.name, cs.type, cs.dir))
Exemplo n.º 9
0
    def Takepic(self):  ## take pic button

        src = Frame(cwgt, width=400, height=300, relief=RAISED, borderwidth=1)
        src = camera.capture('src.png')
        analysed = camera.capture('analysed.png')
        if self.var0.get() == 1:
            camera.capture("/home/pi/Desktop/New/{0:%Y%m%d-%H%M%S}.png".format(
                datetime.now()))

        #'{0:%Y%m%d-%H%M%S}: start.'.format(datetime.now())
        #img_abc=PhotoImage(file="src.png")
        #h=img_abc.width()
        #w=img_abc.height()
        #print h,w

        #cv2.imwrite("src.png",src)

        #img_abc = cv2.imread("img.png",cv2.IMREAD_COLOR)
        #cv2.rectangle(img_abc,(50,50),(100,50),(255,0,0),15)
        #cv2.imwrite("out2.png",img_abc)

        img_origin = PhotoImage(file="src.png")
        cwgt2.img = img_origin
        cwgt2.create_image(200, 200, image=img_origin)

        h = img_origin.width()
        w = img_origin.height()
        #print h,w
        #px=img[55,55]

        #img_new=cv2.imread("out2.png")

        #pix=img_new[2,2]
        #pix0=img_new[2,2][0]
        #pix1=img_new[2,2][1]
        #pix2=img_new[2,2][2]
        #print pix,pix0,pix1,pix2

        #for j in range (0,h):
        #	  for i in range (0,w):
        #	  if img_new[i,j]

        #img_new[i,i]=[255,255,255]
        #pix__=img_new[2,2][0]
        #print pix__

        #cv2.imwrite("out3.png",img_new)
        #img_x=PhotoImage(file="out3.png")
        #cwgt2.img=img_x
        #cwgt2.create_image(200, 200,  image=img_x)

        #if self.var1.get() == True:

        #src=cv2.imread("src.png")
        #res=cv2.Canny(src,self.varLow.get(), self.varHigh.get())
        #retval,res = cv2.threshold(src, self.varLow.get(), self.varHigh.get(), cv2.THRESH_BINARY)
        #cv2.imwrite("analysed.png",res)

        if self.var2.get() == True:
            min_R = self.varRed_L.get()
            max_R = self.varRed_H.get()

            min_G = self.varGreen_L.get()
            max_G = self.varGreen_H.get()

            min_B = self.varBlue_L.get()
            max_B = self.varBlue_H.get()

            pro_2 = cv2.imread('analysed.png')
            #hsv = cv2.cvtColor(src,cv2.COLOR_BGR2HSV)
            lower = np.array([min_B, min_G, min_R], np.uint8)
            upper = np.array([max_B, max_G, max_R], np.uint8)
            mask = cv2.inRange(pro_2, lower, upper)
            analysed = cv2.bitwise_and(pro_2, pro_2, mask=mask)
            cv2.imwrite("analysed.png", analysed)
            #cv2.imshow('aaa',src)
            #
            #img2=PhotoImage(file="out.png")
            #cwgt.img2=img2
            #cwgt.create_image(200, 200,  image=img2)
            #cv2.imwrite("out3.png",img_new)
        img_show = PhotoImage(file="analysed.png")
        cwgt.img = img_show
        cwgt.create_image(200, 200, image=img_show)

        if self.var1.get() == True:

            src = cv2.imread("analysed.png")
            #analysed=cv2.Canny(src,self.varLow.get(), self.varHigh.get())
            retval, res = cv2.threshold(src, self.varLow.get(),
                                        self.varHigh.get(), cv2.THRESH_BINARY)
            cv2.imwrite("analysed.png", res)

        if self.var5.get() == True:
            src = cv2.imread("analysed.png")
            number = 0
            for j in range(self.x0_1, self.x1_1):
                for i in range(self.y0_1, self.y1_1):
                    if src[i, j][0] > 0 and src[i, j][1] > 0 and src[i,
                                                                     j][2] > 0:
                        src[i, j] = [255, 255, 255]
                        number = number + 1
            print number
            if number > 180:
                tkMessageBox.showinfo(title="OK", message="OK")
            else:
                tkMessageBox.showinfo(title="ng", message="ng")
            cv2.imwrite("analysed.png", src)
        img_show = PhotoImage(file="analysed.png")
        cwgt.img = img_show
        cwgt.create_image(200, 200, image=img_show)
Exemplo n.º 10
0
class UI(Tkinter.Tk):
    def __init__(self, parent):
        Tkinter.Tk.__init__(self, parent)
        self.parent = parent
        self.initialize()

    def initialize(self):

        ################ Menu ################
        self.menu1 = Tkinter.Menu(tearoff=0)

        self.fichier = Tkinter.Menu(tearoff=0)
        self.menu1.add_cascade(label="Fichier", menu=self.fichier)
        self.fichier.add_command(label="  Quitter", command=self.quitter)
        self.fichier = Tkinter.Menu(tearoff=0)
        self.menu1.add_cascade(label="Aide", menu=self.fichier)
        self.fichier.add_command(label="  A propos", command=self.apropos)

        self.config(menu=self.menu1)
        ################ /Menu ###############

        self.grid()
        '''
        ## champ IP ##
        self.labelIP = Tkinter.Label(self,anchor='w',text="IP du serveur Qemu :")
        self.labelIP.grid(column=0,row=0,sticky='EW')
        
        self.entryVariableIP = Tkinter.StringVar()
        self.entryVariableIP.set("Not supported yet")
        self.entryIP = Tkinter.Entry(self,textvariable=self.entryVariableIP)
        self.entryIP.grid(column=0,row=1,sticky='EW')
        '''

        ## champ Port LED verte ##
        self.labelPortVerte = Tkinter.Label(self,
                                            anchor='w',
                                            text="Port LED verte :")
        self.labelPortVerte.grid(column=0, row=2, sticky='EW')

        self.entryVariablePortVerte = Tkinter.StringVar()
        self.entryVariablePortVerte.set(u"4242")
        self.entryPortVerte = Tkinter.Entry(
            self, textvariable=self.entryVariablePortVerte)
        self.entryPortVerte.grid(column=0, row=3, sticky='EW')

        ## champ Port LED Bleue ##
        self.labelPortBleue = Tkinter.Label(self,
                                            anchor='w',
                                            text="Port LED bleue :")
        self.labelPortBleue.grid(column=0, row=4, sticky='EW')

        self.entryVariablePortBleue = Tkinter.StringVar()
        self.entryVariablePortBleue.set(u"4243")
        self.entryPortBleue = Tkinter.Entry(
            self, textvariable=self.entryVariablePortBleue)
        self.entryPortBleue.grid(column=0, row=5, sticky='EW')

        ## champ Port Bouton ##
        self.labelPortBouton = Tkinter.Label(self,
                                             anchor='w',
                                             text="Port Bouton :")
        self.labelPortBouton.grid(column=0, row=6, sticky='EW')

        self.entryVariablePortBouton = Tkinter.StringVar()
        self.entryVariablePortBouton.set(u"4244")
        self.entryPortBouton = Tkinter.Entry(
            self, textvariable=self.entryVariablePortBouton)
        self.entryPortBouton.grid(column=0, row=7, sticky='EW')

        button = Tkinter.Button(self,
                                text="Lancer",
                                command=self.OnButtonLancerClick)
        button.grid(column=0, row=8, sticky="EW")

        self.labelLog = Tkinter.Label(self, anchor='w', text="Log : ")
        self.labelLog.grid(column=0, row=9, sticky='EW')

        self.log = Tkinter.Text(width=20, height=20)
        self.log.grid(column=0, row=10, sticky='EWNS', rowspan=50)
        self.log.insert(Tkinter.END, "")

        button2 = Tkinter.Button(self, text="Vider", command=self.Clear)
        button2.grid(column=0, row=60, sticky="EW")

        scrollbar = Tkinter.Scrollbar(self.log, width=10)
        scrollbar.pack(side='right', fill='y')

        scrollbar.config(command=self.log.yview)
        self.log.config(yscrollcommand=scrollbar.set)

        # Images #
        self.carte = PhotoImage(file="img/carte.gif")
        self.ledBlanche = PhotoImage(file="img/LEDblanche.gif")
        self.ledBleue = PhotoImage(file="img/LEDbleue.gif")
        self.ledVerte = PhotoImage(file="img/LEDverte.gif")
        self.user = PhotoImage(file="img/user.gif")

        self.canvas = Tkinter.Canvas(self,
                                     width=self.carte.width(),
                                     height=self.carte.height())
        self.canvas.grid(column=2, row=1, rowspan=70)
        self.canvas.create_image(0, 0, anchor="nw", image=self.carte)

        self.canvas.create_image(70,
                                 390,
                                 image=self.user,
                                 tag="user",
                                 anchor="nw")
        self.canvas.create_image(150,
                                 390,
                                 image=self.user,
                                 tag="reset",
                                 anchor="nw")
        self.canvas.tag_bind("reset", "<B1-ButtonRelease>", self.Reset)
        self.canvas.tag_bind("user", "<Button-1>", self.UserPressed)
        self.canvas.tag_bind("user", "<B1-ButtonRelease>", self.UserReleased)

        self.ledGauche = self.canvas.create_image(35,
                                                  400,
                                                  anchor="nw",
                                                  image=self.ledBlanche)
        self.ledDroite = self.canvas.create_image(190,
                                                  400,
                                                  anchor="nw",
                                                  image=self.ledBlanche)

        #self.grid_columnconfigure(1,weight=1)
        #self.grid_columnconfigure(0,weight=1) INUTILE
        #self.grid_rowconfigure(0,weight=1) #Gestion verticale de l'agrandissement
        self.resizable(False, False)  #Pas redimentionable !

        #self.geometry(self.geometry())
        self.update()

    def OnButtonLancerClick(self):
        app.event.set()

    def UserPressed(self, none):
        self.log.insert(Tkinter.END, "User button pressed\n")
        app.user_pressed()
        self.log.see(Tkinter.END)

    def UserReleased(self, none):
        self.log.insert(Tkinter.END, "User button released\n")
        app.user_released()
        self.log.see(Tkinter.END)

    def Reset(self, none):
        self.log.insert(Tkinter.END, "Reset button clicked\n")
        self.log.see(Tkinter.END)

    def Clear(self):
        self.log.delete(1.0, Tkinter.END)

    def quitter(self):
        if hasattr(app, 'thread'):
            app.close_conn()
        self.quit()

    def printlog(self, m):
        self.labelVariableLog.set(m)
        self.update()

    def apropos(self):
        self.apropos = Fenetre()
Exemplo n.º 11
0
class mapDrawer:
    def __init__(self, window):
        self.window = window
        self.img_location = "/home/user/catkin_ws/src/navigation/scripts/slam_map.png"
        self.img = PhotoImage(file=self.img_location)
        self.old_img = misc.imread(self.img_location)
        self.WIDTH_OF_IMAGE = self.img.width()
        self.HEIGHT_OF_IMAGE = self.img.height()
        self.number_of_particles = np.zeros(shape=(self.HEIGHT_OF_IMAGE,
                                                   self.WIDTH_OF_IMAGE))
        self.canvas = Canvas(window,
                             width=self.WIDTH_OF_IMAGE * 2,
                             height=self.HEIGHT_OF_IMAGE * 2,
                             bg="#000000")
        self.canvas.pack()
        self.canvas.create_image(
            (self.WIDTH_OF_IMAGE / 2, self.HEIGHT_OF_IMAGE / 2),
            image=self.img,
            state="normal")
        self.old_red_pixels = []
        self.meter_to_pixel = 30.8

    def clamp(self, x):
        return max(0, min(x, 255))

    def convert_to_six_digit_code(self, color):
        r, g, b = color
        return "#{0:02x}{1:02x}{2:02x}".format(self.clamp(r), self.clamp(g),
                                               self.clamp(b))

    def restore_old_image(self):
        for position in self.old_red_pixels:
            width, height = position
            self.img.put(
                self.convert_to_six_digit_code(self.old_img[height][width]),
                (width, height))
        self.old_red_pixels = []

    def draw_circle(self, i, j, diameter):
        min_width = max(0, i - diameter)
        max_width = min(self.WIDTH_OF_IMAGE - 1, i + diameter)
        min_height = max(0, j - diameter)
        max_height = min(self.HEIGHT_OF_IMAGE - 1, j + diameter)
        for curr_width in range(int(min_width), int(max_width + 1)):
            for curr_height in range(int(min_height), int(max_height + 1)):
                if self.img.get(curr_width, curr_height) == "#ff0000":
                    continue
                if np.sqrt((i - curr_width)**2 +
                           (j - curr_height)**2) <= diameter:
                    self.img.put("#ff0000", (curr_width, curr_height))
                    self.old_red_pixels.append((curr_width, curr_height))

    def update(self, num_of_particles_per_pixel):

        total_num_of_particles = 0
        for value in num_of_particles_per_pixel:
            total_num_of_particles += num_of_particles_per_pixel.get(value, 0)
        self.restore_old_image()
        for value in num_of_particles_per_pixel:
            percentage = float(num_of_particles_per_pixel.get(
                value, 0)) / total_num_of_particles
            if (percentage > 0):
                self.draw_circle(value % self.WIDTH_OF_IMAGE,
                                 value / self.WIDTH_OF_IMAGE,
                                 int(int(percentage / 0.15) + 1))
        self.window.update()

    def update_particles(self, particles):
        number_of_particles_per_pixel = {}
        for particle in particles:
            height_in_pixels = int(particle.get_height() * self.meter_to_pixel)
            width_in_pixels = int(particle.get_width() * self.meter_to_pixel)
            index = height_in_pixels * self.WIDTH_OF_IMAGE + width_in_pixels
            number_of_particles_per_pixel[
                index] = number_of_particles_per_pixel.get(
                    index, 0) + particle.get_cnt()
        self.update(number_of_particles_per_pixel)
Exemplo n.º 12
0
class CollapsibleFrame(Frame):
    def __init__(self, master, text=None, borderwidth=2, width=0, height=16, interior_padx=0, interior_pady=8, background=None, caption_separation=4, caption_font=None, caption_builder=None, icon_x=5):
        Frame.__init__(self, master)
        if background is None:
            background = self.cget("background")

        self.configure(background=background)

        self._is_opened = False

        self._interior_padx = interior_padx
        self._interior_pady = interior_pady

        self._iconOpen = PhotoImage(data="R0lGODlhEAAQAKIAAP///9TQyICAgEBAQAAAAAAAAAAAAAAAACwAAAAAEAAQAAADNhi63BMgyinFAy0HC3Xj2EJoIEOM32WeaSeeqFK+say+2azUi+5ttx/QJeQIjshkcsBsOp/MBAA7")
        self._iconClose = PhotoImage(data="R0lGODlhEAAQAKIAAP///9TQyICAgEBAQAAAAAAAAAAAAAAAACwAAAAAEAAQAAADMxi63BMgyinFAy0HC3XjmLeA4ngpRKoSZoeuDLmo38mwtVvKu93rIo5gSCwWB8ikcolMAAA7")
        
        height_of_icon = max(self._iconOpen.height(), self._iconClose.height())
        width_of_icon = max(self._iconOpen.width(), self._iconClose.width())
        
        containerFrame_pady = (height_of_icon//2) +1

        self._height = height
        self._width = width

        self._containerFrame = Frame(self, borderwidth=borderwidth, width=width, height=height, relief=RIDGE, background=background)
        self._containerFrame.pack(expand=True, fill=X, pady=(containerFrame_pady,0))
        
        self.interior = Frame(self._containerFrame, background=background)

        self._collapseButton = Label(self, borderwidth=0, image=self._iconOpen, relief=RAISED)
        self._collapseButton.place(in_= self._containerFrame, x=icon_x, y=-(height_of_icon//2), anchor=N+W, bordermode="ignore")
        self._collapseButton.bind("<Button-1>", lambda event: self.toggle())

        if caption_builder is None:
            self._captionLabel = Label(self, anchor=W, borderwidth=1, text=text)
            if caption_font is not None:
                self._captionLabel.configure(font=caption_font)
        else:
            self._captionLabel = caption_builder(self)
            
            if not isinstance(self._captionLabel, Widget):
                raise Exception("'caption_builder' doesn't return a tkinter widget")

        self.after(0, lambda: self._place_caption(caption_separation, icon_x, width_of_icon))

    def update_width(self, width=None):
        # Update could be devil
        # http://wiki.tcl.tk/1255
        self.after(0, lambda width=width:self._update_width(width))

    def _place_caption(self, caption_separation, icon_x, width_of_icon):
        self.update()
        x = caption_separation + icon_x + width_of_icon
        y = -(self._captionLabel.winfo_reqheight()//2)

        self._captionLabel.place(in_= self._containerFrame, x=x, y=y, anchor=N+W, bordermode="ignore")

    def _update_width(self, width):
        self.update()
        if width is None:
            width=self.interior.winfo_reqwidth()

        if isinstance(self._interior_pady, (list, tuple)):
            width += self._interior_pady[0] + self._interior_pady[1]
        else:
            width += 2*self._interior_pady
            
        width = max(self._width, width)

        self._containerFrame.configure(width=width)
        
    def open(self):
        self._collapseButton.configure(image=self._iconClose)
        
        self._containerFrame.configure(height=self.interior.winfo_reqheight())
        self.interior.pack(expand=True, fill=X, padx=self._interior_padx, pady =self._interior_pady)

        self._is_opened = True

    def close(self):
        self.interior.pack_forget()
        self._containerFrame.configure(height=self._height)
        self._collapseButton.configure(image=self._iconOpen)

        self._is_opened = False
    
    def toggle(self):
        if self._is_opened:
            self.close()
        else:
            self.open()