-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:dougransom/unimacro
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|