I have several Mayavi plots that I am combining in a single window (along the lines of the documentation), and it would be much better if I could get rid of the toolbars in all of them. While it's possible to to right-click each of the toolbars to have them disappear, I would like to code them to disappear instead. A command like scene.hide_toolbar() would be ideal. I've dug around in the TraitsUI package a bit to no avail... anybody know how to make it go away?
You can use Handler to modify UI, the following code works with ETS_TOOLKIT=qt4. Add the DisableToolbarHandler class to the code multiple_mlab_scene_models.py, and show the UI by m.edit_traits(handler=DisableToolbarHandler()).
class DisableToolbarHandler(Handler):
def position(self, info):
for name in ["scene1", "scene2"]:
editor = info.ui.get_editors(name)[0]
editor._scene._tool_bar.setVisible(False)
m = MyDialog()
m.edit_traits(handler=DisableToolbarHandler())
The windows shows as:
Related
.Hi everyone,
I`m still pretty new to python so, bear with me.
I am trying to setup a custom UI Window in maya, with a custom camera.
For this i am using the panelLayout, modelPanel and modelEditor commands.
Now, it's working so far with one exception.
The flags i've set for the modelEditor seem to be ignored entirely and i dont know why.
So here is the code:
if cmds.window("myWindow", exists=True):
cmds.deleteUI('myWindow')
cmds.window("myWindow")
cmds.paneLayout(configuration="single", w=1000, h=500)
cmds.modelPanel()
cmds.modelEditor(modelPanel="modelPanel4", allObjects=False, polymeshes=True, imagePlane=True, displayAppearance="smoothShaded")
cmds.showWindow("myWindow")
I want only polyMeshes and imgagePlanes to show in this window, aswell as to have the displayAppearance set to "smoothShaded".
Nnothing else, including the grid, should be visible at this point.
but, everything show up in the window, as if i had'nt set a single flag.
any help is much appreciated
All the flags in modelEditor() work fine in Maya 2016.5 and Maya 2018. I've checked it.
import maya.cmds as cmds
if cmds.window("myWindow", exists=True):
cmds.deleteUI('myWindow')
cmds.window("myWindow")
cmds.paneLayout(configuration="single", w=1000, h=500)
cmds.modelPanel()
cmds.modelEditor(modelPanel="modelPanel4",
allObjects=False,
polymeshes=True,
imagePlane=False,
displayAppearance="smoothShaded")
cmds.showWindow("myWindow")
The problem might appear when you click myWindow or press any key. It'll show not perspective view (modelPanel4) but the other view (for instance camera1 view).
I'm using Gtk to build an application on Linux using Python 3. I'm trying to use a Gtk.HeaderBar. So far it's been working Ok, but it seems that I can't get it to expand it's child widgets. For example:
As you can see above, I've tried putting my Gtk.Entry into the Gtk.HeaderBar, but even with things like Gtk.Entry.set_hexpand(True) it simply refuses to expand. I've even tried putting it inside a Gtk.Box, expanding the Gtk.Box, then adding the Gtk.Entry inside that. Even when I set the Gtk.Entry as a custom title for the Gtk.HeaderBar, this happens:
What's causing this? How can I fix it?
Enabling hexpand only says that you want the widget to be allocated all the remaining space; it does not actually resize your widget. You want the halign property set to GTK_ALIGN_FILL (or whatever it's called in Python) in addition to hexpand.
Check the diagrams on this page for a visual explanation.
You can use Box instead of Headerbar with window.set_titlebar method
I'm writing a class to embed some common configurations of graphs in a wx Notebook tab, but I'm running into a strange issue. When I try to add wx.Panel with the FigureCanvas, instead it floats the figure in another window entirely.
The odd thing is, the graph window resizes when I resize the main window. The figure comes out the correct size, just not in the right window.
My code is here. I can't see what I'm doing wrong, I've embedded matplotlib in wx before, but never in a Notebook. I can get it to embed on a simple GUI by itself just fine, just not in the tabs.
Try:
Make GraphTab a wxPanel rather than a wxFrame
Set all GraphTab to have nb as the parent (currently your first one has self as the parent.
I'm not sure whether this is everything, but it's a start.
I am trying to build a GUI with wxPython to control a pretty stable, well-established model. The standard output of the model includes a series of plots to screen done via matplotlib. These plots are all OK if the model is run from the command line. If I run from my new GUI, however, they all show up, but I have no control over them: I can't click their respective "save" buttons; if they get covered up by other windows, they are "grayed out" when the blocking window is moved away. Things like that. If I close my GUI window, however, I get full control of my plots again. But this is no way to run this code.
I think my procedure is pretty standard. The bare outlines of the code are:
import wx
import model_code
class gui_for_model(wx.Frame):
# lots of stuff with hooks into model_code,
# including a "go" button that starts model_code running
#end of class
app=wx.App(False)
gm = gui_for_model()
app.MainLoop()
Anyone know what I should do differently? Thanks.
Here is a link to a site that has some demo code of using matplotlib with wxPython GUIs.
eli.thegreenplace.net/2008/08/01/matplotlib-with-wxpython-guis
Also this - matplotlib.org/faq/usage_faq.html talks about changing the backend.
And i found a package on pypi pypi.python.org/pypi/wxmplot/0.9.12
I am trying to rebuild the functionality of the desktop's "highlight to select" feature so that I can use it in my own app. When I say "highlight to select" I mean the selection box that shows up if you click and drag on your desktop (native to all main-stream OS).
I've been working for hours trying to recreate it, and simply can't find a way. I've tried PyGTK, Xlib for python, and a couple other weird hacks. All of which have their own problems that won't allow me to move forward.
I generally don't ask for straight up example code without providing some sort of starting point, but in this project I don't even know where to start. How would you do this?
Here's the requirements:
Must draw on the root window (or a transparent layer that "appears" to be the root)
Must return the coordinates of the selection (x, y, height width)
Update: Forgot some details.
I am using Ubuntu 10.10
I have dual monitors (though, I don't think that should matter)
I don't mind downloading any extra libraries that are necessary
I don't know if this is what you're looking for, but what if you created another window in your module, and have your code show it when you release drag? You could fetch the cursor's current position, and have it draw the window there.
This should help you get the mouse position on the root window.
So, your code may look a little like this (this is untested code!) I'm only showing the relevant portions of what goes inside __ init __.
def __init__(self):
...
#Some of your code here.
...
win = gtk.Window(gtk.WINDOW_TOPLEVEL)
#Note that I am creating a popup window separately.
popwin = gtk.Window(gtk.WINDOW_POPUP)
#I am setting "decorated" to False, so it will have no titlebar or window controls.
#Be sure to compensate for this by having another means of closing it.
popwin.set_decorated(False)
def ShowPopup():
#You may need to put additional arguments in above if this is to be an event.
#For sake of example, I'm leaving this open ended.
#Get the cursor position.
rootwin = widget.get_screen().get_root_window()
curx, cury, mods = rootwin.get_pointer()
#Set the popup window position.
popwin.move(curx, cury)
popwin.show()
def HidePopup():
#This is just an example for how to hide the popup when you're done with it.
popwin.hide()
...
#More of your code here.
...
#Of course, here is the code showing your program's main window automatically.
win.show()
A very simplistic approach, but it should give the appearance of what you're wanting.