mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-16 21:37:59 +08:00
* Fix Makefile whitespace and .PHONY use
* Fix Makefile filename
* Modularize Makefile into client and server Makefiles
Part of the reason that the Makefile in the root directory is a bit
complicated is that it tries to handle tasks that can be handled
separately in the client and server modules.
This commit pushes some of the make logic specific to each module into
their own makefiles and calls out to those makefiles from that in the
project root.
* Add auto-formatting to client and server modules
One thing that can make linting faster is auto-formatting. This commit
adds the yapf auto-formatting tool to the server module and uses
eslint's "fix" functionality to speed up the linting/formatting process.
* Add yapf for automatic code formatting
* Add a root test target that calls sub-tests
* Apply yapf to python files
* Do not duplicate npm commands, simply pass through
* Update documentation
* Do not shadow reserved word len
* Add general test target
* Fix make call in dev-env
* Use black instead of yapf
* Run flake8 from the root directory
* Revert "Apply yapf to python files"
This reverts commit cdca128a01.
* Apply black to python code
* Resolve lint errors resulting from black format
* Add explanation of server unit tests in dev guidelines
93 lines
2.8 KiB
Python
93 lines
2.8 KiB
Python
# flake8: noqa F403, F405
|
|
from cefpython3 import cefpython as cef
|
|
from PySide2.QtCore import *
|
|
from PySide2.QtGui import *
|
|
from PySide2.QtWidgets import *
|
|
|
|
from server.gui.utils import WINDOWS, LINUX
|
|
|
|
WindowUtils = cef.WindowUtils()
|
|
|
|
# OS differences
|
|
# noinspection PyUnresolvedReferences
|
|
CefWidgetParent = QWidget
|
|
|
|
|
|
class CefWidget(CefWidgetParent):
|
|
def __init__(self, parent=None):
|
|
super(CefWidget, self).__init__(parent)
|
|
self.parent = parent
|
|
self.browser = None
|
|
# TODO test without this on linux
|
|
self.hidden_window = None # Required for PyQt5 on Linux
|
|
self.show()
|
|
|
|
def focusInEvent(self, event):
|
|
# This event seems to never get called on Linux, as CEF is
|
|
# stealing all focus due to Issue #284.
|
|
if self.browser:
|
|
if WINDOWS:
|
|
WindowUtils.OnSetFocus(self.getHandle(), 0, 0, 0)
|
|
self.browser.SetFocus(True)
|
|
|
|
def focusOutEvent(self, event):
|
|
# This event seems to never get called on Linux, as CEF is
|
|
# stealing all focus due to Issue #284.
|
|
if self.browser:
|
|
self.browser.SetFocus(False)
|
|
|
|
def embedBrowser(self):
|
|
if LINUX:
|
|
self.hidden_window = QWindow()
|
|
window_info = cef.WindowInfo()
|
|
rect = [0, 0, self.width(), self.height()]
|
|
window_info.SetAsChild(self.getHandle(), rect)
|
|
# TODO better splash
|
|
self.browser = cef.CreateBrowserSync(window_info)
|
|
|
|
def getHandle(self):
|
|
if self.hidden_window:
|
|
# PyQt5 on Linux
|
|
return int(self.hidden_window.winId())
|
|
else:
|
|
return int(self.winId())
|
|
|
|
def moveEvent(self, _):
|
|
self.x = 0
|
|
self.y = 0
|
|
if self.browser:
|
|
if WINDOWS:
|
|
WindowUtils.OnSize(self.getHandle(), 0, 0, 0)
|
|
elif LINUX:
|
|
self.browser.SetBounds(self.x, self.y, self.width(), self.height())
|
|
self.browser.NotifyMoveOrResizeStarted()
|
|
|
|
def resizeEvent(self, event):
|
|
size = event.size()
|
|
if self.browser:
|
|
if WINDOWS:
|
|
WindowUtils.OnSize(self.getHandle(), 0, 0, 0)
|
|
elif LINUX:
|
|
self.browser.SetBounds(self.x, self.y, size.width(), size.height())
|
|
self.browser.NotifyMoveOrResizeStarted()
|
|
|
|
|
|
class CefApplication(QApplication):
|
|
def __init__(self, args):
|
|
super(CefApplication, self).__init__(args)
|
|
if not cef.GetAppSetting("external_message_pump"):
|
|
self.timer = self.createTimer()
|
|
|
|
def createTimer(self):
|
|
timer = QTimer()
|
|
timer.timeout.connect(self.onTimer)
|
|
timer.start(10)
|
|
return timer
|
|
|
|
def onTimer(self):
|
|
cef.MessageLoopWork()
|
|
|
|
def stopTimer(self):
|
|
# Stop the timer after Qt's message loop has ended
|
|
self.timer.stop()
|