Skip to content

Commit

Permalink
Revert "Enter API key via terminal if DISPLAY is unavailable"
Browse files Browse the repository at this point in the history
This reverts commit 7afd1a4.
  • Loading branch information
byrongibby committed Feb 6, 2025
1 parent 7afd1a4 commit 02eb986
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions R/econdata_credentials.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,29 @@ econdata_credentials <- function() {
call. = FALSE)
}
tkn <- NULL # Need to add global bindings for variables
if (Sys.getenv("DISPLAY") != "") {
token <- tcltk::tclVar("")
token <- tcltk::tclVar("")

tt <- tcltk::tktoplevel()
tcltk::tkwm.title(tt, "econdata.co.za credentials")
tkn.entry <- tcltk::tkentry(tt, textvariable = token)
tt <- tcltk::tktoplevel()
tcltk::tkwm.title(tt, "econdata.co.za credentials")
tkn.entry <- tcltk::tkentry(tt, textvariable = token)

reset <- function() tcltk::tclvalue(token) <- ""
reset.but <- tcltk::tkbutton(tt, text = "Reset", command = reset)
reset <- function() tcltk::tclvalue(token) <- ""
reset.but <- tcltk::tkbutton(tt, text = "Reset", command = reset)

submit <- function() {
tkn <- tcltk::tclvalue(token)
e <- parent.env(environment())
e$tkn <- tkn
tcltk::tkdestroy(tt)
}
submit.but <- tcltk::tkbutton(tt, text = "Submit", command = submit)
submit <- function() {
tkn <- tcltk::tclvalue(token)
e <- parent.env(environment())
e$tkn <- tkn
tcltk::tkdestroy(tt)
}
submit.but <- tcltk::tkbutton(tt, text = "Submit", command = submit)

tcltk::tkgrid(tcltk::tklabel(tt, text = "Enter Token Details"),
tcltk::tkgrid(tcltk::tklabel(tt, text = "Enter Token Details"),
columnspan = 2)
tcltk::tkgrid(tcltk::tklabel(tt, text = "API Token"),
tcltk::tkgrid(tcltk::tklabel(tt, text = "API Token"),
tkn.entry, pady = 10, padx = 10)
tcltk::tkgrid(submit.but, reset.but, pady = 10, padx = 50)
tcltk::tkgrid(submit.but, reset.but, pady = 10, padx = 50)

tcltk::tkwait.window(tt)
} else {
tkn <- readline("Enter API key: ")
}
tcltk::tkwait.window(tt)
return(tkn)
}

0 comments on commit 02eb986

Please sign in to comment.