Skip to content

Commit

Permalink
blacken all files
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesdelbeke committed Nov 10, 2022
1 parent a112b37 commit 2193176
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ dmypy.json

fake_bpy_modules*/
run_blender.ps1
test.py
test.py
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
recursive-include bqt *.png *.qss *.py
recursive-include bqt *.png *.qss *.py
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ python setup.py install
```


# Developers
# Developers

### Environment variables
- BQT_DISABLE_STARTUP if set, completely disable bqt
Expand All @@ -34,4 +34,4 @@ python setup.py install

### Supported Platforms
bqt is developed on Windows, but also supports Darwin (MacOS).
If you are a dev, add a PR for another OS.
If you are a dev, add a PR for another OS.
12 changes: 6 additions & 6 deletions bqt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ def load_os_module() -> object:
"""
operating_system = sys.platform
if operating_system == 'darwin':
if operating_system == "darwin":
from .blender_applications.darwin_blender_application import DarwinBlenderApplication

return DarwinBlenderApplication(sys.argv)
if operating_system in ['linux', 'linux2']:
if operating_system in ["linux", "linux2"]:
# TODO: LINUX module
pass
elif operating_system == 'win32':
elif operating_system == "win32":
from .blender_applications.win32_blender_application import Win32BlenderApplication

return Win32BlenderApplication(sys.argv)
Expand Down Expand Up @@ -79,11 +79,11 @@ def register():
setup bqt, wrap blender in qt, register operators
"""

if os.getenv('BQT_DISABLE_STARTUP'):
if os.getenv("BQT_DISABLE_STARTUP"):
return

# only start focus operator if blender is wrapped
if not os.getenv('BQT_DISABLE_WRAP', 0) == "1":
if not os.getenv("BQT_DISABLE_WRAP", 0) == "1":
bpy.utils.register_class(focus.QFocusOperator)

# append add_focus_handle before create_global_app,
Expand All @@ -106,7 +106,7 @@ def unregister():
Returns: None
"""
if not os.getenv('BQT_DISABLE_WRAP', 0) == "1":
if not os.getenv("BQT_DISABLE_WRAP", 0) == "1":
bpy.utils.unregister_class(focus.QFocusOperator)
if create_global_app in bpy.app.handlers.load_post:
bpy.app.handlers.load_post.remove(create_global_app)
Expand Down
6 changes: 3 additions & 3 deletions bqt/blender_applications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import sys
from .blender_application import BlenderApplication

if sys.platform == 'darwin':
if sys.platform == "darwin":
from .darwin_blender_application import DarwinBlenderApplication
if sys.platform in ['linux', 'linux2']:
if sys.platform in ["linux", "linux2"]:
# TODO: LINUX module
pass
elif sys.platform == 'win32':
elif sys.platform == "win32":
from .win32_blender_application import Win32BlenderApplication
12 changes: 6 additions & 6 deletions bqt/blender_applications/blender_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(self, *args, **kwargs):
# Blender Window
self._hwnd = self._get_application_hwnd()

if os.getenv('BQT_DISABLE_WRAP') == "1":
if os.getenv("BQT_DISABLE_WRAP") == "1":
self._blender_window = QWindow()
self.blender_widget = QWidget.createWindowContainer(self._blender_window)
else:
Expand Down Expand Up @@ -92,14 +92,14 @@ def _set_window_geometry(self):
For this reason it should be set on self.blender_widget.
"""

settings = QSettings('Tech-Artists.org', 'Blender Qt Wrapper')
settings = QSettings("Tech-Artists.org", "Blender Qt Wrapper")
settings.beginGroup(self._settings_key_window_group_name)

if settings.value(self._settings_key_full_screen, 'false').lower() == 'true':
if settings.value(self._settings_key_full_screen, "false").lower() == "true":
self.blender_widget.showFullScreen()
return

if settings.value(self._settings_key_maximized, 'false').lower() == 'true':
if settings.value(self._settings_key_maximized, "false").lower() == "true":
self.blender_widget.showMaximized()
return

Expand All @@ -125,7 +125,7 @@ def notify(self, receiver: QObject, event: QEvent) -> bool:
event.ignore()
import bpy

bpy.ops.wm.quit_blender({'window': bpy.context.window_manager.windows[0]}, 'INVOKE_DEFAULT')
bpy.ops.wm.quit_blender({"window": bpy.context.window_manager.windows[0]}, "INVOKE_DEFAULT")
return False

return super().notify(receiver, event)
Expand All @@ -137,7 +137,7 @@ def store_window_geometry(self):
For that reason the _blender_widget should be used.
"""

settings = QSettings('Tech-Artists.org', 'Blender Qt Wrapper')
settings = QSettings("Tech-Artists.org", "Blender Qt Wrapper")
settings.beginGroup(self._settings_key_window_group_name)
settings.setValue(self._settings_key_geometry, self.blender_widget.geometry())
settings.setValue(self._settings_key_maximized, self.blender_widget.isMaximized())
Expand Down
7 changes: 2 additions & 5 deletions bqt/blender_applications/darwin_blender_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class DarwinBlenderApplication(BlenderApplication):
"""
Darwin (MACOS) Implementation of BlenderApplication
"""

def __init__(self, *args, **kwargs):
# OSX Specific - Needs to initialize first
self._ns_window = self.__get_application_window() or None

super().__init__(*args, **kwargs)


def _get_application_hwnd(self) -> int:
"""
This finds the blender application window and collects the
Expand All @@ -44,7 +44,6 @@ def _get_application_hwnd(self) -> int:

return objc.pyobjc_id(self._ns_window.contentView())


@staticmethod
def _get_application_icon() -> QIcon:
"""
Expand All @@ -59,7 +58,6 @@ def _get_application_icon() -> QIcon:
icon_path = contents_path / "Resources" / "blender icon.icns"
return QIcon(str(icon_path))


@staticmethod
def _get_application_window() -> AppKit.NSApp.mainWindow:
"""
Expand All @@ -72,7 +70,6 @@ def _get_application_window() -> AppKit.NSApp.mainWindow:
ns_window.setSharingType_(AppKit.NSWindowSharingReadWrite)
return ns_window


def _on_focus_object_changed(self, focus_object: QObject):
"""
Args:
Expand All @@ -82,4 +79,4 @@ def _on_focus_object_changed(self, focus_object: QObject):
if focus_object is self.blender_widget:
self._ns_window.makeKey()
with bpy.context.temp_override(window=bpy.context.window_manager.windows[0]):
bpy.ops.bqt.return_focus('INVOKE_DEFAULT')
bpy.ops.bqt.return_focus("INVOKE_DEFAULT")
31 changes: 16 additions & 15 deletions bqt/blender_applications/win32_blender_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

def get_process_hwnds():
# https://stackoverflow.com/questions/37501191/how-to-get-windows-window-names-with-ctypes-in-python
user32 = ctypes.WinDLL('user32', use_last_error=True)
user32 = ctypes.WinDLL("user32", use_last_error=True)

def check_zero(result, func, args):
if not result:
Expand All @@ -23,49 +23,50 @@ def check_zero(result, func, args):
raise ctypes.WinError(err)
return args

if not hasattr(wintypes, 'LPDWORD'): # PY2
if not hasattr(wintypes, "LPDWORD"): # PY2
wintypes.LPDWORD = ctypes.POINTER(wintypes.DWORD)

WindowInfo = namedtuple('WindowInfo', 'title hwnd')
WindowInfo = namedtuple("WindowInfo", "title hwnd")

WNDENUMPROC = ctypes.WINFUNCTYPE(
wintypes.BOOL,
wintypes.HWND, # _In_ hWnd
wintypes.LPARAM, ) # _In_ lParam
wintypes.LPARAM,
) # _In_ lParam

user32.EnumWindows.errcheck = check_zero
user32.EnumWindows.argtypes = (
WNDENUMPROC, # _In_ lpEnumFunc
wintypes.LPARAM,) # _In_ lParam
wintypes.LPARAM,
) # _In_ lParam

user32.IsWindowVisible.argtypes = (
wintypes.HWND,) # _In_ hWnd
user32.IsWindowVisible.argtypes = (wintypes.HWND,) # _In_ hWnd

user32.GetWindowThreadProcessId.restype = wintypes.DWORD
user32.GetWindowThreadProcessId.argtypes = (
wintypes.HWND, # _In_ hWnd
wintypes.LPDWORD,) # _Out_opt_ lpdwProcessId
wintypes.LPDWORD,
) # _Out_opt_ lpdwProcessId

user32.GetWindowTextLengthW.errcheck = check_zero
user32.GetWindowTextLengthW.argtypes = (
wintypes.HWND,) # _In_ hWnd
user32.GetWindowTextLengthW.argtypes = (wintypes.HWND,) # _In_ hWnd

user32.GetWindowTextW.errcheck = check_zero
user32.GetWindowTextW.argtypes = (
wintypes.HWND, # _In_ hWnd
wintypes.LPWSTR, # _Out_ lpString
ctypes.c_int,) # _In_ nMaxCount
ctypes.c_int,
) # _In_ nMaxCount

def list_windows():
'''Return a sorted list of visible windows.'''
"""Return a sorted list of visible windows."""
result = []

@WNDENUMPROC
def enum_proc(hWnd, lParam):
if user32.IsWindowVisible(hWnd):
pid = wintypes.DWORD()
tid = user32.GetWindowThreadProcessId(
hWnd, ctypes.byref(pid))
tid = user32.GetWindowThreadProcessId(hWnd, ctypes.byref(pid))
length = user32.GetWindowTextLengthW(hWnd) + 1
title = ctypes.create_unicode_buffer(length)
user32.GetWindowTextW(hWnd, title, length)
Expand Down Expand Up @@ -113,4 +114,4 @@ def _on_focus_object_changed(self, focus_object: QObject):
if focus_object is self.blender_widget:
ctypes.windll.user32.SetFocus(self._hwnd)
with bpy.context.temp_override(window=bpy.context.window_manager.windows[0]):
bpy.ops.bqt.return_focus('INVOKE_DEFAULT')
bpy.ops.bqt.return_focus("INVOKE_DEFAULT")
44 changes: 22 additions & 22 deletions bqt/blender_stylesheet.qss
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ QCheckBox::indicator:unchecked:hover {
QComboBox {
background-color: #2c2c2c;
border: 1px solid #404040;
color: #d0d0d0;
color: #d0d0d0;
padding-left: 6px;
}
QComboBox:disabled {
background-color: #323232;
color: #8a8a8a;
}
QComboBox::down-arrow {
background-color: #2c2c2c;
background-color: #2c2c2c;
}
QComboBox::down-arrow:on {
background-color: #7e848e;
}
QComboBox::drop-down {
QComboBox::drop-down {
background-color: #202020;
}
QComboBox::on {
Expand All @@ -57,7 +57,7 @@ QComboBox QAbstractItemView {


QGroupBox {
border: 0px solid #373737;
border: 0px solid #373737;
background-color: #373737;
padding-top: 12px;
}
Expand All @@ -66,14 +66,14 @@ QGroupBox::title {
margin-top: 4px;
padding-left: 8px;
}


QHeaderView {
background-color: #3b3b3b;
background-color: #3b3b3b;
border: 0px transparent transparent;
}
QHeaderView:section {
background-color: #3b3b3b;
background-color: #3b3b3b;
border: 0px transparent transparent;
}

Expand Down Expand Up @@ -120,7 +120,7 @@ QProgressBar {
text-align: right;
}
QProgressBar::chunk {
background-color: #5680c2;
background-color: #5680c2;
border: 1px solid #373737;
}

Expand Down Expand Up @@ -161,8 +161,8 @@ QRadioButton::indicator:unchecked {
QRadioButton::indicator:unchecked:hover {
color: #f5f5f5;
}


QSpinBox {
background: #595959;
border: 1px solid #404040;
Expand All @@ -174,13 +174,13 @@ QSpinBox::down-button {
subcontrol-origin: control;
subcontrol-position: top left;
width: 13px;
height: 20px;
height: 20px;
}

QSpinBox::down-button:hover {
background:#6b6b6b
}
QSpinBox::down-arrow:hover {
QSpinBox::down-arrow:hover {
height: 20px;
}
QSpinBox::hover {
Expand All @@ -200,46 +200,46 @@ QSpinBox::up-button:hover {
QSpinBox::up-arrow:hover {
height: 20px;
}


QTableView QTableCornerButton:section {
background-color: #3b3b3b;
border: 1px solid #3b3b3b;
}


QTabWidget::pane {
background-color: #404040;
border-color: #373737;
border-style: solid;
border-style: solid;
border-width: 2px;
border-radius: 4px;
margin-left: 1x;
}
QTabBar::tab {
background-color: #373737;
border-style: solid;
border-width: 1px;
border-width: 1px;
border-top-color: #373737;
border-right-color: #373737;
border-left-color: #373737;
border-bottom-color: #373737;
padding: 5px;

}
QTabBar::tab:selected {
background-color: #424242;
border-style: solid;
border-width: 1px;
border-color: #373737;
border-color: #373737;
border-bottom-color: #424242;
}
QTabBar::tab:hover:!selected {
background-color: #343434;
color: #afafaf;
}
QTabBar::tab:!selected {
border-style: solid;
QTabBar::tab:!selected {
border-style: solid;
border-width: 1px;
background-color: #313131;
color: #d8d8d8;
Expand Down
1 change: 0 additions & 1 deletion bqt/dist/bqt_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ def register():

def unregister():
bqt.unregister()

Loading

0 comments on commit 2193176

Please sign in to comment.