如何组合多个模式进行匹配?(How to combine multiple Pattern for match?)
我想在
posts
目录中匹配扩展名为*.md
和*.tex
的文件。我不能使用
"posts/*" :: Pattern
的原因是因为posts目录中有文件*.tex.metadata
。 并且site
会对该文件给出错误。[ERROR] Hakyll.Web.readPandocWith: I don't know how to read a file of the type Binary for: posts/2017-06-02-tex.metadata
尝试以下代码并使用空匹配失败(没有html输出)。
match (fromList ["posts/*.md", "posts/*.tex"]) $ do route $ setExtension "html" compile $ pandocCompiler let postFiles :: Pattern postFiles = fromGlob "posts/*.md" `mappend` fromGlob "posts/*.tex" match postFiles $ do route $ setExtension "html" compile $ pandocCompiler
也许我应该使用
fromRegex
但我不知道如何为此编写正则表达式。非常欢迎加入学习资源。 文档缺乏样本。
I want to match files with extensions
*.md
and*.tex
inposts
directory.The reason I can't use
"posts/*" :: Pattern
is because there are files*.tex.metadata
in the posts directory. Andsite
will give error on that files.[ERROR] Hakyll.Web.readPandocWith: I don't know how to read a file of the type Binary for: posts/2017-06-02-tex.metadata
Try following code and fail with empty match (no html output).
match (fromList ["posts/*.md", "posts/*.tex"]) $ do route $ setExtension "html" compile $ pandocCompiler let postFiles :: Pattern postFiles = fromGlob "posts/*.md" `mappend` fromGlob "posts/*.tex" match postFiles $ do route $ setExtension "html" compile $ pandocCompiler
Maybe I should use
fromRegex
but I have no idea how to write regex for that.Addition learning resource is very much welcome. The documentation is lack of sample.
原文:https://stackoverflow.com/questions/44325251
最满意答案
这与python的垃圾收集有关 - 因为(几乎)很快就会引用一个对象而不再引用它,所以我想只要窗口没有被垃圾收集,这个过程就不会终止。
您可以尝试在结束时添加
del Programm.window
或类似的东西(这可能是一种更好的方法,但我从未编写过QT,所以我在这里无法帮助你)This has to do with python's garbage collecting - as (almost) soon an object isn't referenced anymore it destroys it, so I guess the process doesn't terminate as long as the window wasn't garbage-collected.
You can try to add at the end
del Programm.window
or something like that (there's probably a better way of doing this, but I never programmed QT myself so I can't help you here)
相关问答
更多-
感谢@ekhumoro,我发布了适用于此情况的回复,以防其他人遇到此问题。 在win2的代码中: def closeWindow(self): self.parent().show() self.close() 这是有效的,因为当win2被创建时,win1将自我传递给win2 Thanks to @ekhumoro, I'm posting the response that worked here in case anyone else has this issue. In the co ...
-
我认为你需要将点击“x”右上角按钮的事件与杀戮过程线相关联。 这个话题可能有帮助吗? PySide / PyQt检测用户是否试图关闭窗口 I think you need to link the event of clicking the "x" top right button with the killing process lines. This topic may be of help? PySide / PyQt detect if user trying to close window
-
你试过sys.exit(0)吗? (你需要import sys ,但你可能已经导入了它,因为pyqt sys.exit(app.exec_())需要它) 如果它不起作用,我相信你的问题来自其他地方。 Have you tried sys.exit(0) ? (You need import sys for this, but you probably imported it already as it is required for pyqt sys.exit(app.exec_())) If it doe ...
-
是的,我得到了解决方案,最初我试图在Linux中使用葡萄酒与python和qt4作为64位创建win应用程序,但当我在Windows操作系统中使用pyinstaller尝试相同的事情时,它创建了一个exe文件....(我仍然不知道之所以) Yeah i got the solution , initially i was trying to create win application in linux using wine with python and qt4 as 64bit but when i t ...
-
这与python的垃圾收集有关 - 因为(几乎)很快就会引用一个对象而不再引用它,所以我想只要窗口没有被垃圾收集,这个过程就不会终止。 您可以尝试在结束时添加del Programm.window或类似的东西(这可能是一种更好的方法,但我从未编写过QT,所以我在这里无法帮助你) This has to do with python's garbage collecting - as (almost) soon an object isn't referenced anymore it destroys it ...
-
PyQt为字符串提供了两种不同的API:您可以选择使用哪一个代码,如下所示: import sip sip.setapi('QString', 2) from PyQt4 import QtGui 导入PyQt4后,该API已设置且无法更改。 在Python 2上,它默认为版本1以实现向后兼容,但IPython需要API版本2.版本2是Python 3的默认值,PySide的API等同于版本2。 如果您在应用程序中使用了v1 API,则不能使用该应用程序中嵌入的IPython Qt控制台,除非将其移植到v ...
-
我在macOS Sierra上尝试了你的代码,它可以正常工作。 但是,我会提出一种不同的方法来解决您的问题。 你可以做的是在你的MainWindow类中实现showEvent()函数,只要显示一个小部件(使用.show()或.showMaximized() )就会执行该函数,并触发你的自定义插槽来打开QFileDialog 。 执行此操作时,您可以使用单次触发计时器以最小的延迟触发插槽:这背后的原因是,如果您只是从showEvent()打开对话框,您将看到对话窗口而不是MainWindow在它下面(因为QF ...
-
你的第二个问题回答了第一个问题。 重新实现的keyPressEvent方法调用close() ,它将QCloseEvent发送到窗口小部件。 随后,将使用该事件作为其参数调用窗口小部件的closeEvent 。 所以你只需要将按钮连接到小部件的close()插槽,一切都将按预期工作: btn.clicked.connect(self.close) Your second question answers the first question. The reimplemented keyPressE ...
-
如何解决PyQt和Py2exe应用程序启动错误和问题?(How to resolve PyQt and Py2exe application startup errors and issues?)[2022-02-15]
你应该发布你的setup.py所以我们可以看看它。 无论如何,这个效果的东西应该适用于你的py2exe setup.py。 您可能必须调整bundle_files和zipfile参数才能使用我们的设置。 确保将'insert qt path here'替换为QT dll的正确路径,并输入'a.dll','b.dll','c.dll'的实际QT dll名称,... setup.py: # USAGE: 'python setup.py py2exe' from distutils.core import se ... -
PyQt应用程序成功关闭,但进程没有被杀死?(PyQt application closes successfully, but process is not killed?)[2022-11-09]
这看起来像IDLE特有的问题。 python bug跟踪器上存在几个密切相关的问题(例如8093和12540 ),但它们现在已关闭并被解析为“已修复”。 由于您似乎使用的是旧版本的python(2.5),因此您应该能够通过升级来解决问题。 This looks like a problem specific to IDLE. There are several issues on the python bug tracker that are closely related (e.g. 8093 and 1 ...