将熊猫与pyqt5一起使用。单击按钮,请获取信息并将其加载到屏幕
因此,我有一个带有转换按钮的基本应用程序。目前,我的输入我正在接受一个URL并将其取代为表(数据[2])。在我的功能中,当我单击“转换”按钮时,我想将这些数据粘贴到我的窗口应用程序上,但是正在遇到此错误,
TypeError: arguments did not match any overloaded call:
QLabel(parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags()): argument 1 has unexpected type 'DataFrame'
QLabel(str, parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags()): argument 1 has unexpected type 'DataFrame'
我该如何工作?
import pandas as pd
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QVBoxLayout, QPushButton, QLabel, QLineEdit, QWidget
app = QApplication([])
WIN = QWidget()
layout = QVBoxLayout()
WIN.setWindowTitle('Table')
WIN.setGeometry(100,100,500,500)
#
url = input('Paste URL here: ')
data = pd.read_html(url)
date_grid = data[2]
print(date_grid)
# airlines = data['Airlines'].tolist()
# destinations = data['Destinations'].tolist()
text_box = QLineEdit()
label = QLabel('Paste a URL to convert to Excel')
convert_button = QPushButton('Convert')
layout.addWidget(label, alignment=Qt.AlignCenter)
layout.addWidget(text_box, alignment=Qt.AlignCenter)
layout.addWidget(convert_button, alignment=Qt.AlignCenter)
WIN.setLayout(layout)
text_box.setFixedHeight(35)
text_box.setFixedWidth(300)
def covert_btn():
text = QLabel(date_grid)
layout.addWidget(text, alignment=Qt.AlignCenter)
WIN.setLayout(layout)
convert_button.clicked.connect(covert_btn)
#
WIN.show()
app.exec_()
So I have a basic app with a convert button. Currently with my input I am accepting a URL and scrapping it for the tables (data[2]). In my function I want to paste this data on my window app when I click my 'convert' button but am getting this error
TypeError: arguments did not match any overloaded call:
QLabel(parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags()): argument 1 has unexpected type 'DataFrame'
QLabel(str, parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags()): argument 1 has unexpected type 'DataFrame'
How can I get this to work?
import pandas as pd
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QVBoxLayout, QPushButton, QLabel, QLineEdit, QWidget
app = QApplication([])
WIN = QWidget()
layout = QVBoxLayout()
WIN.setWindowTitle('Table')
WIN.setGeometry(100,100,500,500)
#
url = input('Paste URL here: ')
data = pd.read_html(url)
date_grid = data[2]
print(date_grid)
# airlines = data['Airlines'].tolist()
# destinations = data['Destinations'].tolist()
text_box = QLineEdit()
label = QLabel('Paste a URL to convert to Excel')
convert_button = QPushButton('Convert')
layout.addWidget(label, alignment=Qt.AlignCenter)
layout.addWidget(text_box, alignment=Qt.AlignCenter)
layout.addWidget(convert_button, alignment=Qt.AlignCenter)
WIN.setLayout(layout)
text_box.setFixedHeight(35)
text_box.setFixedWidth(300)
def covert_btn():
text = QLabel(date_grid)
layout.addWidget(text, alignment=Qt.AlignCenter)
WIN.setLayout(layout)
convert_button.clicked.connect(covert_btn)
#
WIN.show()
app.exec_()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Qlabel
需要String
带有普通文本
或html
。dataFrame
具有函数.to_string()
将其作为字符串(如在控制台中),并且它也具有
.to_html()
获得它AShtml
to_string()
to_html()
QLabel
needsstring
withplain text
or withHTML
.DataFrame
has function.to_string()
to get it as string (like in console),and it also has
.to_html()
to get it asHTML
to_string()
to_html()