Blender - How to hide object only in this new window which i creat
create a button in blender VIEW_3D_UI and if i click the button in UI they create a new window if the new window appear on the screen then i select the object and press the key = any. thay hide the object only in this window which i creat. not in whole blender only in this newly window
Code:
import bpy
render = bpy.context.scene.render
render.resolution_x = 640
render.resolution_y = 480
render.resolution_percentage = 100
prefs = bpy.context.preferences
prefs.view.render_display_type = "WINDOW"
bpy.ops.render.view_show("INVOKE_DEFAULT")
area = bpy.context.window_manager.windows[-1].screen.areas[0]
area.type = "VIEW_3D"
sorry for my bad english
Try adding this.
bpy.context.space_data.show_object_viewport_mesh = False
It hides mesh from view in the newly created window. For hiding others refer to these blender apis.
Related
I'm trying to create a windows app that shows weather like windows 10 widgets using Tkinter. The issue I ran into is that I cannot remove the window's border to make it look like a real widget.
Here's what it looks like and what I'd like to remove:
self.root.overrideredirect(1) kinda works but I still can minimize the window, which is what I do not want to be available.
That's what I want it to look and behave like:
To sum up:
How to disable window title and all of that on top properly?
How to move the window after, set the position of it on the screen?
I'm new to Python, any help is appreciated. Thank you all. Peace
To clarify: The app is supposed to be not affected by tab+alt (and other ways to minimize it) and be always on desktop, not on top of any other app, right on the desktop.
UPD
The thing I missed working around with win32gui is that I cannot get the handle the way I was trying to due to the fact that the code of getting the handle before the window itself was created (before mainloop) so root.wait_visibility() was the solution for me. After that I got the handle using EnumWindows and positioned my window the way I needed, finally disabling the border with root.overrideredirect. The suggested solutions will be tried as well. Thank you for help!
top-right corner of the desktop:
You can try this:
root.overrideredirect(1)
root.geometry('250x150+900+600')
#900+600 is x+y axis position of window
And for making close button like of widget you can make transparent frame in side, put button there and in command .destroy().
Edit
From TheLizzard's comment, visit here for further information. From there:
To make the window draggable, put bindings for (mouse clicks) and (mouse movements) on the window.
import tkinter
class Win(tkinter.Tk):
def __init__(self,master=None):
tkinter.Tk.__init__(self,master)
self.overrideredirect(True)
self._offsetx = 0
self._offsety = 0
self.bind('<Button-1>',self.clickwin)
self.bind('<B1-Motion>',self.dragwin)
def dragwin(self,event):
x = self.winfo_pointerx() - self._offsetx
y = self.winfo_pointery() - self._offsety
self.geometry('+{x}+{y}'.format(x=x,y=y))
def clickwin(self,event):
self._offsetx = event.x
self._offsety = event.y
win = Win()
win.mainloop()
You can use this for some part in top of the window rather then in whole window. By making new frame there implement it, to make your widget moveable.
And from second comment of TheLizzard, visit here for more information. From there:
If you want the window to stay above all other windows.
root.attributes("-topmost", True)
I'm a beginner in programing in Maya, and I want to create a new Window INSIDE the main UI of Maya. The ideal place is in the same place that the attribute editor. I know it's possible because XGen does that, but I really do not find how :'(
Like here !
You can create a window with maya.cmds scripting and make this window dockable in maya
https://help.autodesk.com/cloudhelp/2017/ENU/Maya-Tech-Docs/CommandsPython/dockControl.html
Using the dockControl example:
import maya.cmds as cmds
myWindow = cmds.window()
buttonForm = cmds.formLayout( parent = myWindow )
cmds.button( parent = buttonForm )
allowedAreas = ['right']
cmds.dockControl( area='right', content=myWindow, allowedArea=allowedAreas )
you can create any arbitrary window and enforce/allow it to dock at a specific location.
The above example will spawn and restrict 'myWindow' to the Right side of your UI, unless you undock it...
Extending the allowedAreas attribute gives more location options if you want to use them.
I have a maya python tool that is supposed to load turtle, set it as the renderer, and then bake vertex AO on the selected object. The whole thing works except that when the user first opens Maya, it won't actually initialize the first time. It doesn't create the "TurtleDefaultBakeLayer" node for the script to modify attributes on. The user has to manually open the render settings window and then click on the "TURTLE" tab next to the "Common" tab for it to bake anything. After that it works exactly how it should with or without that Render Settings window open.
My question is, how do I get a freshly opened maya to get Turtle to initialize and instantiate those components without the user needing to open the Render Settings window?
def initializeTurtle(self):
#Load Turtle
cmds.loadPlugin('Turtle')
#Set renderer
cmds.setAttr("defaultRenderGlobals.currentRenderer", "turtle", type="string")
For anyone that was curious about solving this problem without opening the render settings window, the only viable solution we could come up with was to manually create the nodes Turtle needed, instead of relying on its automatic instantiation.
def initializeTurtle(self):
#Load Turtle
pluginStatus = cmds.pluginInfo( "Turtle", q = True, l = True, n = True )
if pluginStatus == False:
cmds.loadPlugin( "Turtle")
#Create bake nodes
cmds.setAttr("defaultRenderGlobals.currentRenderer", "turtle", type="string")
tOptions = cmds.createNode ("ilrOptionsNode", name="TurtleRenderOptions")
tBakeLayer = cmds.createNode ("ilrBakeLayer", name="TurtleDefaultBakeLayer")
tbakeLayerMgr = cmds.createNode ("ilrBakeLayerManager", name="TurtleBakeLayerManager")
cmds.connectAttr(tOptions+".message", tBakeLayer+".renderOptions")
cmds.connectAttr(tBakeLayer+".index", tbakeLayerMgr+".bakeLayerId[0]")
I am having a problem with getting tkSimpleDialog to take focus over my fullscreen window GUI. I have a GUI that I am trying to use a dialog window to use as an admin password to close the GUI (like a kiosk mode app) using root.quit(). The problems with this are that the dialog does not come in front of the parent windows if the parent windows are fullscreen. Additionally, I would like to make the tkSimpleDialog go fullscreen as well.
Here is the code for how the dialog box is being called/created using the tkSimpleDialog.py in my program:
def check_admin_password():
# use askstring here to verify password.
pass_attempt = simpledialog.askstring("Verifying access","Please enter Admin password", parent=window, show="*")
if pass_attempt == "password":
root.quit() # used whatever your instance of Tk() is here in place of root.
admin_minimize_button = Button(window, text = "Administrator", command = check_admin_password, width=35, height=12)
admin_minimize_button.grid(row=4, column=0)
I am using the following code for the parent window and I believe there is something with the overrideredirect(True) that is affecting the focus of my dialog window:
qwindow = Toplevel(root) #renames Toplevel "popup" window frame to variable "qwindow"
qwindow.title('Mission Queue') #creates title on popup window
w, h = qwindow.winfo_screenwidth(), qwindow.winfo_screenheight() #aquires dimensions from display size
qwindow.geometry("%dx%d+0+0" % (w, h)) #sets window size to aquired dimensions
qwindow.overrideredirect(True) #removes top bar and exit button from parent window frame
I have tried editing the tkSimpleDialog.py file and adding an overrideredirect(True) line however that is not working. If more information is needed, let me know. Any advice would be much appreciated. Thanks in advance.
Due to my inability to figure out a solution using tkSimpleDialog, I attempted a different approach creating my own "dialog". Unfortunately, I was still unable to get the dialog to have the entry line take focus with the screen window being set to wm_attributes('-fullscreen', 'True') and overrideredirect(True). While it would have been better to have both work; for my purposes, it will work fine to just be fullscreen in my application without overrideredirect(True). For anyone with a similar issue or wanting to see more documentation on my progress, heres the link to my other forum post: (Tkinter Entry Widget with Overrideredirect and Fullscreen).
Thanks for the help!
I'm building a small python 3 tkinter program on windows (10). From a main window (root) I'm creating a secondary window (wdowViewer). I want it to be full screen (zoomed) on my secondary display. The code below works on my main setup with two identical screens. If I however take my laptop out of the dock and connect it to (any) external display, the new window only fills about 2/3 of the secondary display.
Two things to note:
- The laptop and external monitor have same resolution.
- The window is appropriately zoomed when overrideredirect is set to 0.
mon_primary_width = str(app.root.winfo_screenwidth()) # width of primary screen
self.wdowViewer = Toplevel(app.root) # create new window
self.wdowViewer.geometry('10x10+' + mon_primary_width + '+0') # move it to the secondary screen
self.wdowViewer.wm_state('zoomed') # full screen
self.wdowViewer.overrideredirect(1) # remove tool bar
app.root.update_idletasks() # Apply changes
After two days of experimenting I finally found a fix.
Consider the following example: Making a toplevel zoomed, works fine on any secondary display when using the following code:
from tkinter import *
# Make tkinter window
root = Tk()
sw = str(root.winfo_screenwidth())
Label(root, text="Hello Main Display").pack()
# Make a new toplevel
w = Toplevel(root)
w.geometry("0x0+" + sw + "+0")
w.state('zoomed')
w.overrideredirect(1)
Label(w, text='Hello Secondary Display').pack()
root.mainloop()
However, in my code I'm making a new Toplevel after running the mainloop command. Then, the issue arises. A code example with the issue:
from tkinter import *
# New Tkinter
root = Tk()
sw = str(root.winfo_screenwidth())
# Function for new toplevel
def new_wdow():
w = Toplevel(root)
w.geometry("0x0+" + sw + "+0")
w.state('zoomed')
w.overrideredirect(1)
Label(w, text='Hello Secondary Display').pack()
# Make button in main window
Button(root, text="Hello", command=new_wdow).pack()
root.mainloop()
Problem: The bug is only present if the DPI scaling in Windows is not set to 100%. Hence, there seems to be a bug in how tkinter handles the DPI scaling subsequent to running mainloop. It does not scale the window properly, but Windows is treating it as if it does.
Fix: Tell Windows that the app takes care of DPI scaling all by itself, and to not resize the window. This is achievable using ctypes. Put the following code early in your python script:
import ctypes
ctypes.windll.shcore.SetProcessDpiAwareness(2)
Hopefully others will find the solution helpful. Hopefully, someone may explain more of what is going on here!