为什么只有一个文本输入(没有任何按钮)的表单将被提交,而没有两个文本输入的表单将被提交?
示例:https://codesandbox.io/s/form-submitting-ztqpz?fontsize=14
答案 0 :(得分:0)
在每个表单上添加一个提交按钮(也很少输入),它既可以使用按钮,也可以按Enter键
from tkinter import *
from pandastable import Table, TableModel
class MainClass(Frame):
def __init__(self, parent=None):
self.parent = parent
Frame.__init__(self)
self.main = self.master
self.main.geometry('600x400+200+100')
self.main.title('Overview trading pairs')
f = Frame(self.main)
f.pack(fill=BOTH,expand=1)
df = TableModel.getSampleData()
n = list(df.columns)
pt = Table(f, dataframe=df, showtoolbar=0, showstatusbar=0)
pt.columncolors[n[4]] = '#dcf1fc'
pt.rowcolors[4] = '#dcf1fc'
pt.setRowColors(rows=1, clr='#dcf1fc')
pt.show()
return
app = MainClass()
#launch the app
app.mainloop()
答案 1 :(得分:0)
您可以通过多种方式做到这一点,
最好的方法是使用tabindex来防止标签到达此按钮-
import pandas as pd
import numpy as np
ef={'Date':['20.3.2019','21.3.2019','22.3.2019','24.3.2019','25.5.2019','29.6.2019','30.6.2019'],
'Quantity Bought':[342.0,2330.0,'nan','nan',344,'nan','nan'],
'Buy Price':[21.0,45.0,'nan','nan',22,'nan','nan'],
'Sell Quantity':['nan','nan',110,221,'nan',455,566],
'Sell Price':['nan','nan',56,21,'nan',29,30]}
ef=pd.DataFrame(ef)
ef.replace('nan', np.nan, inplace=True)
numberOfRows = len(ef.index)
el={'Date':[],
'Quantity':[],
'Price':[]}
el = pd.DataFrame(el)
row = 0
i = 0
while i < numberOfRows:
if ef.isnull().iat[row,1] != True:
adding = pd.DataFrame({"Date":[ef.iat[row,0]],
"Quantity":[ef.iat[row,1]],
"Price":[ef.iat[row,2]]})
el = el.append(adding, ignore_index=True)
i += 1
row += 1
else:
adding = pd.DataFrame({"Date": [ef.iat[row, 0]],
"Quantity": [ef.iat[row, 3]*(-1)],
"Price": [ef.iat[row, 4]]})
el = el.append(adding, ignore_index=True)
i += 1
row += 1
print(el)
您也可以隐藏按钮链接。或者您可以使用这样的Java脚本功能-
<input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;" tabindex="-1" />