bpy.ops.screen.userpref_show() not Working #77000
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#77000
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Win 10
Graphics card: Nivida GForce RTX 2060
Blender Version
Broken: (version: 2.82a (sub 7), branch: master, commit date: 2020-03-12 05:06, hash:
375c7dc4ca
, type: Releasebuild date: 2020-03-12, 15:41:08)
Worked:: ?
Short description of error
Using "bpy.ops.screen.userpref_show()" in a script or add-on button doesn't display the Preference window at all.
I know the button works because I used another command and the command executed fine.
It also doesn't work in script editor either
Exact steps for others to reproduce the error
Got command from right-clicking and copying command off of preferences menu.
add "bpy.ops.screen.userpref_show()" to script or operator button
Added subscriber: @Pixelink
Added subscriber: @Calra
Can confirm, will wait for others to confirm it is a bug and not intended behavior.
This issue was referenced by
8e4c74292a
Added subscriber: @JulianEisel
Changed status from 'Needs Triage' to: 'Needs User Info'
I see why the operator wouldn't execute from the Python console. But it works fine if I execute it from a script or button.
Could you upload the failing code here? I have a fix ready but would like to know why it doesn't work from a button for you.
(For triagers: Please don't close this without checking with me first.)
This is the code to the operator.
As I stated earlier, I know the button works because I put different commands in. Eliminated if it was my coding in the panel of my add on.
INIT
PANEL (qtpanel.py)
row.operator('viewed3d.file_preferences', text="", icon="PREFERENCES")
OPERATOR (filefunc.py)
Here is a link to the entire addon if you want to download the zip
However, the version on the website has that button commented out
QuickTasks Addon
BTW... this is the error I get in the console...
Changed status from 'Needs User Info' to: 'Resolved'
The reason this did not work is because the operator uses the
invoke()
function, so that there's an event to take the cursor position from. This cursor position is used to determine the window position.So you were actually able to call the operator, but you had to call it in the invoke context:
bpy.ops.screen.userpref_show('INVOKE_DEFAULT')
.We can however get the cursor position differently and always use the
execute()
function then, which is what I've done now.Also, since I've seen this mistake a few times recently: You don't need to create an operator in your example.
screen.userpref_show()
already is an operator and it can assigned to a button directly, e.g.layout.operator("screen.userpref_show")
.Okay... I will give it a try... Thanks
Cool, it fixes
info_log_show()
and others as well, was about to ask.Added subscriber: @Harley
Any idea why?
I can understand why we position our little "OK?" alerts close to the mouse pointer, but I can't see why the positioning of new windows would want to be influenced by the position of the mouse when you invoked it. You'd think we'd just want to initially center a new window using the bounds of the previous one. And then you wouldn't need an xy for WM_window_open_temp() and so don't need to use invoke.
If you look at that positioning logic as it is now it seems jankey anyway and would generally get you a left position that is off the screen and would just be corrected by the following wm_window_check_position(). Which is why Preferences is almost always hugging the left side of the monitor. The File Browser only centers nicely because it doesn't actually use the mouse position at all but just pretends the mouse is at screen center instead.
I'm fine with discussing and possibly changing that. I thought about it as well but didn't want to do design changes like that without discussing first. The only reason I changed code was that there was a simple solution, so it was quick to address.
Thinking about it though, I actually find it quite "smart" that Blender places the window under your cursor. If you open the Preferences, it's usually with the intend to interact with it immediately. If it opened at the center you have to move the mouse to it first. But Blender knows where your mouse is, it can just place the window under your cursor and you can skip that part.
Maybe having a predictable window position is more important than this supposed, tiny quality of life improvement.
IIRC for the File Browser we decided to center it always, because you'd often trigger it from a more centered position and it would just look slightly out of place then. For some reason its default size or aspect ratio also made it feel odd if placed under the cursor.
Anyway, these are just my current thoughts on this. It's all up for debate.