Skip to content

Commit

Permalink
[mapping panel] enable customtkinter style for tiles and links
Browse files Browse the repository at this point in the history
  • Loading branch information
yuqisun committed Aug 20, 2024
1 parent 3bda50c commit 3a22ea5
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions launchUI_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,8 @@ def clickShowDFG():
new_data.append(item)
PIL_image_stretched.putdata(new_data)

dfgImage = ImageTk.PhotoImage(PIL_image_stretched)
# dfgImage = ImageTk.PhotoImage(PIL_image_stretched)
dfgImage = customtkinter.CTkImage(PIL_image_stretched, size=(260, 380))
images["dfgImage"] = dfgImage # This is important due to the garbage collection would remove local variable of image
widgets["dfgLabel"].configure(image=dfgImage)

Expand Down Expand Up @@ -1408,22 +1409,25 @@ def drawSchedule():

for ii in range(mappingII):
# draw data memory
spmLabel = tkinter.Label(canvas, text="Data\nSPM", fg='black', bg='gray', relief='raised', bd=BORDER,
highlightbackground="black", highlightthickness=HIGHLIGHT_THICKNESS)
# spmLabel = tkinter.Label(canvas, text="Data\nSPM", fg='black', bg='gray', relief='raised', bd=BORDER,
# highlightbackground="black", highlightthickness=HIGHLIGHT_THICKNESS)
spmLabel = customtkinter.CTkButton(canvas, text="Data\nSPM", state='disabled')
canvas.create_window(baseX + BORDER, BORDER, window=spmLabel, height=GRID_HEIGHT, width=MEM_WIDTH, anchor="nw")

# draw tiles
for tile in paramCGRA.tiles:
if not tile.disabled:
button = None
if ii in tile.mapping:
button = tkinter.Label(canvas, text="Opt " + str(tile.mapping[ii]), fg="black", bg="cornflowerblue",
relief="raised", bd=BORDER, highlightbackground="black",
highlightthickness=HIGHLIGHT_THICKNESS)
# button = tkinter.Label(canvas, text="Opt " + str(tile.mapping[ii]), fg="black", bg="cornflowerblue",
# relief="raised", bd=BORDER, highlightbackground="black",
# highlightthickness=HIGHLIGHT_THICKNESS)
button = customtkinter.CTkButton(canvas, text="Opt " + str(tile.mapping[ii]), state='disabled')
else:
button = tkinter.Label(canvas, text="Tile " + str(tile.ID), fg="black", bg="grey", relief="raised",
bd=BORDER, highlightbackground="black",
highlightthickness=HIGHLIGHT_THICKNESS)
# button = tkinter.Label(canvas, text="Tile " + str(tile.ID), fg="black", bg="grey", relief="raised",
# bd=BORDER, highlightbackground="black",
# highlightthickness=HIGHLIGHT_THICKNESS)
button = customtkinter.CTkButton(canvas, text="Tile " + str(tile.ID), state='disabled')
posX, posY = tile.getPosXY(baseX + BORDER, BORDER)
canvas.create_window(posX, posY, window=button, height=tileHeight, width=tileWidth, anchor="nw")

Expand All @@ -1433,15 +1437,17 @@ def drawSchedule():
srcX, srcY = link.getSrcXY(baseX + BORDER, BORDER)
dstX, dstY = link.getDstXY(baseX + BORDER, BORDER)
if ii in link.mapping:
canvas.create_line(srcX, srcY, dstX, dstY, arrow=tkinter.LAST, fill="red")
canvas.create_line(srcX, srcY, dstX, dstY, arrow=tkinter.LAST, fill="gold")
else:
canvas.create_line(srcX, srcY, dstX, dstY, arrow=tkinter.LAST, fill="black")
canvas.create_line(srcX, srcY, dstX, dstY, arrow=tkinter.LAST, fill="white")

cycleLabel = tkinter.Label(canvas, text="Cycle " + str(ii))
# cycleLabel = tkinter.Label(canvas, text="Cycle " + str(ii))
cycleLabel = customtkinter.CTkLabel(canvas, text="Cycle " + str(ii) + " ",
font=customtkinter.CTkFont(size=FRAME_LABEL_LEVEL_2_FONT_SIZE, weight="bold", slant='italic'))
canvas.create_window(baseX + 280, GRID_HEIGHT + 10 + BORDER, window=cycleLabel, height=20, width=80)

baseX += GRID_WIDTH + MEM_WIDTH + LINK_LENGTH + 20
canvas.create_line(baseX - 5, INTERVAL, baseX - 5, GRID_HEIGHT, width=2, dash=(10, 2))
canvas.create_line(baseX - 5, INTERVAL, baseX - 5, GRID_HEIGHT, width=2, dash=(10, 2), fill="grey")


def clickTerminateMapping():
Expand Down Expand Up @@ -1968,8 +1974,7 @@ def create_test_pannel(master):
testPannel.columnconfigure(2, weight=1)
testPannelLabel = customtkinter.CTkLabel(testPannel, text='Verification ',
# width=100,
font=customtkinter.CTkFont(size=FRAME_LABEL_LEVEL_2_FONT_SIZE,
weight="bold", slant='italic'))
font=customtkinter.CTkFont(size=FRAME_LABEL_LEVEL_2_FONT_SIZE, weight="bold", slant='italic'))
testPannelLabel.grid(row=0, column=0, columnspan=3, ipadx=5, sticky="w")
testButton = customtkinter.CTkButton(testPannel, text="Run tests", # relief='raised',
command=clickTest,
Expand Down

6 comments on commit 3a22ea5

@yuqisun
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: adjust positions of tiles, split lines in mapping panel (overlap now when there're more rows/columns)

mapping panel  enable customtkinter style for tiles and links

@tancheng
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can highlight the mapped tile in each cycle with different color?

@yuqisun
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can highlight the mapped tile in each cycle with different color?

Better?

Color loops in ['#FFF113', '#FDDB76', '#F3993A', '#F2CB67', '#C13C33', '#FEEBCD', '#95D3D2', '#F9D3E3', '#C0C3C2', '#FFC501', '#FED52D', '#BBFF05', '#B3FF04', '#E6E6E6', '#75D561', '#FFAC73', '#C2FFFF']

mapping panel  highlight mapped tile with diff colors cycle0-1
mapping panel  highlight mapped tile with diff colors cycle2-3

@tancheng
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the entire tile be colored differently (instead of only the boarder)?

@yuqisun
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the entire tile be colored differently (instead of only the boarder)?

How about now?

mapping panel  highlight mapped tile with diff colors - entire tile button
mapping panel  highlight mapped tile with diff colors - entire tile button2-3

@tancheng
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's amazing. Pick anyone from the first 3 (as the last one cannot see links clearly), you can make the call as you are the owner.

Please sign in to comment.