'Calculate Hat Trick Wins in a Matrix

I would like to have a script or formula to calculate the number of three consecutive "W" values on a row of 64 cells from left to right and display the result in a column labeled "Hat Tricks". The formula/script must be able to be copied to multiple other rows.

I have drafted an example sheet here.

The data is a matrix of wrestlers who compete against each other, and the win or loss is recorded in a matrix. The nature of the matrix ignores the cell where the wrestler cannot compete against themselves, thus this will need to be configured into the script/formula. Here is a quick example of what I mean, where x is a competition with the self and the numbers are wrestler IDs:

  1  2  3
1 x  L  L
2 W  x  L
3 W  W  x

I am just a hobbyist without a lot of coding knowledge. I am appreciative of any attention this post generates. Thanks for taking the time.



Solution 1:[1]

So, to understand how to do it, I made an example:

This is the first file (the main one) :

import tkinter as tk
from tkinter import *
import threading
import file2 as file2

def func(gui):
   # just some code around here

# start up the program
root = Tk()

# pass the root in the __init__ function from file2
mainGui = file2.file2Class(root)

# Start the new thread
theThread = threading.Thread(target=func, args=([mainGui]))
theThread.daemon = True
theThread.start()

# loop command
tk.mainloop()

And this is file2 :

import tkinter as tk
from tkinter import *

class file2Class:
    root = None
    def __init__(self, initialRoot):
        self.root = initialRoot
        self.createUI();

    def createUI(self):
        # This is an exit button
        tk.Button(
            self.root, 
            text="Exit",
            font = "Verdana 10 bold", 
            fg="red",
            command=self.root.destroy, # <- this is the exit command
            width=25,
            height=2).grid(row=0,column=0)

So, the most important thing is to make sure that you pass root in the args of the thread.

I hope I helped you!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 B. Bogdan