Esempio n. 1
0
    def __init__(self, master=None):
        """

                This will create the window, labels and buttons required.
                
                """
        self.master = master
        self.master.title("Tag Tester")
        self.master.geometry("480x650")

        self.vbatt = StringVar()
        self.vmcu = StringVar()
        self.vreg = StringVar()
        self.led_low = StringVar()
        self.led_high = StringVar()
        self.vbatt_sense_low = StringVar()
        self.vbatt_sense_high = StringVar()
        self.bleeding_low = StringVar()
        self.bleeding_high = StringVar()
        self.currentAction = StringVar()
        self.reset_time = StringVar()
        self.vbatt2 = StringVar()
        self.cnew = StringVar()
        self.cprogmin = StringVar()
        self.cprogmax = StringVar()
        self.ccharge = StringVar()
        self.vcoil = StringVar()

        self.vbatt.set("0 V")
        self.vmcu.set("0 V")
        self.vreg.set("0 V")
        self.led_low.set("0 V")
        self.led_high.set("0 V")
        self.vbatt_sense_low.set("0 V")
        self.vbatt_sense_high.set("0 V")
        self.bleeding_low.set("0 V")
        self.bleeding_high.set("0 V")
        self.reset_time.set("0 mS")
        self.vcoil.set("0 V")
        self.vbatt2.set("0 V")
        self.cnew.set("0 mA")
        self.cprogmin.set("0 mA")
        self.cprogmax.set("0 mA")
        self.ccharge.set("0 mA")

        self.currentAction.set("Press Start Test to begin")

        #Serial number entry
        x = 0
        y = 0
        self.el1 = Label(self.master, text="Serial Number")
        self.el1.grid(row=y, column=x, pady=5)

        x = 1
        self.e1 = Entry(self.master)
        self.e1.grid(row=y, column=x)

        ##########################################################################################
        #read current button
        x = 1
        y = 1
        self.b1 = Button(self.master,
                         text="Read initial current",
                         command=self.readcurrent)
        #self.b1=Button(self.master,  text="Read initial current", command=self.read_samplecurrent)
        self.b1.grid(row=y, column=x, pady=10)

        #current reading display
        x = 0
        y = 2
        self.l13x = Label(self.master, text="Current new")
        self.l13x.grid(row=y, column=x)

        x = 1
        self.ll13x = Label(self.master, text=" ")
        self.ll13x.grid(row=y, column=x)

        x = 2
        self.lll13x = Label(self.master, textvariable=self.cnew)
        self.lll13x.grid(row=y, column=x)

        #start test button
        x = 1
        y = 3
        self.b1 = Button(self.master,
                         text="Start Test",
                         command=self.startTest)
        self.b1.grid(row=y, column=x, pady=5)

        x = 0
        y = 4
        self.d1 = Label(self.master, textvariable=self.currentAction)
        self.d1.grid(row=y, column=x, columnspan=4, pady=5)

        tabley = 5

        #First column
        self.l0 = Label(self.master, text="SIGNAL")
        self.l1 = Label(self.master, text="Vbatt ")
        self.l2 = Label(self.master, text="Vmcu")
        self.l3 = Label(self.master, text="Vreg")
        self.l4 = Label(self.master, text="PF6 led low")
        self.l5 = Label(self.master, text="PF6 led high")
        self.l6 = Label(self.master, text="PC10 vbatt sense low")
        self.l7 = Label(self.master, text="PC10 vbatt sense high")
        self.l8 = Label(self.master, text="PA4 bleeding low")
        self.l9 = Label(self.master, text="PA4 bleeding high")
        self.l10 = Label(self.master, text="Reset timing")
        self.l11 = Label(self.master, text="Vcoil")
        self.l12 = Label(self.master, text="Charging Voltage")
        self.l13 = Label(self.master, text="Current prog min")
        self.l14 = Label(self.master, text="Current prog max")
        self.l15 = Label(self.master, text="Current charging")

        x = 0
        y = tabley
        self.l0.grid(row=y, column=x)
        y += 1
        self.l1.grid(row=y, column=x)
        y += 1
        self.l2.grid(row=y, column=x)
        y += 1
        self.l3.grid(row=y, column=x)
        y += 1
        self.l4.grid(row=y, column=x)
        y += 1
        self.l5.grid(row=y, column=x)
        y += 1
        self.l6.grid(row=y, column=x)
        y += 1
        self.l7.grid(row=y, column=x)
        y += 1
        self.l8.grid(row=y, column=x)
        y += 1
        self.l9.grid(row=y, column=x)
        y += 1
        self.l10.grid(row=y, column=x)
        y += 1
        self.l11.grid(row=y, column=x)
        y += 1
        self.l12.grid(row=y, column=x)
        y += 1
        self.l13.grid(row=y, column=x)
        y += 1
        self.l14.grid(row=y, column=x)
        y += 1
        self.l15.grid(row=y, column=x)

        #Second column
        self.ll0 = Label(self.master, text="Pass Criteria")
        self.ll1 = Label(self.master, text="3.0-4.2 V")
        self.ll2 = Label(self.master, text="3.2-3.4 V")
        self.ll3 = Label(self.master, text="1.7-1.9 V")
        self.ll4 = Label(self.master, text="<500 mV")
        self.ll5 = Label(self.master, text=">2.7 V")
        self.ll6 = Label(self.master, text="<500 mV")
        self.ll7 = Label(self.master, text=">2.7 V")
        self.ll8 = Label(self.master, text="<500 mV")
        self.ll9 = Label(self.master, text=">2.7 V")
        self.ll10 = Label(self.master, text=">5 mS")
        self.ll11 = Label(self.master, text="4.9-5.1 V")
        self.ll12 = Label(self.master, text="4.0-4.2 V")

        self.ll13 = Label(self.master, text=" ")
        self.ll14 = Label(self.master, text=" ")
        self.ll15 = Label(self.master, text=" ")

        x = 1
        y = tabley
        self.ll0.grid(row=y, column=x)
        y += 1
        self.ll1.grid(row=y, column=x)
        y += 1
        self.ll2.grid(row=y, column=x)  #Vcoil
        y += 1
        self.ll3.grid(row=y, column=x)
        y += 1
        self.ll4.grid(row=y, column=x)
        y += 1
        self.ll5.grid(row=y, column=x)
        y += 1
        self.ll6.grid(row=y, column=x)
        y += 1
        self.ll7.grid(row=y, column=x)
        y += 1
        self.ll8.grid(row=y, column=x)
        y += 1
        self.ll9.grid(row=y, column=x)
        y += 1
        self.ll10.grid(row=y, column=x)
        y += 1
        self.ll11.grid(row=y, column=x)
        y += 1
        self.ll12.grid(row=y, column=x)

        y += 1
        self.ll13.grid(row=y, column=x)
        y += 1
        self.ll14.grid(row=y, column=x)
        y += 1
        self.ll15.grid(row=y, column=x)

        #Third column
        self.lll0 = Label(self.master, text="Actual Value")
        self.lll1 = Label(self.master, textvariable=self.vbatt)
        self.lll2 = Label(self.master, textvariable=self.vmcu)
        self.lll3 = Label(self.master, textvariable=self.vreg)
        self.lll4 = Label(self.master, textvariable=self.led_low)
        self.lll5 = Label(self.master, textvariable=self.led_high)
        self.lll6 = Label(self.master, textvariable=self.vbatt_sense_low)
        self.lll7 = Label(self.master, textvariable=self.vbatt_sense_high)
        self.lll8 = Label(self.master, textvariable=self.bleeding_low)
        self.lll9 = Label(self.master, textvariable=self.bleeding_high)
        self.lll10 = Label(self.master, textvariable=self.reset_time)
        self.lll11 = Label(self.master, textvariable=self.vcoil)
        self.lll12 = Label(self.master, textvariable=self.vbatt2)

        self.lll13 = Label(self.master, textvariable=self.cprogmin)
        self.lll14 = Label(self.master, textvariable=self.cprogmax)
        self.lll15 = Label(self.master, textvariable=self.ccharge)

        x = 2
        y = tabley
        self.lll0.grid(row=y, column=x)
        y += 1
        self.lll1.grid(row=y, column=x)
        y += 1
        self.lll2.grid(row=y, column=x)
        y += 1
        self.lll3.grid(row=y, column=x)
        y += 1
        self.lll4.grid(row=y, column=x)
        y += 1
        self.lll5.grid(row=y, column=x)
        y += 1
        self.lll6.grid(row=y, column=x)
        y += 1
        self.lll7.grid(row=y, column=x)
        y += 1
        self.lll8.grid(row=y, column=x)
        y += 1
        self.lll9.grid(row=y, column=x)
        y += 1
        self.lll10.grid(row=y, column=x)
        y += 1
        self.lll11.grid(row=y, column=x)
        y += 1
        self.lll12.grid(row=y, column=x)

        y += 1
        self.lll13.grid(row=y, column=x)
        y += 1
        self.lll14.grid(row=y, column=x)
        y += 1
        self.lll15.grid(row=y, column=x)

        #Fourth column
        self.llll0 = Label(self.master, text="Pass / Fail")
        self.llll1 = Label(self.master, text="       ", bg="white")
        self.llll2 = Label(self.master, text="       ", bg="white")
        self.llll3 = Label(self.master, text="       ", bg="white")
        self.llll4 = Label(self.master, text="       ", bg="white")
        self.llll5 = Label(self.master, text="       ", bg="white")
        self.llll6 = Label(self.master, text="       ", bg="white")
        self.llll7 = Label(self.master, text="       ", bg="white")
        self.llll8 = Label(self.master, text="       ", bg="white")
        self.llll9 = Label(self.master, text="       ", bg="white")
        self.llll10 = Label(self.master, text="       ", bg="white")
        self.llll11 = Label(self.master, text="       ", bg="white")
        self.llll12 = Label(self.master, text="       ", bg="white")

        x = 3
        y = tabley
        self.llll0.grid(row=y, column=x)
        y += 1
        self.llll1.grid(row=y, column=x)
        y += 1
        self.llll2.grid(row=y, column=x)
        y += 1
        self.llll3.grid(row=y, column=x)
        y += 1
        self.llll4.grid(row=y, column=x)
        y += 1
        self.llll5.grid(row=y, column=x)
        y += 1
        self.llll6.grid(row=y, column=x)
        y += 1
        self.llll7.grid(row=y, column=x)
        y += 1
        self.llll8.grid(row=y, column=x)
        y += 1
        self.llll9.grid(row=y, column=x)
        y += 1
        self.llll10.grid(row=y, column=x)
        y += 1
        self.llll11.grid(row=y, column=x)
        y += 1
        self.llll12.grid(row=y, column=x)

        y += 6
        self.exit = Button(
            self.master, text="Exit",
            command=self.master.destroy)  #.pack(side="top",pady=40)
        self.exit.grid(row=y, column=1, pady=5)

        self.ADC = ADS1256.ADS1256()
        self.ADC.ADS1256_init()

        self.relaywirelesscharge = 24
        self.relaybatt = 23
        self.reset = 27
