Следующий код работает нормально:
def next_available_row(wks):
str_list = list(filter(None, wks.col_values(2))) # fastest
return str(len(str_list)+1)
scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('TOOL-frtbddf4dc13.json', scope)
gc = gspread.authorize(credentials)
wks = gc.open("Log").sheet1
next_row = next_available_row(wks)
wks.update_acell("B{}".format(next_row), "111")
wks.update_acell("D{}".format(next_row), "222")
wks.update_acell("E{}".format(next_row), "333")
wks.update_acell("F{}".format(next_row), "444")
Я попытался включить этот код в кнопку, чтобы при нажатии кнопки моя программа проверяла флажок.Если флажок == true, приведенный выше код будет работать.Я не могу заставить его работать вообще, и я думаю, что это потому, что я не передаю / подключаю next_available_row (wks) должным образом.
Вот мои основные части:
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setEnabled(True)
class Window(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self, cList):
super().__init__()
self.setupUi(self)
self.cList = cList
self.Input_7.addItems(sorted(cList.keys()))
self.Input_7.activated[str].connect(self.onActivatedText)
@QtCore.pyqtSlot(str)
def onActivatedText(self, text):
self.Input_8.setText(self.cList[text][0])
self.Input_9.setText(self.cList[text][1])
self.Input_6.setText(self.cList[text][2])
self.Input_13.setText(self.cList[text][0])
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "TOOL V2.01"))
self.label_2.setText(_translate("MainWindow", "55"))
и, наконец, кнопка:
def printMessage(self):
ctypes.windll.user32.MessageBoxW(0, "File Created!", "File Created!", 1)
#lineEdits
tInput1 = (self.Input.displayText()) #this is where i grab my inputs and run my scripts.
Как вставить код API Google, чтобы он работал, когда янажать мою кнопку (printMessage)?