The error you're encountering is due to the inconsistent use of tabs and spaces for indentation in your code. Python requires that you use either tabs or spaces consistently for indentation.
To fix this issue, you should reformat your code to use either tabs or spaces for indentation. Here are the steps to resolve the issue:
- Open your code in a text editor or IDE that can display tabs and spaces (e.g., PyCharm, VS Code).
- Replace all tabs with spaces. In most editors, you can do this by using the "Replace" or "Find and Replace" feature.
- Ensure that your editor is set to use 4 spaces for indentation (this is the standard for Python).
Here's your code reformatted to use 4 spaces for indentation:
import tkinter as tk
class App:
def __init__(self, root):
self.root = root
self.i = 0
self.j = 0
self.tablica = [["" for _ in range(4)] for _ in range(10)]
self.button_frame = tk.Frame(self.root)
self.button_frame.pack()
self.buttons = []
for k, text in enumerate(["ConceptArts", "ScrappedContent", "ARTS", "???"]):
btn = tk.Button(self.button_frame, text=text, command=lambda j=k: self.set_j(j))
btn.pack(side=tk.LEFT)
self.buttons.append(btn)
self.nav_frame = tk.Frame(self.root)
self.nav_frame.pack()
self.prev_button = tk.Button(self.nav_frame, text="Previous", command=self.prev_i)
self.prev_button.pack(side=tk.LEFT)
self.next_button = tk.Button(self.nav_frame, text="Next", command=self.next_i)
self.next_button.pack(side=tk.LEFT)
self.index_label = tk.Label(self.root, text="i: 0, j: 0")
self.index_label.pack()
def set_j(self, j):
self.j = j
self.index_label['text'] = f"i: {self.i}, j: {self.j}"
def next_i(self):
self.i = (self.i + 1) % len(self.tablica)
self.index_label['text'] = f"i: {self.i}, j: {self.j}"
def prev_i(self):
self.i = (self.i - 1) % len(self.tablica)
self.index_label['text'] = f"i: {self.i}, j: {self.j}"
root = tk.Tk()
app = App(root)
root.mainloop()
Now, your code should be free of the "Mixed use of tabs and spaces for indentation" error.