I have a task, which is to make an update window in Tkinter) To make an update at first, i have to choose 3 files, which exactly contain an update and they must be shown in text containers) And then press the 'Update' button, which will automatically open these 3 files and an update will happen) Help please
My code:
import tkinter
from tkinter import *
from tkinter import filedialog as fd
root = Tk()
root.iconbitmap('/Users/Rostyslav Levytskyi/Downloads/logo_orange.ico')
root.title('MS4Bike')
root.geometry('800x580')
root.geometry('+200+100')
root.resizable(width=False, height=False)
root.configure(bg='#AEC09A')
# blue top line
color_text_top = Label(
bg='blue',
height=3
)
color_text_top.pack(fill=X)
text_top = Label(
text='Update Generator',
fg='white',
bg='blue',
font='Arial 12'
)
text_top.place(height=40, x=15, y=4)
# first label
label1 = tkinter.Label(
text="Programmodner auswählen(ms4bikeHost)",
bg="#AEC09A",
font=('Arial', 10, 'bold')
)
label1.place(x=25, y=125)
# first button
def open_text_file1():
# file type
filetypes = (
('text files', '*.txt'),
('All files', '*.*')
)
# show the open file dialog
f = fd.askopenfilename(filetypes=filetypes)
text_first.insert('1.0', f)
open_button1 = Button(
root,
bd=0,
relief=GROOVE,
text='Ändern',
bg="#c0cfaf",
width=20,
height=2,
command=open_text_file1
).place(x=600, y=147)
# second label
label2 = tkinter.Label(
text="Speicherort für Update-Datei auswählen",
bg="#AEC09A",
font=('Arial', 10, 'bold'),
)
label2.place(x=25, y=250)
# second button
def open_text_file2():
# file type
filetypes = (
('text files', '*.txt'),
('All files', '*.*')
)
# show the open file dialog
f = fd.askopenfilename(filetypes=filetypes)
# read the text file and show its content on the Text
text_second.insert('1.0', f)
open_button2 = Button(
root,
bd=0,
relief=GROOVE,
text='Ändern',
bg="#c0cfaf",
width=20,
height=2,
command=open_text_file2
).place(x=600, y=272)
# third label
label3 = tkinter.Label(
text="Schlüsseldatel auswählen",
bg="#AEC09A",
font=('Arial', 10, 'bold'),
)
label3.place(x=25, y=375)
# third button
def open_text_file3():
# file type
filetypes = (
('text files', '*.txt'),
('All files', '*.*')
)
# show the open file dialog
f = fd.askopenfilename(filetypes=filetypes)
# read the text file and show its content on the Text
text_third.insert('1.0', f)
open_button3 = Button(
root,
bd=0,
relief=GROOVE,
text='Ändern',
bg="#c0cfaf",
width=20,
height=2,
command=open_text_file3
).place(x=600, y=397)
# file name fields
text_first = Text(
font='Arial 14',
highlightthickness=1,
highlightcolor='black',
highlightbackground='black'
)
text_first.place(x=20, y=150, height=33, width=520)
text_second = Text(
font='Arial 14',
highlightthickness=1,
highlightcolor='black',
highlightbackground='black'
)
text_second.place(x=20, y=275, height=33, width=520)
text_third = Text(
font='Arial 14',
highlightthickness=1,
highlightcolor='black',
highlightbackground='black'
)
text_third.place(x=20, y=400, height=33, width=520)
# update button
tkinter.Button(
bd=0,
relief=GROOVE,
text='Update erstellen',
bg="#c0cfaf",
width=93,
height=3,
font=('Arial', 10, 'bold'),
).place(x=20, y=490)
tkinter.mainloop()