How to change just one side border width of a ttk.Entry?
As stated in my comment before, I'd use a stacked layout with the boxes in frames and the entries in these boxes. So there is no need for special styling. Access to the values within the ttk.Entries
gives a dictionary that contains tk.StringVar
objects, the keys are uppercase letters 'A'..'I' combined with numbers '1'..'9' like in spreadsheet applications:
import tkinter as tkfrom tkinter import ttkmainWin = tk.Tk()mainWin.title('Sudoku solver')mainFrame = ttk.Frame(mainWin, borderwidth=10)mainFrame.grid(column=1, row=1)# access to entries (of type tk.StringVar)values = {}for box_col in range(3): for box_row in range(3): box = ttk.Frame(mainFrame, borderwidth=1, relief='sunken') box.grid(column=box_col+1, row=box_row+1) for cell_col in range(3): for cell_row in range(3): v = tk.StringVar() # build spreadsheet key from overall column and row col = 'ABCDEFGHI'[3*box_col+cell_col] row = '123456789'[3*box_row+cell_row] key = col+row values[key] = v entry = ttk.Entry(box, width=3, justify='center', textvariable=v) entry.grid(column=cell_col+1, row=cell_row+1)# example for accessing the entriesvalues['A1'].set(1)values['G3'].set(7)values['E5'].set(int(values['A1'].get())+4)values['I9'].set(int(values['E5'].get())+4)mainWin.mainloop()
Under Windows 8.1, this will look this: