Skip to content

Commit ae6cb8e

Browse files
horizontal & vertical on interleaving simulation
1 parent 5f34598 commit ae6cb8e

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

main.py

+29-9
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def start_normal_simulation(self, i, label):
339339
else:
340340
return "RESTART"
341341

342-
self.wait_in_the_middle(60)
342+
self.wait_in_the_middle(50)
343343

344344
return "FINISH"
345345

@@ -385,10 +385,19 @@ def button_normal_event(self) -> None:
385385

386386

387387
def start_interleaving_simulation(self, i, label):
388+
old_label = label
389+
old_text = label.cget("text")
390+
label.place_forget()
391+
392+
new_text = old_label.cget("text").replace("\n", " ")
393+
label = self.create_label(new_text)
394+
388395
# 0 - 0.5
389396
for j in range(1, abs(752 - self.x[i] -32), 6):
390397
if self.is_running:
391-
label.place(x=self.x[i] + j + 32, y=self.y_initial, width=self.y_label_width, height=self.y_label_height)
398+
label.place(x=self.x[i] + j + 32 - (get_widget_size(label)[0]//2), y=self.screenheight//2 - (get_widget_size(label)[1]//2), width=self.x_label_width, height=self.x_label_height)
399+
label.config(bg="yellow")
400+
self.wait_in_the_middle(80) if j == 1 else 0
392401
self.root.update()
393402
sleep(0.002)
394403
else:
@@ -400,25 +409,36 @@ def start_interleaving_simulation(self, i, label):
400409
# broken message
401410
if self.col_indicator[i]:
402411
label.place_forget()
403-
label = self.create_label(self.broken_col_message[i])
404-
label.place(x=self.x[i] + j + 32, y=self.y_initial, width=self.y_label_width, height=self.y_label_height)
405-
412+
new_broken_message = self.broken_col_message[i].replace("\n", " ")
413+
414+
label = self.create_label(new_broken_message)
415+
label.place(x=self.x[i] + j + 32 - (get_widget_size(label)[0]//2), y=self.screenheight//2 - (get_widget_size(label)[1]//2), width=self.x_label_width, height=self.x_label_height)
416+
label.config(bg="yellow")
417+
406418
# pop up info text
407419
self.pop_up_info_text(i)
408420

409421
self.wait_in_the_middle(75)
410422

411423

412424
# 0.5 - 1
413-
for k in range(j, 1000 - 200 -32, 6):
425+
last_iteration = (1100 - 200 - 32 - j) // 6
426+
x_coor_destination = [933, 986, 1039, 1092, 1145, 1198, 1251, 1304]
427+
for index, k in enumerate(range(j, 1100 - 200 - 32, 6)):
414428
if self.is_running:
415-
label.place(x=self.x[i] + k + 32, y=self.y_initial, width=self.y_label_width, height=self.y_label_height)
429+
label.place(x=self.x[i] + k + 32 - (get_widget_size(label)[0]//2), y=self.screenheight//2 - (get_widget_size(label)[1]//2), width=self.x_label_width, height=self.x_label_height)
416430
self.root.update()
417431
sleep(0.002)
432+
433+
if index == last_iteration:
434+
self.wait_in_the_middle(30)
435+
label.place(x=x_coor_destination[i], y=self.y_initial, width=self.y_label_width, height=self.y_label_height)
436+
label.config(bg="#F0F0F0", text=self.broken_col_message[i].upper())
437+
418438
else:
419439
return "RESTART"
420440

421-
self.wait_in_the_middle(60)
441+
self.wait_in_the_middle(50)
422442

423443
return "FINISH"
424444

@@ -515,7 +535,7 @@ def init_header(self):
515535
self.header.config(bg="white")
516536
self.header.place(y=56, width=self.screenwidth)
517537

518-
def create_label(self, text):
538+
def create_label(self, text: str):
519539
label = tk.Label(self.root, text=text.upper())
520540
label.config(font=(self.font_FiraCode, 20, "bold"))
521541
return label

0 commit comments

Comments
 (0)