我正在关注import sys
from PyQt5 import QtCore, QtWidgets, QtGui
class main(QtWidgets.QDialog):
def __init__(self):
super(main, self).__init__()
layout = QtWidgets.QVBoxLayout()
button = QtWidgets.QPushButton("menu", self)
menu = QtWidgets.QMenu(button)
menu.setWindowFlags(
menu.windowFlags() | QtCore.Qt.FramelessWindowHint
)
menu.setWindowFlags(
menu.windowFlags() | QtCore.Qt.NoDropShadowWindowHint
)
firstaction = QtWidgets.QAction("1st Item", self)
secondaction = QtWidgets.QAction("2nd Item", self)
thirdaction = QtWidgets.QAction("3rd Item", self)
fourthaction = QtWidgets.QAction("4th Item", self)
menu.addAction(firstaction)
menu.addAction(secondaction)
menu.addAction(thirdaction)
menu.addAction(fourthaction)
button.setMenu(menu)
menu.setStyleSheet("""
background-color:black;
border-radius:20;
border:1px solid white;"""
)
self.setMinimumSize(500, 500)
layout.addWidget(button)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
mw = main()
mw.show()
sys.exit(app.exec())
上对Creating a Custom CodecRegistry
有用的MongoDB documentation。我尝试实现自定义编解码器配置,如下所示:
object-relational-mapping
不幸的是,我遇到了错误:
CodecRegistry pojoCodecRegistry = fromRegistries(MongoClient.getDefaultCodecRegistry(),
fromProviders(PojoCodecProvider.builder().automatic(true).build()));
MongoClient mongoClient = new MongoClient("a.b.c", 2345);
MongoDatabase database =
mongoClient.getDatabase("rester").withCodecRegistry(pojoCodecRegistry);
MongoCollection<Record> collection = database.getCollection("cloudtrail",
Record.class);
Block<Record> printBlock = new Block<Record>() {
@Override
public void apply(final Record person) {
System.out.println(person);
}
};
collection.find().forEach(printBlock);
这是pojo(记录类)
org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class de.hpi.aws.model.events.Record.
我也看过类似的解决方案,例如对此GitHub Gist进行了解释。发生相同的错误,似乎有一些我想念的东西,但是我还不能识别出这个错误!