Esempio n. 2
0
def OnSelected(event):
    global mem_id, UpdateWindow
    curItem = tree.focus()
    contents = (tree.item(curItem))
    selecteditem = contents['values']
    mem_id = selecteditem[0]
    FIRSTNAME.set("")
    LASTNAME.set("")
    GENDER.set("")
    AGE.set("")
    ADDRESS.set("")
    CONTACT.set("")
    FIRSTNAME.set(selecteditem[1])
    LASTNAME.set(selecteditem[2])
    AGE.set(selecteditem[4])
    ADDRESS.set(selecteditem[5])
    CONTACT.set(selecteditem[6])
    UpdateWindow = Toplevel()
    UpdateWindow.title("Update Contact")
    width = 400
    height = 300
    screen_width = root.winfo_screenwidth()
    screen_height = root.winfo_screenheight()
    x = ((screen_width / 2) + 450) - (width / 2)
    y = ((screen_height / 2) + 20) - (height / 2)
    UpdateWindow.resizable(0, 0)
    UpdateWindow.geometry("%dx%d+%d+%d" % (width, height, x, y))
    if 'NewWindow' in globals():
        NewWindow.destroy()

    #----------FRAMES----------#
    FormTitle = Frame(UpdateWindow)
    FormTitle.pack(side=TOP)
    ContactForm = Frame(UpdateWindow)
    ContactForm.pack(side=TOP, pady=10)
    RadioGroup = Frame(ContactForm)
    Male = Radiobutton(RadioGroup,
                       text="Male",
                       variable=GENDER,
                       value="Male",
                       font=('arial', 14)).pack(side=LEFT)
    Female = Radiobutton(RadioGroup,
                         text="Female",
                         variable=GENDER,
                         value="Female",
                         font=('arial', 14)).pack(side=LEFT)

    #----------LABELS----------#
    lbl_title = Label(FormTitle,
                      text="Updating Contacts",
                      font=('arial', 16),
                      bg="orange",
                      width=300)
    lbl_title.pack(fill=X)
    lbl_firstname = Label(ContactForm,
                          text="Firstname",
                          font=('arial', 14),
                          bd=5)
    lbl_firstname.grid(row=0, sticky=W)
    lbl_lastname = Label(ContactForm,
                         text="Lastname",
                         font=('arial', 14),
                         bd=5)
    lbl_lastname.grid(row=1, sticky=W)
    lbl_gender = Label(ContactForm, text="Gender", font=('arial', 14), bd=5)
    lbl_gender.grid(row=2, sticky=W)
    lbl_age = Label(ContactForm, text="Age", font=('arial', 14), bd=5)
    lbl_age.grid(row=3, sticky=W)
    lbl_address = Label(ContactForm, text="Address", font=('arial', 14), bd=5)
    lbl_address.grid(row=4, sticky=W)
    lbl_contact = Label(ContactForm, text="Contact", font=('arial', 14), bd=5)
    lbl_contact.grid(row=5, sticky=W)

    #----------ENTRY----------#
    firstname = Entry(ContactForm, textvariable=FIRSTNAME, font=('arial', 14))
    firstname.grid(row=0, column=1)
    lastname = Entry(ContactForm, textvariable=LASTNAME, font=('arial', 14))
    lastname.grid(row=1, column=1)
    RadioGroup.grid(row=2, column=1)
    age = Entry(ContactForm, textvariable=AGE, font=('arial', 14))
    age.grid(row=3, column=1)
    address = Entry(ContactForm, textvariable=ADDRESS, font=('arial', 14))
    address.grid(row=4, column=1)
    contact = Entry(ContactForm, textvariable=CONTACT, font=('arial', 14))
    contact.grid(row=5, column=1)

    #----------BUTTONS----------#
    btn_updatecon = Button(ContactForm,
                           text='Update',
                           width=50,
                           command=UpdateData)
    btn_updatecon.grid(row=6, columnspan=2, pady=10)
    def _create_widgets(self):
        """GUI building"""
        # File widgets
        self._filename_label = Label(self._master, width="22", anchor="e", text="Access File (*.mdb, *.accdb):")
        self._filename_label.grid(row=0, column=0)

        self._filename_path_label = Label(self._master, width="50", anchor="w", textvariable=self._file_path, bg="#cccccc")
        self._filename_path_label.grid(row=0, column=1)

        self._browse_file_button = Button(self._master, text="...", width="3", command=self._browse_file)
        self._browse_file_button.grid(row=0, column=2)

        # Password widget
        self._password_label = Label(self._master, width="22", anchor="e", text="Password (else leave empty):")
        self._password_label.grid(row=1, column=0)

        self._password_entry = Entry(self._master, width="58", show="*")
        self._password_entry.grid(row=1, column=1)

        self._password_show_image = PhotoImage(file=path.join(module_dir, "images\\watch_pwd.png")).subsample(8, 8)
        self._password_show_button = Button(self._master, width="3", command=self._show_hide_password, image=self._password_show_image)
        self._password_show_button.grid(row=1, column=2)

        # Checkbox widget
        self._same_dir_as_file_checkbox = Checkbutton(self._master, width="50", text="Same directory as source file", var=self._same_dir, command=self._same_dir_as_file)
        self._same_dir_as_file_checkbox.grid(row=2, column=1, pady=8)

        # Output widgets
        self._output_label = Label(self._master, width="22", anchor="e", text="Output directory:")
        self._output_label.grid(row=3, column=0)

        self._output_dir_label = Label(self._master, width="50", anchor="w", textvariable=self._file_path,
                                       bg="#cccccc")
        self._output_dir_label.grid(row=3, column=1)

        self._browse_dir_button = Button(self._master, text="...", width="3", command=self._browse_dir)
        self._browse_dir_button.grid(row=3, column=2)

        # Radio buttons for PostgreSQL or MySQL/MariaDB
        self._db_type_label = Label(self._master, width="22", anchor="e", text="Database type:")
        self._db_type_label.grid(row=4, column=0)

        self._db_type_frame = Frame(self._master)
        self._db_type_frame.grid(row=4, column=1, columnspan=2, pady=5)

        self._radio_button_postgres = Radiobutton(self._db_type_frame, text="PostgreSQL", var=self._db_type, value=self.DB_TYPE_POSTGRESQL(), width="13")
        self._radio_button_postgres.grid(row=0, column=0)

        self._radio_button_mariadb = Radiobutton(self._db_type_frame, text="MariaDB", var=self._db_type, value=self.DB_TYPE_MARIADB(), width="13")
        self._radio_button_mariadb.grid(row=0, column=1)

        self._radio_button_mysql = Radiobutton(self._db_type_frame, text="MySQL", var=self._db_type, value=self.DB_TYPE_MYSQL(), width="13")
        self._radio_button_mysql.grid(row=0, column=2)

        # Convert widget & progressbar
        self._convert_frame = Frame(self._master)
        self._convert_frame.grid(row=5, column=0, columnspan=2, pady=5)

        self._convert_button = Button(self._convert_frame, width="84", text="CREATE SQL FILE", command=self.convertSQL, state="disabled")
        self._convert_button.grid(row=0, column=0)

        self._convert_progressbar = Progressbar(self._convert_frame, length="512")
        self._convert_progressbar.grid(row=1, column=0)
"""Remove parts of window frame

stevepython.wordpress.com
code-snippet-vol_42-snip_208

Source: Various
"""

from tkinter import Label, Tk

root = Tk()

# This removes the maximize button.
#root.resizable(0,0)

# This makes a window frame with no title or icon.
root.overrideredirect(1) # Close Python shell to quit this one.

# No maximize or minimize icons.
# This one does not work on Linux Mint 19.1
#root.attributes("-toolwindow", 1)

txt_label = Label(root, bg='powderblue',
                  text='This is some test text.')
txt_label.grid()

root.mainloop()
Esempio n. 5
0
def showTable(table):
    # use black background so it "peeks through" to
    # form grid lines
    window = Toplevel()
    window._widgets = []

    # setting headers
    row = 0
    current_row = []
    ins_tuple = ["IDENTIFIER", "TYPE", "SIZE", "VALUE", "SCOPE", "REFERENCE"]
    for column in range(6):
        label = Label(window,
                      text="%s" % ins_tuple[column],
                      borderwidth=0,
                      width=10,
                      bg="black",
                      fg="white")
        label.grid(row=row, column=column, sticky="nsew", padx=1, pady=1)
        current_row.append(label)
    window._widgets.append(current_row)
    row += 1

    # setting content
    for key in table.printTable():
        #current_row = []
        ins = table.get(key)
        typ = ["INT", "FLOAT", "STRING", "STRUCT"]
        is_label = ins.getType()
        is_pointer = ins.getValue()
        is_struct = ins.getSize()
        ref = ins.getRef()
        if type(is_label) == str:
            typ = "FUNCTION"
            ref = "LABEL"
        elif type(is_pointer) == leaf:
            typ = "POINTER"
            is_pointer = is_pointer.getValue()
        else:
            typ = typ[is_label - 1]
            if typ == "STRUCT":
                is_struct = len(is_pointer)
        ins_tuple = [
            ins.getID(), typ, is_struct, is_pointer,
            ins.getScope(), ref
        ]
        for column in range(6):
            label = Label(window,
                          text="%s" % ins_tuple[column],
                          borderwidth=0,
                          width=10,
                          bg="black",
                          fg="lightgrey")
            label.grid(row=row, column=column, sticky="nsew", padx=1, pady=1)
            current_row.append(label)
        window._widgets.append(current_row)
        row += 1

    for column in range(6):
        window.grid_columnconfigure(column, weight=1)

    window.resizable(width=True, height=False)
Esempio n. 6
0
def searchsong():
    w4 = Toplevel(bg='black')
    w4.title('Search Results')
    w4.geometry('450x380')
    w4.resizable(False, False)
    searchlabel = Label(w4,
                        text='Search Results',
                        font=('moon', 40, 'bold'),
                        bg='black',
                        foreground=red)
    searchlabel.pack()

    def playsearchsong(playindex, newlist):
        global index
        global pause
        pause = False
        play_button.config(text=' ▌▌')

        print(index)
        for i in final_list:
            if newlist[playindex] in i:
                index = final_list.index(i)
        mixer.music.stop()
        mixer.music.load(final_list[index])
        mixer.music.play()
        playing_label.config(text='Playing : ' + final_list[index][:-4])

    def search(word, song):
        word = word.upper()
        ind = []
        for i in song:
            j = i[:-4].upper()
            if word in j:
                ind.append(song.index(i))
                print(i)

        return (ind)

    searchlist = search(search_entry.get(), final_list)
    xsum = 10
    ysum = 120
    newlist = []
    print(searchlist)
    for i in searchlist:
        newlist.append(final_list[i])
    if len(newlist) == 0:
        no = Label(w4,
                   text=' No\nResults\nFound',
                   font=('moon', 30),
                   bg='black',
                   foreground=m)
        no.pack()
        no.place(y=120, x=150)

    else:

        bnew = []
        for i in range(len(newlist)):
            bnew.append(
                Button(w4,
                       text=newlist[i][:-4],
                       bg='black',
                       foreground='purple',
                       activebackground='black',
                       font=('moon', 13),
                       activeforeground=m,
                       command=lambda x=i: playsearchsong(x, newlist)))
        for i in bnew:
            i.pack()
            if ysum >= 330:
                ysum = 120
                xsum = 220

            i.place(x=xsum, y=ysum)

            ysum += 50
        print(ysum)
def add_display_label(display_window, label):
    display_label = Label(display_window, text=str(label))
    display_label.config(font=('times', 130, 'bold'))
    display_label.pack(expand=True)
    return display_label
Esempio n. 8
0
def show(event):
    img = ImageTk.PhotoImage(Image.open("A:/mario.jpg"))
    imglabel = Label(root, image=img)
    imglabel.pack()
    root.pack()
