Title: getopenfilename does not block when when using ipython inputhook/start_event_loop · Issue #7301 · ipython/ipython · GitHub
Open Graph Title: getopenfilename does not block when when using ipython inputhook/start_event_loop · Issue #7301 · ipython/ipython
X Title: getopenfilename does not block when when using ipython inputhook/start_event_loop · Issue #7301 · ipython/ipython
Description: This is very similar to #2380. However, since that issue, and related ones, are all closed, I'm presenting this similar issue, which has already been posted on Stack Overflow Note: If not using the native dialog option, all works fine. T...
Open Graph Description: This is very similar to #2380. However, since that issue, and related ones, are all closed, I'm presenting this similar issue, which has already been posted on Stack Overflow Note: If not using the...
X Description: This is very similar to #2380. However, since that issue, and related ones, are all closed, I'm presenting this similar issue, which has already been posted on Stack Overflow Note: If not using...
Opengraph URL: https://github.com/ipython/ipython/issues/7301
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"getopenfilename does not block when when using ipython inputhook/start_event_loop","articleBody":"This is very similar to #2380. However, since that issue, and related ones, are all closed, I'm presenting this similar issue, which has already been posted on [Stack Overflow](http://stackoverflow.com/questions/27625394/getopenfilename-does-not-block-when-when-using-ipython-inputhook-start-event-loo)\n\nNote: If not using the native dialog option, all works fine. This is just when using the native dialog.\n\nWhen trying to run Qt in iPython, using the inputhook and start_event_loop, to create non-blocking app, the function PyQt4.QtGui.QFileDialog.getOpenFileName does not allow for input. It pops up and immediately closes.\n\nThe code below demonstrates the behavior. If run through _main(), which starts the Qt eventloop normally, all works fine. Both the generic Dialog and FileDialog operate as expected.\n\nHowever, when run as\n\n```\n$ ipython\nIn [1]: import ipython_nonblock_example as nb\nIn [2]: nb_instance = nb.start_gui(nb.Example)\n```\n\nthe Dialog works as expected. But the FileDialog does the open/close behavior.\nVersions are: IPython 2.3.1, Qt 4.8, PyQt4 4.11.1,Python 2.7.5\n\nFile ipython_nonblock_example.py\n\n``` python\nimport sys\nfrom PyQt4 import QtGui, QtCore\n\nclass Example(QtGui.QMainWindow):\n def __init__(self):\n super(Example, self).__init__()\n\n self.initUI()\n\n def initUI(self):\n self.btn = QtGui.QPushButton('Dialog', self)\n self.btn.move(20, 20)\n self.btn.clicked.connect(self.showDialog)\n\n self.btn2 = QtGui.QPushButton('File', self)\n self.btn2.move(20,50)\n self.btn2.clicked.connect(self.showFile)\n\n self.le = QtGui.QLineEdit(self)\n self.le.move(130, 22)\n\n self.setGeometry(300, 300, 290, 150)\n self.setWindowTitle('Input dialog')\n self.show()\n\n def showDialog(self):\n text, ok = QtGui.QInputDialog.getText(self, 'Input Dialog',\n 'Enter your name:')\n\n if ok:\n self.le.setText(str(text))\n\n def showFile(self):\n file_name = str(QtGui.QFileDialog.getOpenFileName(parent=self, caption='Open file'))\n\n if file_name:\n self.le.setText(str(file_name))\n\ndef start_gui(ui, block=False):\n try:\n if not block \u0026 __IPYTHON__:\n from IPython.lib.inputhook import enable_gui\n app = enable_gui('qt4')\n else:\n raise ImportError\n except (ImportError, NameError):\n app = QtCore.QCoreApplication.instance()\n if app is None:\n app = QtGui.QApplication(sys.argv)\n\n ui_instance = ui()\n\n try:\n from IPython.lib.guisupport import start_event_loop_qt4\n start_event_loop_qt4(app)\n return ui_instance\n except ImportError:\n app.exec_()\n\ndef _main():\n start_gui(Example, block=True)\n\nif __name__ == '__main__':\n _main()\n```\n","author":{"url":"https://github.com/triccare","@type":"Person","name":"triccare"},"datePublished":"2014-12-23T22:13:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/7301/ipython/issues/7301"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ef03b01a-c317-7e99-69f1-a28dcc869042 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA70:3463DE:246B0ED:322CC58:6A4F481F |
| html-safe-nonce | 410f9d27ec2cef52e5142285652e877334d634a5368034662615ab4c41812edb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTcwOjM0NjNERToyNDZCMEVEOjMyMkNDNTg6NkE0RjQ4MUYiLCJ2aXNpdG9yX2lkIjoiODc1NjI4NjQ5ODI5MzEwNjcxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bd78c67c36a4ccd9b2eb184819da23bdec1aa59044ae0a190b7a73e4a66fb9d1 |
| hovercard-subject-tag | issue:52779244 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/ipython/ipython/7301/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f179c2dc5ccbb101cdc9573edefee7ad9f0aa279f613712b5c8b597e040d5a77/ipython/ipython/issues/7301 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f179c2dc5ccbb101cdc9573edefee7ad9f0aa279f613712b5c8b597e040d5a77/ipython/ipython/issues/7301 |
| og:image:alt | This is very similar to #2380. However, since that issue, and related ones, are all closed, I'm presenting this similar issue, which has already been posted on Stack Overflow Note: If not using the... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | triccare |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/ipython/ipython git https://github.com/ipython/ipython.git |
| octolytics-dimension-user_id | 230453 |
| octolytics-dimension-user_login | ipython |
| octolytics-dimension-repository_id | 658518 |
| octolytics-dimension-repository_nwo | ipython/ipython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 658518 |
| octolytics-dimension-repository_network_root_nwo | ipython/ipython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4b249b445842943ed31549e027f57a8ade9881ed |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width