Left Column ”W” Second Button Opens Web Reverso German Verb Conjugation Python Code in Description

Published: 03 January 2023
on channel: Tonio FERENER-VARI
63
like

Playlist: Playlist: Python Tutorial Lessons to do Double Double Text Editor with Microsoft Text to Speech in English and Deutsch There is Python Code in the Description    • Python Tutorial  Lessons to do  Doubl...  

The code below
is also published in the description of the precedent movie.

The operand "greater or equal to one" is not allowed in the description.
The text "greater or equal to one" must be replaced in the code below

Python Lesson 12 Code

def executed_script_dir_path():
is necessary
to get the path of the executed script

executed_script_dir_path = lib_programname.get_path_executed_script()
os.chdir(os.path.dirname(executed_script_dir_path))
executed_script_dir_path = os.getcwd()
return executed_script_dir_path

app_executed_script_dir_path = StringVar()
app_executed_script_dir_path = executed_script_dir_path()

def text_set_text(text, obj):
obj.delete('1.0', END)
obj.insert(INSERT, text)

def open_to_read_and_insert_in_txt_obj(chosen_filename, obj):

if(chosen_filename != None):
if (chosen_filename.find('.txt') != -1):
isExist = os.path.exists(chosen_filename)
if (isExist):
f = open(chosen_filename, encoding ='utf-8')
s=f.read()
if (len(s) greater or equal to 1):
obj.delete('1.0', END)
obj.insert(END, s)
else:
text_set_text("\nThe file of\n\nthe default metadatum\n\ndoes not exist", obj)


filename = app_executed_script_dir_path + "\\t2_default_relative_filename.txt"
open_to_read_and_insert_in_txt_obj(filename, t2)

t2_askopenfilename
def t2_askopenfilename():

if (check_box_var.get() == 0):

t2_default_relative_filename.txt
stores manually updatable metadata
os_path_basename = "\\t2_default_relative_filename.txt"
else:
t2_relative_filename.txt
stores automatically updatable metadata
os_path_basename = "\\t2_relative_filename.txt"

s1 = app_executed_script_dir_path
s2 = os_path_basename

abs_of_default_or_prec_rel_fn = s1 + s2

f_read from
t2_default_relative_filename.txt
or t2_relative_filename.txt

is necessary
to build
the full absolute filename

dirname is the path of the filename
dirname can be extracted from full absolute filename

with open(abs_of_default_or_prec_rel_fn
, 'r', encoding='utf-8') as f:
f_read = f.read()

relative_filename = s1 + f_read
os.chdir(os.path.dirname(relative_filename))

os_path_basename = os.path.basename(relative_filename)
os_path_dirname = os.path.dirname(relative_filename)

chosen_filename = filedialog.askopenfilename(
filetypes=[("Text files","*.txt")],
initialdir=os_path_dirname,
title="T2 Open")

if(chosen_filename != None):
if (chosen_filename.find('.txt') !=-1):
os.chdir(os.path.dirname(chosen_filename))

open_to_read_and_insert_in_txt_obj(
chosen_filename, t2)

if (check_box_var.get() == 1):

n=len(app_executed_script_dir_path)
strg_path_of_rel_fn = chosen_filename[n:]

string to be saved in t1_relative_filename.txt
strg_path_of_rel_fn = strg_path_of_rel_fn.replace("/", "\\")
entry_set_text(strg_path_of_rel_fn, e1)

absolute filename (os_path_dirname + os_path_basename)
s1 = app_executed_script_dir_path

t2_rel_os_path_basename = "\\t2_relative_filename.txt"
strg_abs_flnm = s1 + t2_rel_os_path_basename

entry_set_text(strg_abs_flnm, e2)

if(chosen_filename != None):
os.chdir(os.path.dirname(chosen_filename))
with open(strg_abs_flnm, 'w', encoding='utf-8') as f:
f.write(strg_path_of_rel_fn)
f.close()

bt2_askopenfilename = Button(w, text ="Open", command = t2_askopenfilename)
bt2_askopenfilename.pack(padx=10, pady=2)
bt2_askopenfilename.place(x=348, y=196+22)


Watch video Left Column ”W” Second Button Opens Web Reverso German Verb Conjugation Python Code in Description online without registration, duration hours minute second in high quality. This video was added by user Tonio FERENER-VARI 03 January 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 6 once and liked it lik people.