Esempio n. 9
0
def get_user_parameters_with_gui(params_input: dict):
    """
    Creates tkinter GUI window with parameters and populated default values. \n
    After user entered new parameters and hit 'Submit' button, it collects all values and returns params_output dict.\n
    :param params_input: dict with structure {param_name: [param_type, param_value]},
    where param_name - str, param_type - "ENTRY" or "FILE", param_value - list or str
    :return: params_output dict with structure {param_name: param_value}, where param_name - str, param_value - list
    """

    def click_folder_path(param_name: str):
        """
        Opens directory window and sets selected path to button_output dict.
        :param param_name: str
        :return:
        """
        default_dir = params_input[param_name][1]
        new_dir_name = filedialog.askdirectory(initialdir=default_dir if os.path.isdir(default_dir) else os.getcwd())

        # change button output if already provided (user re-selects path) or set a new value
        button_output[param_name] = new_dir_name if param_name in button_output.keys() \
            else button_output.setdefault(param_name, new_dir_name)

    def get_gui_info():
        """
        Fetches all parameters outputs from user (for labels & buttons)
        :return:
        """

        for param_name, (param_input_type, param_default_value, elem_object) in params_input.items():
            if param_input_type == 'ENTRY':
                # converting user comma separated input to list
                params_output.setdefault(param_name, [el.strip() for el in elem_object.get().split(",")])
            elif param_input_type == 'FILE':

                # use new value if directory button was changed, else - use default
                if param_name in button_output.keys():
                    params_output.setdefault(param_name, button_output[param_name])
                else:
                    params_output.setdefault(param_name, param_default_value)

        window.destroy()

    # create tkinter window
    window = Tk()
    window.title("Input parameters")
    window.minsize(450, 100)

    params_output = {}
    button_output = {}

    # build 2-column grid with label-input layout
    grid_row = itertools.count()

    for param_name, (param_input_type, param_default_value) in params_input.items():
        row = next(grid_row)

        # insert labels in the 1st column
        label = Label(window, text=param_name)
        label.grid(row=row, sticky='E', padx=5)

        # insert inputs in the 2nd column
        if isinstance(param_default_value, list):  # convert list to comma separated string values for displaying
            param_default_value = ", ".join(param_default_value)
        value = StringVar()
        value.set(param_default_value)

        if param_input_type == 'ENTRY':
            elem = Entry(window, width=50, textvariable=value)
        elif param_input_type == 'FILE':
            elem = Button(window, text="Select PATH", command=lambda param_name=param_name: click_folder_path(param_name), width=42, anchor="w")
        else:
            print(f"Unexpected input type '{param_input_type}' for parameter '{param_name}'. "
                  f"Accepted only {'ENTRY'}, {'FILE'}.")
            sys.exit()

        elem.grid(row=row, column=1, sticky='W', padx=10)
        params_input[param_name].append(elem)

    # collect user output for params
    submit_button = Button(window, text="SUBMIT", width=10, command=lambda: get_gui_info())
    submit_button.grid(row=len(params_input), column=1, sticky='E', pady=20, padx=10)

    window.mainloop()

    # if values submission was cancelled (Exit button) - stop the program
    if not bool(params_output):
        print("Parameter values are empty. Exiting the program.")
        sys.exit()
    else:
        return params_output
Esempio n. 10
0
def brighten(event):
    o = ImageEnhance.Brightness(im)
    im2 = ImageTk.PhotoImage(o.enhance(5))
    imglabel = Label(root, image=im2)
    imglabel.pack()
    root.pack()
Esempio n. 11
0
def contrast(event):
    o = ImageEnhance.Contrast(im)
    img = ImageTk.PhotoImage(o.enhance(3))
    imglabel = Label(root, image=img)
    imglabel.pack()
    root.pack()
Esempio n. 12
0
 def createWidgets(self):
     self.helloLabel = Label(self, text='Hello, world!')
     self.helloLabel["background"] ="green"
     self.helloLabel.pack()
     self.quitButton = Button(self, text='Quit',fg="red", command=self.quit)
     self.quitButton.pack()
Esempio n. 13
0

# Erstellen eines Tkinter Parent
root = Tk()
root.title("Kreuzprodukt")

# Definieren der Klammern
klauf = Image.open("/home/daniel/Downloads/klauf.png")
klauf = ImageTk.PhotoImage(klauf)

klzu = Image.open("/home/daniel/Downloads/klzu.png")
klzu = ImageTk.PhotoImage(klzu)

# Platzieren der Klammern
for i in range(0, 9, 4):
    Label(root, image=klauf).grid(column=i, row=0, rowspan=3)
    Label(root, image=klzu).grid(column=i + 2, row=0, rowspan=3)

Label(root, text="x").grid(column=3, row=1)
Label(root, text="=").grid(column=7, row=1)

# Erstellung und Sortieren der Eingabefelder e0-2
for i in range(0, 3):
    exec("e" + str(i) + " = Entry(root, width=3)")
    exec("e" + str(i) + ".grid(row=" + str(i) + ", column=1)")

# Erstellung und Sortieren der Eingabefelder e3-5
for i in range(3, 6):
    exec("e" + str(i) + " = Entry(root, width=3)")
    exec("e" + str(i) + ".grid(row=" + str(i - 3) + ", column=5)")
Esempio n. 14
0
from tkinter import Tk, Button, Label, Entry

root = Tk()
root.geometry('600x400+500+200')

l_login = Label(root, text='Login')
l_login.grid(row=0, column=0)

e_login = Entry(root)
e_login.grid(row=0, column=1)

l_password = Label(root, text='Password')
l_password.grid(row=1, column=0)

e_password = Entry(root)
e_password.grid(row=1, column=1)

b_login = Button(root, text='Enter')
b_login.grid(row=2, column=0)

b_register = Button(root, text='Register')
b_register.grid(row=2, column=1)

b_forgot = Button(root, text='Forgot password?')
b_forgot.grid(row=2, column=2)

root.mainloop()
Esempio n. 15
0
            if (g>200):
                g = 255
            if (b>200):
                b = 255
            if (getChar(h) == '1'):
                if (random.random()>0.5):
                    text_file.write('0')
                    d.text((j*oneCharWidth, i*oneCharHeight), '0', font = fnt, fill = (r, g, b))
                else:
                    text_file.write(getChar(h))        
                    d.text((j*oneCharWidth, i*oneCharHeight), getChar(h), font = fnt, fill = (r, g, b))
            else:
                text_file.write(getChar(h))        
                d.text((j*oneCharWidth, i*oneCharHeight), getChar(h), font = fnt, fill = (r, g, b))

        text_file.write('\n')

    text_file.close()
    outputImage.save('output.png')
    lbl.configure(text="Готово!")

lbl = Label(window, text="Нажмите на кнопку ниже, чтобы начать")
lbl.grid(column=0, row=0)

btn = Button(window, text="Выбрать изображение", command=clicked)
btn.grid(column=0, row=2)

window.mainloop()


Esempio n. 16
0
import pickle

window = Tk()
window.title("FRAS")
# window.geometry('550x400')
window.attributes("-fullscreen", True)

########################################################################################################
################################ widgets ###############################################################
########################################################################################################
#title
label_title = Label(window,
                    text="FACE RECOGNITION BASED ATTENDANCE SYSTEM",
                    width=60,
                    height=2,
                    bg='green',
                    fg='white',
                    font=('times', 30, ' bold '))
label_title.place(x=0, y=0)

#Enter  password
label_pass = Label(window,
                   text="Enter password   : ",
                   width=13,
                   height=2,
                   font=('times', 15, ' bold '))
label_pass.place(relx=0.6, rely=0.3, x=-20)

entry_pass = Entry(
    window,
Esempio n. 17
0
            i.place(x=xsum, y=ysum)

            ysum += 50
        print(ysum)


def callback1(event):

    if 'search... .. .' in search_entry.get():
        print('yes')
        search_entry.delete(0, END)


heading = Label(top,
                bg='black',
                foreground=red,
                text='Music Player',
                font=('moon', 40, 'bold'))
heading.pack()
heading.place(x=100, y=20)

search_entry = Entry(top,
                     bg='black',
                     foreground=m,
                     insertbackground='white',
                     highlightcolor='purple',
                     highlightthickness=1)
search_entry.insert(0, 'search... .. .')
search_entry.pack()
search_entry.place(x=440, y=2)
search_entry.bind('<Button-1>', callback1)
    def __init__(self, master=None):

        Frame.__init__(self, master)

        # Creating left canvas
        self.canvasLeft = Canvas(width=500, height=500, bg="white")
        # Aligning left canvas
        self.canvasLeft.grid(column=1, row=3)

        # Creating right canvas
        self.canvasRight = Canvas(width=500, height=500, bg="white")
        # Aligning right canvas
        self.canvasRight.grid(column=2, row=3)

        self.grid()  # use the grid manager

        self.master.title("Binary Image Creator")

        # Creating menu bar for opening and saving files
        menubar = Menu(self)
        fileMenu = Menu(self)

        # Initiating cascade feature on menubar
        menubar.add_cascade(label="File", menu=fileMenu)
        # Adding filemenu button to open file with linked with command
        fileMenu.add_cascade(label="Open", command=self.openFile)
        # Adding filemenu button to save file with linked with command
        fileMenu.add_cascade(label="Save", command=self.saveFile)
        # Adding filemenu button to close application
        fileMenu.add_cascade(label="Close", command=self.closeApplication)

        # Initiating label to hold the file path of selected image file
        self.filePath = Label(self.master, text=None)
        # Aligning label to be above left canvas
        self.filePath.grid(column=1, row=2)

        # Initiating label to display text relating to threshold
        self.thresholdLabel = Label(self.master,
                                    text="Select Threshold (0-255)")
        # Aligning label to be above left canvas
        self.thresholdLabel.grid(column=2, row=2, sticky="w", padx=70)

        # Creating text entry box in same column as threshold label
        self.thresholdEntry = Entry(self.master, width=4)
        # Automatically selecting threshold and placing in text entry box
        self.thresholdEntry.insert(0, "0")
        # Aligning text entry box next to label
        self.thresholdEntry.grid(column=2, row=2, sticky="e", padx=180)

        # Creating threshold calculate button next to text entry box
        self.thresholdCalculate = Button(self.master,
                                         command=self.processThreshold,
                                         width=6,
                                         text="Process")
        # Aligning button and specifying position next to entry box
        self.thresholdCalculate.grid(column=2, row=2, sticky="e", padx=125)

        self._imagedata = None  # Store here the loaded Image Data, i.e. an object of class GreyScaleImage or ColourImage.
        # This will not change until a new data file is loaded.
        self._processedData = None  # Store here a BinaryImage object that is the result of binarising the loaded data.
        self._pixelSize = 2  # This is used to size the pixels in our display. See method _display()
        self._previousFile = [None]
        self.master.configure(menu=menubar)
Esempio n. 19
0
def juke_box():
    w2 = Toplevel(bg='black')
    w2.title('Jukebox')
    w2.geometry('600x400')
    w2.resizable(False, False)
    jukelabel = Label(w2,
                      text='Jukebox',
                      font=('moon', 40),
                      bg='black',
                      foreground=red)
    jukelabel.pack()
    timelabel = Label(w2,
                      text='Time',
                      font=('moon', 20),
                      bg='black',
                      foreground=m)
    timelabel.pack()
    timelabel.place(x=40, y=70)
    timeentry = Entry(w2,
                      bg='black',
                      foreground=m,
                      insertbackground='white',
                      highlightcolor='purple',
                      highlightthickness=1)
    timeentry.insert(0, 'Enter Time')
    timeentry.pack()
    timeentry.place(x=115, y=76)

    def callback2(event):
        if 'Enter Time' in timeentry.get():
            print('yes')
            timeentry.delete(0, END)

    timeentry.bind('<Button-1>', callback2)
    number = []
    newlist = []

    def knap():
        t = int(timeentry.get())
        t = t * 100
        val = [1] * 9
        wt = copy.deepcopy(time_list)
        n = len(val)
        x = printknapSack(t, wt, val, n)

        for i in x:
            number.append(wt.index(i))
        for i in number:
            newlist.append(final_list[i])
        xsum = 10
        ysum = 120

        def playjuke(jukeindex):
            global pause
            pause = False
            play_button.config(text=' ▌▌')
            print(jukeindex)
            mixer.music.stop()
            mixer.music.load(newlist[jukeindex])
            mixer.music.play()
            playing_label.config(text='Playing : ' + newlist[jukeindex][:-4])

        newlist.sort(reverse=True)
        bnew = []
        for i in range(len(newlist)):
            bnew.append(
                Button(w2,
                       text=newlist[i][:-4],
                       bg='black',
                       foreground='purple',
                       activebackground='black',
                       font=('moon', 13),
                       activeforeground=m,
                       command=lambda x=i: playjuke(x)))
        for i in bnew:
            i.pack()
            if ysum >= 330:
                ysum = 120
                xsum = 330

            i.place(x=xsum, y=ysum)

            ysum += 50
        print(ysum)

    createbutton = Button(w2,
                          text='Create',
                          bg='black',
                          foreground='purple',
                          activebackground='black',
                          font=('moon', 13),
                          activeforeground=m,
                          command=knap)
    createbutton.pack()
    createbutton.place(y=360, x=200)

    w2.protocol("WM_DELETE_WINDOW", lambda: disable_event(w2))
Esempio n. 20
0
    def raise_window(self, player):
        win = Toplevel(self.root)
        win.geometry("500x200")
        bg = self.COLORS[self.grp]

        def close():
            win.destroy()

        def buy():
            self.square.sell(player)
            close()

        c = Frame(win, width=500, height=200, bg=bg)
        Label(
            c,
            text=
            f"NAME: {self.square.Element}, # {int(self.square.AtomicNumber)}",
            font=Font(18),
            bg=bg).place(x=250, y=20, anchor=CENTER)
        Label(c,
              text=f"DISCOVERER: {self.square.Discoverer}, {self.square.Year}",
              font=Font(18),
              bg=bg).place(x=250, y=52, anchor=CENTER)
        Label(c, text=f"PRICE: {self.square.price} KJ", font=Font(18),
              bg=bg).place(x=250, y=84, anchor=CENTER)

        if self.square.owned_by is None:
            win.title(f"Buy {self.square.Element}?")
            Label(c, text="Do you want to Buy?", font=Font(18),
                  bg=bg).place(x=250, y=115, anchor=CENTER)
            Button(c,
                   text="Yes",
                   bg="green",
                   fg="white",
                   font=Font(12),
                   width=20,
                   height=1,
                   command=buy).place(x=145, y=170, anchor=CENTER)
            Button(c,
                   text="No",
                   bg="red",
                   fg="white",
                   font=Font(12),
                   width=20,
                   height=1,
                   command=close).place(x=345, y=170, anchor=CENTER)

        else:
            message = f"This is your property, {player.name}"
            if self.square.owned_by.name != player.name:
                player.balance -= self.square.rent
                self.square.owned_by.balance += self.square.rent
                win.title(f"Pay energy to {self.square.owned_by.name}")
                message = f"You have paid energy to {self.square.owned_by.name}"

            Label(
                c,
                text=
                f"NAME: {self.square.Element}, # {int(self.square.AtomicNumber)}",
                font=Font(18),
                bg=bg).place(x=250, y=20, anchor=CENTER)
            Label(c,
                  text=
                  f"DISCOVERER: {self.square.Discoverer}, {self.square.Year}",
                  font=Font(18),
                  bg=bg).place(x=250, y=52, anchor=CENTER)
            Label(c,
                  text=f"PRICE: {self.square.price} KJ",
                  font=Font(18),
                  bg=bg).place(x=250, y=84, anchor=CENTER)
            Label(c, text=message, font=Font(18), bg=bg).place(x=250,
                                                               y=115,
                                                               anchor=CENTER)
            Button(c,
                   text="OK",
                   bg="blue",
                   fg="white",
                   font=Font(12),
                   width=20,
                   height=1,
                   command=close).place(x=250, y=170, anchor=CENTER)

        c.place(x=0, y=0)
        win.mainloop()
        return
Esempio n. 21
0
File: main.py Progetto: wojtii/smti

def handle_tab_changed(event):
    selection = event.widget.select()
    tab = event.widget.tab(selection, "text")
    if tab == "Preferences list":
        preferences.update_screen()


# Main Window
window = Tk()
window.title("SMTI")
window.geometry('640x540')

# Menu Controls
tab_control = ttk.Notebook(window)
tab1 = ttk.Frame(tab_control)
tab2 = ttk.Frame(tab_control)
tab_control.add(tab1, text='Women & Men')
tab_control.add(tab2, text='Preferences list')
people = People(tab1)
preferences = Preferences(tab2)

# Status Bar
status = Label(text="", bd=1, relief=SUNKEN, anchor=W)
status.pack(side=BOTTOM, fill=X)
tab_control.bind("<<NotebookTabChanged>>", handle_tab_changed)

# Pack menu and loop window
tab_control.pack(expand=1, fill='both')
window.mainloop()
Esempio n. 22
0
    def create_interface(self):
        """Create the interface."""
        root = Tk()
        frame = Frame(root)
        root.title("Black hole options")
        frame.pack()

        open_file_button = Button(frame, text="Open image", width=14, command=self.open_file_name)
        open_file_button.grid(row=0, column=0)

        L1 = Label(frame, text="radius")
        L1.grid(row=1, column=0)
        var = StringVar(root)
        var.set(self.blackhole.Rs)
        self.radius = Spinbox(frame, from_=1e-100, to=1e100, textvariable=var, bd=2, width=7)
        self.radius.grid(row=1, column=1)

        L2 = Label(frame, text="distance")
        L2.grid(row=2, column=0)
        var = StringVar(root)
        var.set(self.blackhole.D)
        self.distance = Spinbox(frame, from_=1e-100, to=1e100, textvariable=var, bd=2, width=7)
        self.distance.grid(row=2, column=1)

        compute_button = Button(frame, text="Compute", width=14, command=self.compute)
        compute_button.grid(row=1, column=2)

        self.message = Label(frame, text="", width=20)
        self.message.grid(row=1, column=3)
        self.message5 = Label(frame, text="", width=20)
        self.message5.grid(row=2, column=3)

        L3 = Label(frame, text="Image size")
        L3.grid(row=3, column=0)
        var = StringVar(root)
        var.set(self.blackhole.axe_X)
        self.size = Spinbox(frame, from_=1, to=1e100, textvariable=var, bd=2, width=7)
        self.size.grid(row=3, column=1)

        self.message2 = Label(frame, text="", width=20)
        self.message2.grid(row=3, column=3)

        save_button = Button(frame, text="Save image", width=14, command=self.img_save)
        save_button.grid(row=4, column=2)

        self.message4 = Label(frame, text="")
        self.message4.grid(row=4, column=3)

        message6 = Label(frame, text="Fix background")
        message6.grid(row=5, column=0)

        fixed_background = BooleanVar()
        C1 = Checkbutton(frame, text="", variable=fixed_background,
                         onvalue=True, offvalue=False)
        C1.grid(row=5, column=1)

        L4 = Label(frame, text="images")
        L4.grid(row=6, column=0)

        var = StringVar(root)
        var.set(10)
        self.number = Spinbox(frame, from_=1, to=1e100, textvariable=var, bd=2, width=7)
        self.number.grid(row=6, column=1)

        save_gif_button = Button(frame, text="Save animation", width=14, command=self.save_gif)
        save_gif_button.grid(row=6, column=2)

        self.message3 = Label(frame, text="")
        self.message3.grid(row=6, column=3)

        root.mainloop()
Esempio n. 23
0
    def __init__(self):

        root = Tk()
        root.title("SNAKE AND LADDERS")
        head = Frame(root)
        head.pack(side='top')
        body = Frame(root)
        body.pack()
        # -------------------------------------------------------
        left = Frame(body)  # THIS IS FOR LEFT SIDE OF THE BODY FRAME
        self.right = Frame(body)  # THIS IS FOR RIGHT SIDE OF THE BODY FRAME
        left.pack(side='left')
        self.right.pack(side='right')
        # ------------------HEADING OF SNAKE AND LADDER ---------------
        #        self.lb1 = Label(self.right, text="player 1's name")
        #        self.lb2 = Label(self.right, text="player 2's name")
        #        self.box1 = Entry(self.right)
        #        self.box2 = Entry(self.right)
        img100 = Image.open("dice/dice6.png")
        # =======================Buttons====================================================
        self.canvas = Canvas(self.right,
                             height=img100.size[0],
                             width=img100.size[0])
        self.canvas.grid(row=1, column=1)
        self.player1 = Button(self.right,
                              text='Player 1',
                              bg='#03A235',
                              command=self.player1_dice_throw)
        self.player2 = Button(self.right,
                              text='Player 2',
                              bg='#AF7135',
                              state='disable',
                              command=self.player2_dice_throw)
        #        self.lb1.grid(row=0, column=0, pady=50)
        #        self.lb2.grid(row=0, column=2, pady=50)
        #        self.box1.grid(row=1, column=0)
        #        self.box2.grid(row=1, column=2)

        self.player1.grid(row=2, column=0, pady=50)
        self.player2.grid(row=2, column=2, pady=50)
        # Disable colour #AF7135

        # ---------------------------heading label for game----------------------------------

        Label(head,
              text="Snake & Ladder",
              font=("times new roman", 48, "bold", "underline"),
              bg="snow",
              fg="green").pack()
        # ===================IMG0 WILL SET THE CANVAS SIZE FOR ALL THE CANVAS=================
        img0 = Image.open('cut_images/1.png')
        #--------------------button for players--------------------------------
        # bt1=Button(self.right,text="Player 1") #PLAYER 1's button
        # bt1.pack(side='bottom')
        # bt2=Button(self.right,text="Player 2")
        # bt2.pack(side='bottom')
        # -------------------NOW THE CAN IS CREATING THE SNAKE AND LADDER BOARD-----------------------
        self.can1 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can1.grid(row=10, column=1)
        img1 = PhotoImage(file='cut_images/1.png')
        self.can1.create_image(0, 0, image=img1, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can2 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can2.grid(row=10, column=2)
        img2 = PhotoImage(file='cut_images/2.png')
        self.can2.create_image(0, 0, image=img2, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can3 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can3.grid(row=10, column=3)
        img3 = PhotoImage(file='cut_images/3.png')
        self.can3.create_image(0, 0, image=img3, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can4 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can4.grid(row=10, column=4)
        img4 = PhotoImage(file='cut_images/4.png')
        self.can4.create_image(0, 0, image=img4, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can5 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can5.grid(row=10, column=5)
        img5 = PhotoImage(file='cut_images/5.png')
        self.can5.create_image(0, 0, image=img5, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can6 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can6.grid(row=10, column=6)
        img6 = PhotoImage(file='cut_images/6.png')
        self.can6.create_image(0, 0, image=img6, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can7 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can7.grid(row=10, column=7)
        img7 = PhotoImage(file='cut_images/7.png')
        self.can7.create_image(0, 0, image=img7, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can8 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can8.grid(row=10, column=8)
        img8 = PhotoImage(file='cut_images/8.png')
        self.can8.create_image(0, 0, image=img8, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can9 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can9.grid(row=10, column=9)
        img9 = PhotoImage(file='cut_images/9.png')
        self.can9.create_image(0, 0, image=img9, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can10 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can10.grid(row=10, column=10)
        img10 = PhotoImage(file='cut_images/10.png')
        self.can10.create_image(0, 0, image=img10, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can11 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can11.grid(row=9, column=10)
        img11 = PhotoImage(file='cut_images/11.png')
        self.can11.create_image(0, 0, image=img11, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can12 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can12.grid(row=9, column=9)
        img12 = PhotoImage(file='cut_images/12.png')
        self.can12.create_image(0, 0, image=img12, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can13 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can13.grid(row=9, column=8)
        img13 = PhotoImage(file='cut_images/13.png')
        self.can13.create_image(0, 0, image=img13, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can14 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can14.grid(row=9, column=7)
        img14 = PhotoImage(file='cut_images/14.png')
        self.can14.create_image(0, 0, image=img14, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can15 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can15.grid(row=9, column=6)
        img15 = PhotoImage(file='cut_images/15.png')
        self.can15.create_image(0, 0, image=img15, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can16 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can16.grid(row=9, column=5)
        img16 = PhotoImage(file='cut_images/16.png')
        self.can16.create_image(0, 0, image=img16, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can17 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can17.grid(row=9, column=4)
        img17 = PhotoImage(file='cut_images/17.png')
        self.can17.create_image(0, 0, image=img17, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can18 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can18.grid(row=9, column=3)
        img18 = PhotoImage(file='cut_images/18.png')
        self.can18.create_image(0, 0, image=img18, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can19 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can19.grid(row=9, column=2)
        img19 = PhotoImage(file='cut_images/19.png')
        self.can19.create_image(0, 0, image=img19, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can20 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can20.grid(row=9, column=1)
        img20 = PhotoImage(file='cut_images/20.png')
        self.can20.create_image(0, 0, image=img20, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can21 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can21.grid(row=8, column=1)
        img21 = PhotoImage(file='cut_images/21.png')
        self.can21.create_image(0, 0, image=img21, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can22 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can22.grid(row=8, column=2)
        img22 = PhotoImage(file='cut_images/22.png')
        self.can22.create_image(0, 0, image=img22, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can23 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can23.grid(row=8, column=3)
        img23 = PhotoImage(file='cut_images/23.png')
        self.can23.create_image(0, 0, image=img23, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can24 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can24.grid(row=8, column=4)
        img24 = PhotoImage(file='cut_images/24.png')
        self.can24.create_image(0, 0, image=img24, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can25 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can25.grid(row=8, column=5)
        img25 = PhotoImage(file='cut_images/25.png')
        self.can25.create_image(0, 0, image=img25, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can26 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can26.grid(row=8, column=6)
        img26 = PhotoImage(file='cut_images/26.png')
        self.can26.create_image(0, 0, image=img26, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can27 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can27.grid(row=8, column=7)
        img27 = PhotoImage(file='cut_images/27.png')
        self.can27.create_image(0, 0, image=img27, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can28 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can28.grid(row=8, column=8)
        img28 = PhotoImage(file='cut_images/28.png')
        self.can28.create_image(0, 0, image=img28, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can29 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can29.grid(row=8, column=9)
        img29 = PhotoImage(file='cut_images/29.png')
        self.can29.create_image(0, 0, image=img29, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can30 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can30.grid(row=8, column=10)
        img30 = PhotoImage(file='cut_images/30.png')
        self.can30.create_image(0, 0, image=img30, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can31 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can31.grid(row=7, column=10)
        img31 = PhotoImage(file='cut_images/31.png')
        self.can31.create_image(0, 0, image=img31, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can32 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can32.grid(row=7, column=9)
        img32 = PhotoImage(file='cut_images/32.png')
        self.can32.create_image(0, 0, image=img32, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can33 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can33.grid(row=7, column=8)
        img33 = PhotoImage(file='cut_images/33.png')
        self.can33.create_image(0, 0, image=img33, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can34 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can34.grid(row=7, column=7)
        img34 = PhotoImage(file='cut_images/34.png')
        self.can34.create_image(0, 0, image=img34, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can35 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can35.grid(row=7, column=6)
        img35 = PhotoImage(file='cut_images/35.png')
        self.can35.create_image(0, 0, image=img35, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can36 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can36.grid(row=7, column=5)
        img36 = PhotoImage(file='cut_images/36.png')
        self.can36.create_image(0, 0, image=img36, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can37 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can37.grid(row=7, column=4)
        img37 = PhotoImage(file='cut_images/37.png')
        self.can37.create_image(0, 0, image=img37, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can38 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can38.grid(row=7, column=3)
        img38 = PhotoImage(file='cut_images/38.png')
        self.can38.create_image(0, 0, image=img38, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can39 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can39.grid(row=7, column=2)
        img39 = PhotoImage(file='cut_images/39.png')
        self.can39.create_image(0, 0, image=img39, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can40 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can40.grid(row=7, column=1)
        img40 = PhotoImage(file='cut_images/40.png')
        self.can40.create_image(0, 0, image=img40, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can41 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can41.grid(row=6, column=1)
        img41 = PhotoImage(file='cut_images/41.png')
        self.can41.create_image(0, 0, image=img41, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can42 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can42.grid(row=6, column=2)
        img42 = PhotoImage(file='cut_images/42.png')
        self.can42.create_image(0, 0, image=img42, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can43 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can43.grid(row=6, column=3)
        img43 = PhotoImage(file='cut_images/43.png')
        self.can43.create_image(0, 0, image=img43, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can44 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can44.grid(row=6, column=4)
        img44 = PhotoImage(file='cut_images/44.png')
        self.can44.create_image(0, 0, image=img44, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can45 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can45.grid(row=6, column=5)
        img45 = PhotoImage(file='cut_images/45.png')
        self.can45.create_image(0, 0, image=img45, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can46 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can46.grid(row=6, column=6)
        img46 = PhotoImage(file='cut_images/46.png')
        self.can46.create_image(0, 0, image=img46, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can47 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can47.grid(row=6, column=7)
        img47 = PhotoImage(file='cut_images/47.png')
        self.can47.create_image(0, 0, image=img47, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can48 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can48.grid(row=6, column=8)
        img48 = PhotoImage(file='cut_images/48.png')
        self.can48.create_image(0, 0, image=img48, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can49 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can49.grid(row=6, column=9)
        img49 = PhotoImage(file='cut_images/49.png')
        self.can49.create_image(0, 0, image=img49, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can50 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can50.grid(row=6, column=10)
        img50 = PhotoImage(file='cut_images/50.png')
        self.can50.create_image(0, 0, image=img50, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can51 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can51.grid(row=5, column=10)
        img51 = PhotoImage(file='cut_images/51.png')
        self.can51.create_image(0, 0, image=img51, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can52 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can52.grid(row=5, column=9)
        img52 = PhotoImage(file='cut_images/52.png')
        self.can52.create_image(0, 0, image=img52, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can53 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can53.grid(row=5, column=8)
        img53 = PhotoImage(file='cut_images/53.png')
        self.can53.create_image(0, 0, image=img53, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can54 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can54.grid(row=5, column=7)
        img54 = PhotoImage(file='cut_images/54.png')
        self.can54.create_image(0, 0, image=img54, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can55 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can55.grid(row=5, column=6)
        img55 = PhotoImage(file='cut_images/55.png')
        self.can55.create_image(0, 0, image=img55, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can56 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can56.grid(row=5, column=5)
        img56 = PhotoImage(file='cut_images/56.png')
        self.can56.create_image(0, 0, image=img56, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can57 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can57.grid(row=5, column=4)
        img57 = PhotoImage(file='cut_images/57.png')
        self.can57.create_image(0, 0, image=img57, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can58 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can58.grid(row=5, column=3)
        img58 = PhotoImage(file='cut_images/58.png')
        self.can58.create_image(0, 0, image=img58, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can59 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can59.grid(row=5, column=2)
        img59 = PhotoImage(file='cut_images/59.png')
        self.can59.create_image(0, 0, image=img59, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can60 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can60.grid(row=5, column=1)
        img60 = PhotoImage(file='cut_images/60.png')
        self.can60.create_image(0, 0, image=img60, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can61 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can61.grid(row=4, column=1)
        img61 = PhotoImage(file='cut_images/61.png')
        self.can61.create_image(0, 0, image=img61, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can62 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can62.grid(row=4, column=2)
        img62 = PhotoImage(file='cut_images/62.png')
        self.can62.create_image(0, 0, image=img62, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can63 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can63.grid(row=4, column=3)
        img63 = PhotoImage(file='cut_images/63.png')
        self.can63.create_image(0, 0, image=img63, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can64 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can64.grid(row=4, column=4)
        img64 = PhotoImage(file='cut_images/64.png')
        self.can64.create_image(0, 0, image=img64, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can65 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can65.grid(row=4, column=5)
        img65 = PhotoImage(file='cut_images/65.png')
        self.can65.create_image(0, 0, image=img65, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can66 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can66.grid(row=4, column=6)
        img66 = PhotoImage(file='cut_images/66.png')
        self.can66.create_image(0, 0, image=img66, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can67 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can67.grid(row=4, column=7)
        img67 = PhotoImage(file='cut_images/67.png')
        self.can67.create_image(0, 0, image=img67, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can68 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can68.grid(row=4, column=8)
        img68 = PhotoImage(file='cut_images/68.png')
        self.can68.create_image(0, 0, image=img68, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can69 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can69.grid(row=4, column=9)
        img69 = PhotoImage(file='cut_images/69.png')
        self.can69.create_image(0, 0, image=img69, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can70 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can70.grid(row=4, column=10)
        img70 = PhotoImage(file='cut_images/70.png')
        self.can70.create_image(0, 0, image=img70, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can71 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can71.grid(row=3, column=10)
        img71 = PhotoImage(file='cut_images/71.png')
        self.can71.create_image(0, 0, image=img71, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can72 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can72.grid(row=3, column=9)
        img72 = PhotoImage(file='cut_images/72.png')
        self.can72.create_image(0, 0, image=img72, anchor=NW)

        #---------------------------------------------------------------------------------
        self.can73 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can73.grid(row=3, column=8)
        img73 = PhotoImage(file='cut_images/73.png')
        self.can73.create_image(0, 0, image=img73, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can74 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can74.grid(row=3, column=7)
        img74 = PhotoImage(file='cut_images/74.png')
        self.can74.create_image(0, 0, image=img74, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can75 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can75.grid(row=3, column=6)
        img75 = PhotoImage(file='cut_images/75.png')
        self.can75.create_image(0, 0, image=img75, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can76 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can76.grid(row=3, column=5)
        img76 = PhotoImage(file='cut_images/76.png')
        self.can76.create_image(0, 0, image=img76, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can77 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can77.grid(row=3, column=4)
        img77 = PhotoImage(file='cut_images/77.png')
        self.can77.create_image(0, 0, image=img77, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can78 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can78.grid(row=3, column=3)
        img78 = PhotoImage(file='cut_images/78.png')
        self.can78.create_image(0, 0, image=img78, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can79 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can79.grid(row=3, column=2)
        img79 = PhotoImage(file='cut_images/79.png')
        self.can79.create_image(0, 0, image=img79, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can80 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can80.grid(row=3, column=1)
        img80 = PhotoImage(file='cut_images/80.png')
        self.can80.create_image(0, 0, image=img80, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can81 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can81.grid(row=2, column=1)
        img81 = PhotoImage(file='cut_images/81.png')
        self.can81.create_image(0, 0, image=img81, anchor=NW)
        #---------------------------------------------------------------------------------
        self.can82 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can82.grid(row=2, column=2)
        img82 = PhotoImage(file='cut_images/82.png')
        self.can82.create_image(0, 0, image=img82, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can83 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can83.grid(row=2, column=3)
        img83 = PhotoImage(file='cut_images/83.png')
        self.can83.create_image(0, 0, image=img83, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can84 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can84.grid(row=2, column=4)
        img84 = PhotoImage(file='cut_images/84.png')
        self.can84.create_image(0, 0, image=img84, anchor=NW)
        # ---------------------------------------------------------------------------------
        self.can85 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can85.grid(row=2, column=5)
        img85 = PhotoImage(file='cut_images/85.png')
        self.can85.create_image(0, 0, image=img85, anchor=NW)
        # ---------------------------------------------------------------------------------
        self.can86 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can86.grid(row=2, column=6)
        img86 = PhotoImage(file='cut_images/86.png')
        self.can86.create_image(0, 0, image=img86, anchor=NW)
        # ---------------------------------------------------------------------------------
        self.can87 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can87.grid(row=2, column=7)
        img87 = PhotoImage(file='cut_images/87.png')
        self.can87.create_image(0, 0, image=img87, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can88 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can88.grid(row=2, column=8)
        img88 = PhotoImage(file='cut_images/88.png')
        self.can88.create_image(0, 0, image=img88, anchor=NW)
        # ---------------------------------------------------------------------------------
        self.can89 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can89.grid(row=2, column=9)
        img89 = PhotoImage(file='cut_images/89.png')
        self.can89.create_image(0, 0, image=img89, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can90 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can90.grid(row=2, column=10)
        img90 = PhotoImage(file='cut_images/90.png')
        self.can90.create_image(0, 0, image=img90, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can91 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can91.grid(row=1, column=10)
        img91 = PhotoImage(file='cut_images/91.png')
        self.can91.create_image(0, 0, image=img91, anchor=NW)
        # ---------------------------------------------------------------------------------
        self.can92 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can92.grid(row=1, column=9)
        img92 = PhotoImage(file='cut_images/92.png')
        self.can92.create_image(0, 0, image=img92, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can93 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can93.grid(row=1, column=8)
        img93 = PhotoImage(file='cut_images/93.png')
        self.can93.create_image(0, 0, image=img93, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can94 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can94.grid(row=1, column=7)
        img94 = PhotoImage(file='cut_images/94.png')
        self.can94.create_image(0, 0, image=img94, anchor=NW)
        # ---------------------------------------------------------------------------------
        self.can95 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can95.grid(row=1, column=6)
        img95 = PhotoImage(file='cut_images/95.png')
        self.can95.create_image(0, 0, image=img95, anchor=NW)
        # ---------------------------------------------------------------------------------
        self.can96 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can96.grid(row=1, column=5)
        img96 = PhotoImage(file='cut_images/96.png')
        self.can96.create_image(0, 0, image=img96, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can97 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can97.grid(row=1, column=4)
        img97 = PhotoImage(file='cut_images/97.png')
        self.can97.create_image(0, 0, image=img97, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can98 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can98.grid(row=1, column=3)
        img98 = PhotoImage(file='cut_images/98.png')
        self.can98.create_image(0, 0, image=img98, anchor=NW)
        # ---------------------------------------------------------------------------------
        self.can99 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can99.grid(row=1, column=2)
        img99 = PhotoImage(file='cut_images/99.png')
        self.can99.create_image(0, 0, image=img99, anchor=NW)

        # ---------------------------------------------------------------------------------
        self.can100 = Canvas(left, height=img0.size[0], width=img0.size[0])
        self.can100.grid(row=1, column=1)
        img100 = PhotoImage(file='cut_images/100.png')
        self.can100.create_image(0, 0, image=img100, anchor=NW)

        self.can_list = [
            "", self.can1, self.can2, self.can3, self.can4, self.can5,
            self.can6, self.can7, self.can8, self.can9, self.can10, self.can11,
            self.can12, self.can13, self.can14, self.can15, self.can16,
            self.can17, self.can18, self.can19, self.can20, self.can21,
            self.can22, self.can23, self.can24, self.can25, self.can26,
            self.can27, self.can28, self.can29, self.can30, self.can31,
            self.can32, self.can33, self.can34, self.can35, self.can36,
            self.can37, self.can38, self.can39, self.can40, self.can41,
            self.can42, self.can43, self.can44, self.can45, self.can46,
            self.can47, self.can48, self.can49, self.can50, self.can51,
            self.can52, self.can53, self.can54, self.can55, self.can56,
            self.can57, self.can58, self.can59, self.can60, self.can61,
            self.can62, self.can63, self.can64, self.can65, self.can66,
            self.can67, self.can68, self.can69, self.can70, self.can71,
            self.can72, self.can73, self.can74, self.can75, self.can76,
            self.can77, self.can78, self.can79, self.can80, self.can81,
            self.can82, self.can83, self.can84, self.can85, self.can86,
            self.can87, self.can88, self.can89, self.can90, self.can91,
            self.can92, self.can93, self.can94, self.can95, self.can96,
            self.can97, self.can98, self.can99, self.can100
        ]

        root.mainloop()
Esempio n. 24
0
 def nas(self):
     self.master = Tk()
     self.master.geometry("840x630")
     frame = Frame(self.master)
     frame1 = Frame(self.master)
     frame2 = Frame(self.master)
     but = Button(frame,
                  text="В меню",
                  height=4,
                  width=20,
                  bg="#090",
                  command=self.menu_nav)
     label_color = Label(frame1, text="Изменить цвет змейки")
     but1 = Button(frame1,
                   text="Зеленый",
                   height=4,
                   width=20,
                   bg="#0f0",
                   command=self.green)
     but2 = Button(frame1,
                   text="Красный",
                   height=4,
                   width=20,
                   bg="#f00",
                   command=self.red)
     but3 = Button(frame1,
                   text="Синий",
                   height=4,
                   width=20,
                   bg="#00f",
                   command=self.blue)
     but4 = Button(frame1,
                   text="Желтый",
                   height=4,
                   width=20,
                   bg="#ff0",
                   command=self.yellow)
     but5 = Button(frame1,
                   text="Белый",
                   height=4,
                   width=20,
                   bg="#fff",
                   command=self.white)
     label_speed = Label(frame2, text="Изменить Скорость змейки")
     button = Button(frame2,
                     text="Медленая",
                     height=4,
                     width=20,
                     bg="#0f0",
                     command=self.speed_min)
     button1 = Button(frame2,
                      text="Нормальная",
                      height=4,
                      width=20,
                      bg="#ff0",
                      command=self.speed_norm)
     button2 = Button(frame2,
                      text="Быстрая",
                      height=4,
                      width=20,
                      bg="#f00",
                      command=self.speed_max)
     frame.pack()
     frame1.pack()
     frame2.pack()
     but.pack()
     label_color.pack(padx=10, pady=10)
     but1.pack(side=LEFT, padx=5, pady=5)
     but2.pack(side=LEFT, padx=5, pady=5)
     but3.pack(side=LEFT, padx=5, pady=5)
     but4.pack(side=LEFT, padx=5, pady=5)
     but5.pack(side=LEFT, padx=5, pady=5)
     label_speed.pack(padx=10, pady=10)
     button.pack(side=LEFT, padx=5, pady=5)
     button1.pack(side=LEFT, padx=5, pady=5)
     button2.pack(side=LEFT, padx=5, pady=5)
     self.master.mainloop()
Esempio n. 25
0
Top = Frame(root, width=500, bd=1, relief=SOLID, bg="#bb86fc")
Top.pack(side=TOP)
Mid = Frame(root, width=500, bg="#121212")
Mid.pack(side=TOP)
MidLeft = Frame(Mid, width=100)
MidLeft.pack(side=LEFT, pady=10)
MidLeftPadding = Frame(Mid, width=370, bg="#121212")
MidLeftPadding.pack(side=LEFT)
MidRight = Frame(Mid, width=100)
MidRight.pack(side=RIGHT, pady=10)
TableMargin = Frame(root, width=500)
TableMargin.pack(side=TOP)

#----------LABELS----------#
lbl_title = Label(Top,
                  text="Contact Management System",
                  font=("arial", 16),
                  width=500)
lbl_title.pack(fill=X)

#----------BUTTONS----------#
btn_add = Button(MidLeft, text="ADD NEW", bg="#03dac5", command=AddNewWindow)
btn_add.pack()
btn_delete = Button(MidRight,
                    text="DELETE EXISTING",
                    bg="#cf6679",
                    command=DeleteData)
btn_delete.pack(side=RIGHT)

#----------TABLES----------#
scrollbarx = Scrollbar(TableMargin, orient=HORIZONTAL)
scrollbary = Scrollbar(TableMargin, orient=VERTICAL)
def Caffe_multiple_features_extraction(folder,
                                       caffemodel,
                                       prototxt,
                                       mean_v,
                                       layer,
                                       crop_size,
                                       cuda,
                                       save_activations,
                                       out_prefix,
                                       GUI=None):
    """ This function lets to extract features from an image using a Keras pre-trained CNN model.
        _____________________________________________________________________________________

        Parameters:
                - folder: string
                        It is the path to a folder containing the images from which extract features.
                        For projectual reason imposed by the full project, this folder must have the following
                        structure:
                                - Folder
                                        + subfolder1
                                        + ......
                                        - subfolderN
                                                - image1
                                                - image2
                                                - ......
                - caffemodel: string
                        It is the path of a Caffe pre-trained model file
                - prototxt: string
                        It is the path of a prototxt file
                - mean_v: array-like
                        the mean vector of the data set on which the net was pre-trained
                - crop_size: int
                        It is the size the input images must have (img.shape=(crop_size,crop_size,3)) for the model       
                - layer: string
                        It is the name of the layer from which extract features.
                - cuda: bool
                        If it is True GPU will be used for the extraction, else only CPU will be used.
                        To set this parameter on True you need to have CUDA drivers installed.
                - save_activations: bool
                        if it is True all the activations of all images will be saves as
                        .png files in Results/Activations folder.
                - out_prefix: string
                        It is the prefix of the name of the output file. Infact, during
                        the process a .h5 file will be generated.
                        This file containg extracted features for all images, labels (intended
                        as subfolder names)of all images (intended as subfolder names), and images
                        list of addresses. All these things are stored respectivelly in the following
                        datasets: 'feats','labels','img_ids'.
                - GUI: object (default None)
                        Do not consider this parameter. This parameter was created expressly for the
                        usage of this function with "FeaturesExtraction_GUI" in order to update the
                        progress bar in the GUI while extraction is in progress.

        Returns:
                This function don't return any variable, but during the process a .h5 file will be generated.
                This file containg extracted features for all images, labels (intended as subfolder names)
                of all images (intended as subfolder names), and images list of addresses. All these things
                are stored respectivelly in the following datasets: 'feats','labels','img_ids'.

        Example usage:
                import CaffeFeaturesExtraction as cfe
                model='caffe alexnet'
                layer= 'conv1'
                folder='Training'
                cuda=False
                save_activation=True
                out_prefix=model+'_'+layer
                caffemodel, prototxt, crop_size, mean_v=cfe.Caffe_model_path(model)
                Caffe_multiple_features_extraction(folder,caffemodel, prototxt, mean_v, layer, crop_size, cuda, save_activations,out_prefix, GUI=None)
                
        """
    s = os.sep
    # Get a proper name for the .txt list of images
    gender = folder.split(s)[-1]

    # Create a list of images
    mf.list_generator(folder, gender, 'png')

    # Create folders in which store features and activations files
    mf.folders_creator('Results', ['Features', 'Activations'])

    # Read .txt list of images and load it as list
    f = open(gender + '.txt', 'r')
    lines = f.readlines()
    lines = [line.rstrip() for line in lines]
    f.close()

    # Take 1st word of each line as an image name, creating a names list
    img_list = [line.split(' ')[0] for line in lines]
    # Take 2nd word of each line as a class, creating a labels list
    lab = [line.split(' ')[1] for line in lines]

    if GUI != None:
        # If GUI mode is ON, initialize a Progress bar
        currentImage = Label(GUI, text=' ' * 50)
        currentImage.grid(row=0, column=1)
        progress = Progressbar(GUI,
                               orient="horizontal",
                               length=200,
                               mode="determinate")
        progress.grid(row=1, column=1)
        value = 0
        progress["value"] = 0
        progress["maximum"] = len(lines)
        step = 1

    if cuda == True:
        # Set Caffe GPU mode
        caffe.set_mode_gpu()
    else:
        # Set Caffe CPU only mode
        caffe.set_mode_cpu()

    # Get net and transformer
    net, transformer = Caffe_get_net_and_transformer(caffemodel, prototxt,
                                                     mean_v, crop_size)

    # Initialize some usefull empty lists
    feats = []
    img_ids = []
    labels = []

    # Initialize to 0 some counters and flag
    i = 0
    count = 0
    file_created = 0

    # Process all images in the list
    for im in img_list:

        if i == 0:
            # Clear terminal
            try:
                os.system('clear')
            except:
                os.system('cls')
            print('Features Extraction from ' + folder)
            # Initialize progress bar
            bar = progressbar.ProgressBar(max_value=len(lines))

        # Update progress bar
        bar.update(i)

        # Load image
        img = caffe.io.load_image(im)

        # Extract features from image
        feat = Caffe_extract_feature(net, transformer, img, crop_size, layer)

        if save_activations == True:
            if i == 0:
                # Create folders in which store features and activations files
                mf.folders_creator('Results' + s + 'Activations' + s + gender)
                # Visualize activations
            M = mf.visualize_activations(feat)

        # Reshape features matrix to an array
        feat = feat.reshape((1, feat.size))
        feat = np.squeeze(feat)

        # Append features array to features list
        feats.append(feat)
        # Append label to labels list
        labels.append(int(lab[i]))

        if GUI != None:
            # If GUI mode is ON, update Progress bar value
            a = value / len(lines) * 100
            currentImage["text"] = 'Processing...' + "{0:.1f}".format(
                round(a, 1)) + ' % '
            currentImage.update()
            value += step
            progress["value"] = int(value)
            progress.update()

        # Abbreviete current image path and append it to image ids list
        tmp = im.split(s)
        im = s.join([tmp[-2], tmp[-1]])
        img_ids.append(np.string_(im))

        if save_activations == True:
            # Write activations
            n = 'Results' + s + 'Activations' + s + gender + '/' + out_prefix + '_' + im.split(
                s)[1]
            mf.save_as_image(M, n)

        if file_created == 0:
            # Create an Hierarchical Data Format (.h5) file in which
            # store Features, Labels and Names of the processed images
            feats_shape = [len(img_list), feat.shape[0]]
            name = 'Results' + s + 'Features' + s + out_prefix + '_' + gender + '.h5'
            f = h5py.File(name, "w")
            feats_dset = f.create_dataset("feats",
                                          feats_shape,
                                          compression="gzip")
            img_id_dset = f.create_dataset("img_id", (len(img_list), ),
                                           dtype="S40")
            labels_dset = f.create_dataset("labels", (len(img_list), ),
                                           compression="gzip")
            file_created = 1

        N = 100
        if (i + 1) % N == 0:
            # Every N processed images save data to the created .h5 file
            # and clean the list variables to empty the RAM

            # Convert lists to numpy arrays
            feats = np.asarray(feats)
            labels = np.asarray(labels)

            # Write data
            feats_dset[i - N + 1:i + 1] = feats
            img_id_dset[i - N + 1:i + 1] = img_ids
            labels_dset[i - N + 1:i + 1] = labels

            # Clean list variables
            feats = []
            labels = []
            img_ids = []

            count = -1

        i += 1
        count += 1

    # Convert lists to numpy arrays
    feats = np.asarray(feats)
    labels = np.asarray(labels)
    # Write remaining data
    feats_dset[i - count:i + 1] = feats
    img_id_dset[i - count:i + 1] = img_ids
    labels_dset[i - count:i + 1] = labels
    # Clean list variables
    feats = []
    labels = []
    img_ids = []

    # Close file
    f.close()

    if GUI != None:
        # If GUI mode is ON, update Progress bar value
        currentImage["text"] = '         Completed                      '
        currentImage.update()
        value += step
        progress["value"] = int(value)
        progress.update()
Esempio n. 27
0
def AddNewWindow():
    global NewWindow
    FIRSTNAME.set("")
    LASTNAME.set("")
    GENDER.set("")
    AGE.set("")
    ADDRESS.set("")
    CONTACT.set("")
    NewWindow = Toplevel()
    NewWindow.title("Contact List")
    width = 400
    height = 300
    screen_width = root.winfo_screenwidth()
    screen_height = root.winfo_screenheight()
    x = ((screen_width / 2) - 455) - (width / 2)
    y = ((screen_height / 2) + 20) - (height / 2)
    NewWindow.resizable(0, 0)
    NewWindow.geometry("%dx%d+%d+%d" % (width, height, x, y))
    if 'UpdateWindow' in globals():
        UpdateWindow.destroy()

    #----------FRAMES----------#
    FormTitle = Frame(NewWindow)
    FormTitle.pack(side=TOP)
    ContactForm = Frame(NewWindow)
    ContactForm.pack(side=TOP, pady=10)
    RadioGroup = Frame(ContactForm)
    Male = Radiobutton(RadioGroup,
                       text="Male",
                       variable=GENDER,
                       value='Male',
                       font=('arial', 14)).pack(side=LEFT)
    Female = Radiobutton(RadioGroup,
                         text="Female",
                         variable=GENDER,
                         value='Female',
                         font=('arial', 14)).pack(side=LEFT)

    #----------LABELS----------#
    lbl_title = Label(FormTitle,
                      text="Adding New Contacts",
                      font=('arial', 16),
                      bg="#03dac5",
                      width=300)
    lbl_title.pack(fill=X)
    lbl_firstname = Label(ContactForm,
                          text="Firstname",
                          font=('arial', 14),
                          bd=5)
    lbl_firstname.grid(row=0, sticky=W)
    lbl_lastname = Label(ContactForm,
                         text="Lastname",
                         font=('arial', 14),
                         bd=5)
    lbl_lastname.grid(row=1, sticky=W)
    lbl_gender = Label(ContactForm, text="Gender", font=('arial', 14), bd=5)
    lbl_gender.grid(row=2, sticky=W)
    lbl_age = Label(ContactForm, text="Age", font=('arial', 14), bd=5)
    lbl_age.grid(row=3, sticky=W)
    lbl_address = Label(ContactForm, text="Address", font=('arial', 14), bd=5)
    lbl_address.grid(row=4, sticky=W)
    lbl_contact = Label(ContactForm, text="Contact", font=('arial', 14), bd=5)
    lbl_contact.grid(row=5, sticky=W)

    #----------ENTRY----------#
    firstname = Entry(ContactForm, textvariable=FIRSTNAME, font=('arial', 14))
    firstname.grid(row=0, column=1)
    lastname = Entry(ContactForm, textvariable=LASTNAME, font=('arial', 14))
    lastname.grid(row=1, column=1)
    RadioGroup.grid(row=2, column=1)
    age = Entry(ContactForm, textvariable=AGE, font=('arial', 14))
    age.grid(row=3, column=1)
    address = Entry(ContactForm, textvariable=ADDRESS, font=('arial', 14))
    address.grid(row=4, column=1)
    contact = Entry(ContactForm, textvariable=CONTACT, font=('arial', 14))
    contact.grid(row=5, column=1)

    #----------BUTTONS----------#
    btn_addcon = Button(ContactForm, text="Save", width=50, command=SubmitData)
    btn_addcon.grid(row=6, columnspan=2, pady=10)
Esempio n. 28
0
    def __init__(self, parent, controller):
        super().__init__(parent)
        #make the view

        #set the delegate/callback pointer
        self.controller = controller
        self.parent = parent

        #control variables
        # i_names = instruments to be shown in the instrument listbox
        self.i_names = StringVar()
        # s_names = samples to be shown in the sample listbox
        self.s_names = StringVar()
        # version = teensy version reflected in the selected element
        # of the radiobutton in the 'select teensy version' frame.
        self.version = IntVar(value=1)
        # out_dir = reflects contents of the 'folder' entry in the
        # 'output settings' frame
        self.out_dir = StringVar(value='Select Directory...')
        self.default_out_name = 'Default is Instrument Name'
        # out_name = reflects contents of the 'name' entyr in the
        # 'output settings' frame
        self.out_name = StringVar(value=self.default_out_name)
        self.total_sample_size = IntVar(value=0)
        self.num_samples_selected = IntVar(value=0)
        self.teensy_percent_used = IntVar(value=0.0)
        # inFile = reflects the filepath that the user chooses as the
        # soundfont file to decode samples from
        self.inFile = StringVar(value='Select a Soundfont File to Continue')

        #formating variables
        self.lrg_font = 14
        self.med_font = 12
        self.sml_font = 10
        self.box_relief = RIDGE
        self.box_pad = 1
        def_pad = 3
        s = Style()
        s.theme_use('default')
        s.configure('.', font=('default', self.sml_font))
        s.configure('TRadiobutton', font=('default', self.med_font))
        s.configure('TLabelframe.Label', font=('default', self.med_font))

        #set up the widgets/layout
        self.parent.columnconfigure(0, weight=1)
        self.parent.rowconfigure(0, weight=1)
        self.grid(column=0, row=0, sticky=N + S + E + W)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)  # Boxes
        self.rowconfigure(1, weight=6)  # ListBoxes
        self.rowconfigure(2, weight=1)  # StatusBar

        # main menu
        self.menu = pjrc.JJMenu(self.parent)
        self.parent.config(menu=self.menu)
        self.menu.filemenu.add_command(
            label='Load SF2', command=self.controller.inBrowseSelected)

        self.upper_frame = pjrc.JJFrame(self)
        self.upper_frame.rcconfigure(_rows=[(0, 1)],
                                     _columns=[(0, 1), (1, 2), (2, 3)])
        self.upper_frame.grid(column=0,
                              row=0,
                              columnspan=4,
                              sticky=N + S + E + W,
                              padx=5,
                              pady=5)

        self.box_1 = pjrc.JJLabelFrame(self.upper_frame,
                                       4,
                                       1,
                                       1,
                                       1,
                                       text='Select Teensy Version')
        self.box_1.grid(column=0,
                        row=0,
                        padx=self.box_pad,
                        pady=self.box_pad,
                        sticky=N + S + E + W)
        self.version_frame = pjrc.JJFrame(self.box_1, 2, 1, 1, 1)
        self.version_frame.grid(row=1, padx=def_pad, sticky=N + E + W)
        self.ver_32 = Radiobutton(self.version_frame,
                                  text='Teensy 3.2 (default)',
                                  variable=self.version,
                                  command=lambda: self.teensyButtonSelect(1),
                                  value=1)
        self.ver_32.grid(row=0, column=0, sticky=N + S + E + W, padx=def_pad)
        self.ver_36 = Radiobutton(self.version_frame,
                                  text='Teensy 3.6',
                                  variable=self.version,
                                  command=lambda: self.teensyButtonSelect(2),
                                  value=2)
        self.ver_36.grid(row=1, column=0, sticky=N + S + E + W, padx=def_pad)
        self.ver_40 = Radiobutton(self.version_frame,
                                  text='Teensy 4.0',
                                  variable=self.version,
                                  command=lambda: self.teensyButtonSelect(3),
                                  value=3)
        self.ver_40.grid(row=2, column=0, sticky=N + S + E + W, padx=def_pad)
        self.ver_41 = Radiobutton(self.version_frame,
                                  text='Teensy 4.1',
                                  variable=self.version,
                                  command=lambda: self.teensyButtonSelect(4),
                                  value=4)
        self.ver_41.grid(row=3, column=0, sticky=N + S + E + W, padx=def_pad)

        self.box_2 = pjrc.JJLabelFrame(self.upper_frame,
                                       2,
                                       1,
                                       1,
                                       1,
                                       text='Load a SoundFont')
        self.box_2.grid(column=1,
                        row=0,
                        padx=self.box_pad,
                        pady=self.box_pad,
                        sticky=N + S + E + W)
        # TODO make this text wrap better
        self.infile_label = Message(self.box_2,
                                    textvariable=self.inFile,
                                    anchor=W,
                                    justify=LEFT,
                                    aspect=400)
        self.infile_label.grid(row=0,
                               column=0,
                               padx=def_pad,
                               pady=def_pad,
                               sticky=E + W)
        self.browse_button = Button(self.box_2,
                                    text="Browse",
                                    command=self.controller.inBrowseSelected)
        self.browse_button.grid(row=1,
                                column=0,
                                padx=def_pad,
                                pady=def_pad,
                                sticky=N)

        self.box_3 = pjrc.JJLabelFrame(self.upper_frame,
                                       2,
                                       1,
                                       1,
                                       1,
                                       text='Output Settings')
        self.box_3.grid(column=2,
                        row=0,
                        padx=self.box_pad,
                        pady=self.box_pad,
                        sticky=N + S + E + W)
        self.dir_line = Frame(self.box_3)
        self.dir_line.grid(row=0, column=0)
        self.folder_label = Label(self.dir_line, text='Folder')
        self.folder_label.grid(row=1, column=0)
        self.folder_entry = Entry(self.dir_line, textvariable=self.out_dir)
        self.folder_entry.grid(row=1, column=1)
        self.folder_button = Button(self.dir_line,
                                    text='Browse',
                                    command=self.controller.outBrowseSelected)
        self.folder_button.grid(row=1, column=2)
        self.name_label = Label(self.dir_line, text='Name')
        self.name_label.grid(row=0, column=0)
        self.name_entry = Entry(self.dir_line, textvariable=self.out_name)
        self.name_entry.grid(row=0, column=1, columnspan=2, sticky=E + W)

        self.lower_frame = pjrc.JJFrame(self, 1, 2, 1, 1)
        self.lower_frame.configurerows([(0, 1), (1, 0)])
        self.lower_frame.grid(column=0,
                              row=1,
                              columnspan=4,
                              sticky=N + S + E + W,
                              padx=1,
                              pady=1)

        # Instruments
        self.inst_listbox = pjrc.JJListBox(self.lower_frame, 'Instruments',
                                           self.i_names)
        self.inst_listbox.grid(column=0,
                               row=0,
                               rowspan=2,
                               sticky=N + S + E + W,
                               padx=5)

        # Samples
        self.samp_listbox = pjrc.JJListBox(self.lower_frame, 'Samples',
                                           self.s_names)
        self.samp_listbox.grid(column=1, row=0, sticky=N + S + E + W, padx=5)
        self.samp_listbox.list_box.config(selectmode=EXTENDED)
        # self.samp_listbox.list_box.config(selectmode=MULTIPLE) FOR CHECKBOX STYLE SELECTION

        self.under_frame = pjrc.JJFrame(self.lower_frame, 1, 1, 1, 1)
        self.under_frame.grid(column=1, row=1, sticky=N + S + E + W)
        self.decode_button = Button(self.under_frame,
                                    text='Decode',
                                    command=self.samplesSelected)
        self.decode_button.grid(row=1, column=0, padx=2, pady=2)

        # Displays sample size, num selected and memory usage percentage for teensy
        #TODO put in different frame to fix listbox stretching
        self.stats_frame = pjrc.JJLabelFrame(self.under_frame,
                                             3,
                                             2,
                                             1,
                                             1,
                                             text='Sample Stats')
        self.stats_frame.grid(row=0,
                              column=0,
                              sticky=N + E + W,
                              padx=5,
                              pady=0)
        self.stats_frame.num_selected_text_label = Label(
            self.stats_frame, text='Num Samples Selected:', anchor=E)
        self.stats_frame.num_selected_text_label.grid(row=0,
                                                      column=0,
                                                      padx=2,
                                                      pady=0,
                                                      sticky=N + S + E)
        self.stats_frame.num_selected_label = Label(
            self.stats_frame, textvariable=self.num_samples_selected, anchor=W)
        self.stats_frame.num_selected_label.grid(row=0,
                                                 column=1,
                                                 padx=2,
                                                 pady=0,
                                                 sticky=N + S + W)
        self.stats_frame.samp_size_text_label = Label(
            self.stats_frame, text='Size of Selections (kb):', anchor=E)
        self.stats_frame.samp_size_text_label.grid(row=1,
                                                   column=0,
                                                   padx=2,
                                                   pady=0,
                                                   sticky=N + S + E)
        self.stats_frame.samp_size_label = Label(
            self.stats_frame, textvariable=self.total_sample_size, anchor=W)
        self.stats_frame.samp_size_label.grid(row=1,
                                              column=1,
                                              padx=2,
                                              pady=0,
                                              sticky=N + S + W)
        self.stats_frame.teensy_percent_text_label = Label(
            self.stats_frame, text='Est. Teensy Usage (%):', anchor=E)
        self.stats_frame.teensy_percent_text_label.grid(row=2,
                                                        column=0,
                                                        padx=2,
                                                        pady=0,
                                                        sticky=N + S + E)
        self.stats_frame.teensy_percent_label = Label(
            self.stats_frame, textvariable=self.teensy_percent_used, anchor=W)
        self.stats_frame.teensy_percent_label.grid(row=2,
                                                   column=1,
                                                   padx=2,
                                                   pady=0,
                                                   sticky=N + S + W)

        # Status bar at bottom
        self.status_bar = pjrc.JJStatusBar(self, 'Load a Soundfont')
        self.status_bar.grid(row=2, column=0, sticky=E + W + S, padx=0, pady=0)

        # Set Bindings
        self.inst_listbox.list_box.bind('<<ListboxSelect>>', self.instSelected)
        self.samp_listbox.list_box.bind('<<ListboxSelect>>',
                                        self.sampleSelected)
        self.samp_listbox.list_box.bind('<Double-1>', self.samplesSelected)
Esempio n. 29
0
    def __init__(self, master, columns, column_weights=None, cnf={}, **kw):
        """
        Construct a new multi-column listbox widget.

        :param master: The widget that should contain the new
            multi-column listbox.

        :param columns: Specifies what columns should be included in
            the new multi-column listbox.  If ``columns`` is an integer,
            the it is the number of columns to include.  If it is
            a list, then its length indicates the number of columns
            to include; and each element of the list will be used as
            a label for the corresponding column.

        :param cnf, kw: Configuration parameters for this widget.
            Use ``label_*`` to configure all labels; and ``listbox_*``
            to configure all listboxes.  E.g.:

                >>> mlb = MultiListbox(master, 5, label_foreground='red')
        """
        # If columns was specified as an int, convert it to a list.
        if isinstance(columns, int):
            columns = list(range(columns))
            include_labels = False
        else:
            include_labels = True

        if len(columns) == 0:
            raise ValueError("Expected at least one column")

        # Instance variables
        self._column_names = tuple(columns)
        self._listboxes = []
        self._labels = []

        # Pick a default value for column_weights, if none was specified.
        if column_weights is None:
            column_weights = [1] * len(columns)
        elif len(column_weights) != len(columns):
            raise ValueError('Expected one column_weight for each column')
        self._column_weights = column_weights

        # Configure our widgets.
        Frame.__init__(self, master, **self.FRAME_CONFIG)
        self.grid_rowconfigure(1, weight=1)
        for i, label in enumerate(self._column_names):
            self.grid_columnconfigure(i, weight=column_weights[i])

            # Create a label for the column
            if include_labels:
                l = Label(self, text=label, **self.LABEL_CONFIG)
                self._labels.append(l)
                l.grid(column=i, row=0, sticky='news', padx=0, pady=0)
                l.column_index = i

            # Create a listbox for the column
            lb = Listbox(self, **self.LISTBOX_CONFIG)
            self._listboxes.append(lb)
            lb.grid(column=i, row=1, sticky='news', padx=0, pady=0)
            lb.column_index = i

            # Clicking or dragging selects:
            lb.bind('<Button-1>', self._select)
            lb.bind('<B1-Motion>', self._select)
            # Scroll whell scrolls:
            lb.bind('<Button-4>', lambda e: self._scroll(-1))
            lb.bind('<Button-5>', lambda e: self._scroll(+1))
            lb.bind('<MouseWheel>', lambda e: self._scroll(e.delta))
            # Button 2 can be used to scan:
            lb.bind('<Button-2>', lambda e: self.scan_mark(e.x, e.y))
            lb.bind('<B2-Motion>', lambda e: self.scan_dragto(e.x, e.y))
            # Dragging outside the window has no effect (diable
            # the default listbox behavior, which scrolls):
            lb.bind('<B1-Leave>', lambda e: 'break')
            # Columns can be resized by dragging them:
            l.bind('<Button-1>', self._resize_column)

        # Columns can be resized by dragging them.  (This binding is
        # used if they click on the grid between columns:)
        self.bind('<Button-1>', self._resize_column)

        # Set up key bindings for the widget:
        self.bind('<Up>', lambda e: self.select(delta=-1))
        self.bind('<Down>', lambda e: self.select(delta=1))
        self.bind('<Prior>', lambda e: self.select(delta=-self._pagesize()))
        self.bind('<Next>', lambda e: self.select(delta=self._pagesize()))

        # Configuration customizations
        self.configure(cnf, **kw)
Esempio n. 30
0
 def __init__(self, *args, **kwargs):
     Page.__init__(self, *args, **kwargs)
     photo = PhotoImage(file=resource_path("white.gif"))
     photolab = Label(self, image=photo)
     photolab.image = photo
     photolab.grid(row=0, column=2, columnspan=2, rowspan=4, sticky='nwes')