Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dougransom/unimacro
Browse files Browse the repository at this point in the history
  • Loading branch information
quintijn committed Aug 8, 2024
2 parents 6ed30e5 + 5803c3d commit 49f660a
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/unimacro/UnimacroGrammars/rememberdialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""template for _folders grammar, remember function.
This template is filled with the actual values and fired. It asks for a spoken form to "remember a given file", this value
is put in the _folders.ini config file.
"""
#pylint:disable=W0621
import time
import PySimpleGUI as sg
from dtactions.unimacro import inivars

prompt = """Remember in Unimacro _folders grammar""" # readable text
text = """Remember folder "C:/Users/Gebruiker/Music" for future calling?
Please give a spoken form for this folder and choose OK; or Cancel...""" # input text, the key of the
inifile = "C:/Users/Gebruiker/Documents/unimacro_clean_start/enx_inifiles/_folders.ini"
section = "folders"
value = "C:/Users/Gebruiker/Music"
title = "test"
default = "Music"
pausetime = 3 # should be replaced by 0 or a positive int value



def InputBox(text, prompt, title, default):
"""the dialog, which returns the wanted spoken form"""
layout = [[sg.Text(prompt)],
[sg.InputText(default)],
[sg.OK(), sg.Cancel()]]

window = sg.Window(title, layout)

_event, values = window.read()
window.close()

return values[0]

if __name__ == "__main__":
result = InputBox(text, prompt, title, default)
if result:
key = result
ini = inivars.IniVars(inifile)
ini.set(section, key, value)
ini.write()
print(f'Wrote "{key} = {value}" to inifile')
print('Call "edit folders" to edit or delete')
else:
print("Action canceled, no change of ini file")
# if pausetime is given, launch as .py, otherwise launch as .pyw:
if pausetime:
# print "sleep: %s"% pausetime
time.sleep(pausetime)

0 comments on commit 49f660a

Please sign in to comment.