Пустая строка, возвращенная из текста Tkinter - PullRequest
0 голосов
/ 05 августа 2020
• 1000 Я что-то не замечаю? Это доходит до моей функции, потому что "Эта кнопка была нажата!" распечатывает нормально.
from tkinter import *
from tkinter import ttk
from tkinter.filedialog import asksaveasfilename

style = ttk.Style()

root = Tk()
# root.withdraw() # Remove additional, blank window
root.title("aaaaaa")
# asksaveasfilename()

# GLOBAL VARIABLES
CELL_COL = "filler"
GOOGLE_SHEETS_FILENAME = "filler"
POINTS = "filler"


try:
    fp = open("input.txt", "w")
except:
    print("File to open does not exist!")

def retrieveInputForTextFile():
    inputValue = textBox.get("1.0", "end-1c")
    fp.write(inputValue)
    print(inputValue)

############ DEBUGING ##############

def retrieveInputForGlobalVars():
    someValue = spreadSheetTextBox.get("1.0", "end-1c")
    print(someValue)
    print("This button has been pressed!")
    global GOOGLE_SHEETS_FILENAME
    GOOGLE_SHEETS_FILENAME = someValue
    #print(globalVarName)

############ DEBUGING ##############


# Defining the global style (applied when no other style is defined)
style.configure('.', font='Arial 14', foreground='brown', background='black')
############ DEBUGING ##############
ttk.Label(root, text="What is the spreadsheet name?:").pack()
spreadSheetTextBox = Text(root, height=1, width=50)
spreadSheetTextBox.pack()

enterButton = ttk.Button(root, text='Enter', command=retrieveInputForGlobalVars)
enterButton.pack()
############ DEBUGING ##############

ttk.Label(root, text="Which column are we modifying?:").pack()
spreadSheetTextBox = Text(root, height=1, width=2)
spreadSheetTextBox.pack()

ttk.Label(root, text="How many points do you want to input:").pack()
spreadSheetTextBox = Text(root, height=1, width=2)
spreadSheetTextBox.pack()

### WORKING CODE ###
ttk.Label(root, text="Please input names of members who attended this meeting:").pack()
textBox = Text(root, height=30, width=20)
textBox.pack()
# Button Widget
submitButton = ttk.Button(root, text='Submit', command=retrieveInputForTextFile)
submitButton.pack()
# Defining a new style named danger
style.configure('danger.TButton', font='Times 12', foreground='red', padding=1)

root.mainloop()
fp.close()
root.destroy()
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...