Last active
December 10, 2015 13:04
-
-
Save cr1901/c6267be973837606c5c9 to your computer and use it in GitHub Desktop.
PyQt4, 5, and quamash compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import atexit | |
import os | |
from quamash import QEventLoop, QtGui, QtCore | |
from pyqtgraph import dockarea | |
# import scanwidget | |
class MainWindow(QtGui.QMainWindow): | |
def __init__(self, app, server): | |
QtGui.QMainWindow.__init__(self) | |
self.exit_request = asyncio.Event() | |
def closeEvent(self, *args): | |
self.exit_request.set() | |
def save_state(self): | |
return bytes(self.saveGeometry()) | |
def restore_state(self, state): | |
self.restoreGeometry(QtCore.QByteArray(state)) | |
def main(): | |
app = QtGui.QApplication([]) | |
loop = QEventLoop(app) | |
asyncio.set_event_loop(loop) | |
atexit.register(loop.close) | |
# Create a window | |
win = MainWindow(app, None) | |
win.show() | |
# win.resize(win.sizeHint()) # Default is (200, 100) if sizeHint < (200 100). Force resize. | |
loop.run_until_complete(win.exit_request.wait()) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment