2
$\begingroup$

When developing scripts for blender, I regularly have to restart blender and the console window defaults to my main monitor, behind the blender window.

I'm starting with "-con" startup parameter.

Can I adjust the default position so it opens on my secondary monitor?

$\endgroup$
1
  • $\begingroup$ Using con flag I assume you are on windows. An option is to start blender, via command line, from a terminal (location of your choosing) and move blender window with a window manager like ewmh in a start up script. $\endgroup$
    – batFINGER
    Jan 13, 2020 at 10:23

2 Answers 2

1
$\begingroup$

thanks for pointing me in the right direction!

I've solved it using a slightly different approach (using pywin32), but here it is:

import win32gui

def _windowEnumerationHandler(hwnd, resultList):
    '''Pass to win32gui.EnumWindows() to generate list of window handle,
    window text, window class tuples.'''
    resultList.append((hwnd,
                       win32gui.GetWindowText(hwnd),
                       win32gui.GetClassName(hwnd))) 

windows = []
win32gui.EnumWindows(_windowEnumerationHandler, windows)

for w in windows:
    if w[1] == 'blender':
        win32gui.MoveWindow(w[0], 2650, 3, 1200, 600, True)

def register():
    return

this is specific to my setup of course, but should be easy enough to tweak for others

$\endgroup$
6
  • $\begingroup$ Good one, instead of a long comment re ewmh added another answer which may be of interest to others. Finding the terminal window that blender was opened from has me stumped on a linux system.. $\endgroup$
    – batFINGER
    Jan 13, 2020 at 16:08
  • $\begingroup$ I tried ewmh, but couldn't get it to work on windows quickly. thats why I switched to pywin32. thanks for your answer! $\endgroup$
    – Markus
    Jan 13, 2020 at 16:14
  • $\begingroup$ I tried windows,... :D.. Cheers. $\endgroup$
    – batFINGER
    Jan 13, 2020 at 16:17
  • $\begingroup$ interesting... when I try it I get the following : File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\python\lib\site-packages\Xlib\support\unix_connect.py", line 31, in <module> import fcntl ModuleNotFoundError: No module named 'fcntl' $\endgroup$
    – Markus
    Jan 13, 2020 at 16:22
  • $\begingroup$ Ooops.. forgot to add the display flush, or nothing appears to happen. $\endgroup$
    – batFINGER
    Jan 13, 2020 at 16:26
1
$\begingroup$

ewmh

The lightweight ewmh window manager module, used to be bundled with blender python, may not be any more, anyhow instead of a long comment under your answer, here is similar using ewmh on linux crunched into blenders python console.

>>> import ewmh
>>> wm = ewmh.EWMH()
>>> bwin = wm.getActiveWindow()
>>> bwin.get_wm_class()
('Blender', 'Blender')

>>> bwin.get_wm_name()
'Blender'

>>> for w in wm.getClientListStacking():
...     w.get_wm_name(), w.get_wm_class()
...     
('Desktop', ('desktop_window', 'Nautilus'))
('Settings', ('gnome-control-center', 'Gnome-control-center'))
('operator_simple.py', ('NeovimGtk', 'NeovimGtk'))
('batfinger@shitbox2: ~/blender-git', ('gnome-terminal-server', 'Gnome-terminal'))
('batfinger@shitbox2: ~/blender', ('gnome-terminal-server', 'Gnome-terminal'))
('scripting - can the system console window default position be adjusted? - Blender Stack Exchange - Mozilla Firefox', ('Navigator', 'Firefox'))
('Blender', ('Blender', 'Blender'))

>>> wm.setMoveResizeWindow(
setMoveResizeWindow(self, win, gravity=0, x=None, y=None, w=None, h=None)
Set the property _NET_MOVERESIZE_WINDOW to move or resize the given
window. Flags are automatically calculated if x, y, w or h are defined.
:param win: the window object
:param gravity: gravity (one of the Xlib.X.*Gravity constant or 0)
:param x: int or None
:param y: int or None
:param w: int or None
:param h: int or None
>>> wm.setMoveResizeWindow(bwin, 0, 10, 10, 1000, 599)
>>> wm.display.flush()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .