I am trying to create a config file that essentially updates the "look" of the page after a code has been entered. If the correct number has been entered, read the "Page2" part of the config file to update the background color and text. This is a small version of my code. I get the 'page' string to successfully update from 'page1' to 'page2' but the program does not re-read the config file with the 'page2' update
CONFIG FILE:
[page1]
line1 = This is the first line of the program
background = black
[page2]
line1 = This is now the second line
background = blue
PYTHON PROGRAM:
from tkinter import *
import keyboard
import tkinter.font as TkFont
from configparser import ConfigParser
config1 = ConfigParser()
config1.read("config1.ini")
updatePage = 1
page = "page" + str(updatePage)
line1 = config1.get(page, 'line1')
background = config1.get(page, 'background')
root = Tk()
root.title("Main Entry")
root.attributes('-fullscreen',True)
root.configure(background=background)
T1 = Label(root, text = line1, fg = 'white', wraplength = "1000", justify = 'left', bg=background, font = ('Consolas 16')).grid(row=0,column=0, padx=40, pady=5,sticky = 'nw')
e = Entry(root, width=120, borderwidth=0, bg= background, justify = 'left', fg = 'white', font = ('Consolas 16'), insertontime=500, insertofftime=500, takefocus=1)
e.grid(row=5, column=0, columnspan=5, padx=40, pady=0, sticky = 'nw')
e.focus_set()
print("global page is: ", page)
def enter():
global updatePage
global page
print("i'v entered")
current = e.get()
if current == '4565':
print("match")
updatePage += 1
page = "page" + str(updatePage)
print("page is: ", page)
e.delete(0, END)
config1.read
return
else:
return
print('ive exited')
check = root.bind('<Return>', lambda event:enter())
print("global page is: ", page)
root.mainloop()
I want each key in the config to be setup the same (page 1 has background, line1, page 2 has background, line2) then I can just update the config1.read info to reread the config file. I've tried separate configs, different methods. Just trying to avoid making a separate line for every key because the end goal is a lot of config info.
Split two line.
In line 39-43 Add this in
enter()function.Code:
Screenshot: