Esempio n. 1
0
def main():
    global images_clusters
    global frame_rhs

    root = Tk()
    root.title("Etsy")
    root.configure(background="white")
    # style configuration
    style = ttk.Style(root)
    style.configure('TLabel', background='white')
    style.configure('TFrame', background='white')

    screen_height = monitor_height(root)
    WINDOW_HEIGHT = screen_height - 130
    print(f"Screen height: {screen_height} window height: {WINDOW_HEIGHT}")

    if False:
        image_files = glob.glob(IMAGE_FOLDER + "/*/*/*.jpg")
        print(f"Found {len(image_files)}")
        print(image_files[0], image_files[550])

    dpi_value = root.winfo_fpixels('1i')
    print(f"Default dpi: {dpi_value}")
    # dpi_value = 400
    # root.tk.call('tk', 'scaling', '-displayof', '.', dpi_value / 72.0)
    root.tk.call('tk', 'scaling', '-displayof', '.', 4.0)
    # root.maxsize(1500, 400)
    root.grid_rowconfigure(0, weight=1)
    root.columnconfigure(0, weight=1)

    # content = Frame(root, bg="white", borderwidth=0, highlightbackground="white", highlightcolor="white")
    content, canvas = create_frame_with_scroll(root, 0, 0, WINDOW_WIDTH,
                                               WINDOW_HEIGHT)

    etsy_top_frame = Frame(content,
                           borderwidth=0,
                           width=RHS_WIDTH,
                           height=200,
                           bg="white")
    frame_lhs = ttk.Frame(content, borderwidth=0, width=LHS_WIDTH, height=400)
    # frame_lhs = create_frame_with_scroll(content, 0, 1, LHS_WIDTH, WINDOW_HEIGHT)
    frame_lhs_outlines = Frame(frame_lhs, bg="white", borderwidth=0)
    etsy_lhs_frame = Frame(frame_lhs,
                           borderwidth=0,
                           highlightbackground="white",
                           highlightcolor="white",
                           width=LHS_WIDTH,
                           height=200,
                           bg="white")

    # frame_rhs = create_frame_with_scroll(content, 2, 1, RHS_WIDTH, WINDOW_HEIGHT)
    frame_rhs = Frame(content, bg="white")

    # This commented line screws up the scrolling
    # content.grid(column=0, row=0)
    etsy_top_frame.grid(column=0, row=0, columnspan=5, sticky='NW')
    frame_lhs.grid(column=0, row=1, padx=0, pady=0, sticky='N')
    frame_lhs_outlines.grid(column=0, row=1, sticky=N + S + E + W)
    etsy_lhs_frame.grid(column=0, row=0, sticky='N')
    frame_rhs.grid(column=2, row=1, sticky='N')

    num_outlines = len(get_files_in_folder(OUTLINE_FOLDER, '.jpg'))
    num_outlines_per_col = round(num_outlines / NUM_OUTLINE_COLS)
    print(f"Num outlines per col: {num_outlines_per_col}")

    images_clusters = read_outline_json()
    Outline.set_canvas(canvas)
    Outline.set_clusters(images_clusters)
    Outline.set_frame(frame_rhs)
    display_outlines(frame_lhs_outlines, OUTLINE_FOLDER, num_outlines_per_col,
                     NUM_OUTLINE_COLS, Outline)

    add_tile_to_frame(etsy_top_frame, 'etsyFrame/topFrame.png')
    add_tile_to_frame(etsy_lhs_frame, 'etsyFrame/Etsy-Filter-version2.png')
    add_image_to_frame(frame_rhs, 'etsyFrame/etsy-num-results.png', 0, 0)
    add_image_to_frame(frame_rhs, 'etsyFrame/1st-background-small.png', 1, 0)
    add_image_to_frame(frame_rhs, 'etsyFrame/2nd-background-small.png', 2, 0)
    add_image_to_frame(frame_rhs, 'etsyFrame/3rd-background-small.png', 3, 0)
    add_image_to_frame(frame_rhs, 'etsyFrame/4th-background-small.png', 4, 0)
    # display_images(frame_rhs, images_clusters['outline21.jpg'], 15, 4)

    root.mainloop()