At first my running system:
I use Windows 8 Pro and Mayavi 4.3 from the repository together with wxPython 2.9.4.0 at Python 2.7.4 but also had the same issue with mayavi 4.2.1 from the EPD package...
As I try to embedd mayavi into a notebook panel I get some problems with the UI. Even in the demo file from mayavi I got the same strange behavior of external frames generated by mayavi.
So using the settings button a the settings window opens. Also the scene reacts on the parameters I changed using the settings. But after clicking OK or chancel the window does not close. And python gives back several error messages. A simular behavior was there as i used the pipeline by implenting mlab.show_pipeline() command.
This behaivior is could be found on the sample from the enthought web page too.
Here you can see my error message after trying to click OK in the settings frame of the enthougth example:
C:\my_directory\>python wx_embedding.py
C:\Python27\lib\site-packages\enthougth_development_mayavi_git\traitsui\traitsui\wx\toolkit.py:35: wxPyDeprecationWarning: Using deprecated class PySimpleApp.
_app = wx.PySimpleApp()
wx_embedding.py:63: wxPyDeprecationWarning: Using deprecated class PySimpleApp.
app = wx.PySimpleApp()
Traceback (most recent call last): File "C:\Python27\lib\site-packages\enthougth_development_mayavi_git\traitsui\traitsui\wx\ui_live.py", line 360, in _on_ok
self.close( wx.ID_OK )
File "C:\Python27\lib\site-packages\enthougth_development_mayavi_git\traitsui\traitsui\wx\ui_live.py", line 320, in close
ui.finish()
File "C:\Python27\lib\site-packages\enthougth_development_mayavi_git\traitsui\traitsui\ui.py", line 264, in finish
self.reset( destroy = True )
File "C:\Python27\lib\site-packages\enthougth_development_mayavi_git\traitsui\traitsui\ui.py", line 304, in reset
editor.dispose()
File "C:\Python27\lib\site-packages\enthougth_development_mayavi_git\traitsui\traitsui\wx\instance_editor.py", line 208, in dispose
self._ui.dispose()
File "C:\Python27\lib\site-packages\enthougth_development_mayavi_git\traitsui\traitsui\ui.py", line 237, in dispose
self.finish()
File "C:\Python27\lib\site-packages\enthougth_development_mayavi_git\traitsui\traitsui\ui.py", line 264, in finish
self.reset( destroy = True )
File "C:\Python27\lib\site-packages\enthougth_development_mayavi_git\traitsui\traitsui\ui.py", line 318, in reset
toolkit().destroy_children( self.control )
File "C:\Python27\lib\site-packages\enthougth_development_mayavi_git\traitsui\traitsui\wx\toolkit.py", line 474, in destroy_children
control.DestroyChildren()
File "C:\Python27\lib\site-packages\wx-2.9.4-msw\wx\_core.py", line 9203, in DestroyChildren
return _core_.Window_DestroyChildren(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "GetEventHandler() == this" failed at . .\..\src\common\wincmn.cpp(468) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed
Thanks in advance
Mayvi is not compatible with wx 2.9.
More info here: https://support.enthought.com/entries/22601196-wxPython
Please use enpkg to revert to wx 2.8 which ships with EPD.
At least this particular exception can be solved with the changes associated with this PR: https://github.com/enthought/traitsui/pull/108. I don't know about Mayavi and the rest of the stack yet, but that change will at least get traitsui working with wxPython 2.9.
Related
More problems with my lovely custom Progress class moving on to wx python 3 (see wx python 3.0.2 classic SetFocus blows for part I)
This:
def setCancel(self, enabled=True):
cancel = self.dialog.FindWindowById(wx.ID_CANCEL)
cancel.Enable(enabled)
used to work just fine in 2.8.12.1 unicode, while crashes in 3.02 with:
Traceback (most recent call last):
File "bash\balt.py", line 419, in <lambda>
if onButClick: self.Bind(wx.EVT_BUTTON, lambda __event: onButClick())
File "bash\balt.py", line 1565, in _conversation_wrapper
return func(*args, **kwargs)
File "bash\basher\patcher_dialog.py", line 204, in PatchExecute
progress.setCancel(False)
File "bash\balt.py", line 1317, in setCancel
cancel.Enable(enabled)
AttributeError: 'NoneType' object has no attribute 'Enable'
self.dialog is a wx.ProgressDialog. From what I read here in How to override the “Cancel” button event of a ProgressDialog?
I suspect the native widget won't allow you to access the Cancel button at all, but I'm not sure.
and from the answer by #RobinDunn to my previous question:
On Windows the ProgressDialog [...] has no native window handle, and most non-ProgressDialog-specific APIs like SetFocus will not work.
(emphasis mine)
Does this mean that I cant't disable the cancel button of a progress dialog anymore ?
Okay, first of all I don't know what is the actual problem here so I couldn't come up with a more accurate title. Maybe some of you can edit it to make it accurate
The following is the minimalised code to reproduce the problem I'm having.
from traybar import SysTrayIcon
from cal import Calendar
import Tkinter
class Add():
def __init__(self,master):
Calendar(master).pack()
def add(systray):
root = Tkinter.Tk()
Add(root)
root.mainloop()
SysTrayIcon("abc.ico","abc", (('Add',None, add), ) ,default_menu_index=0).start()
The cal and the trabar are these files http://tkinter.unpythonic.net/wiki/TkTableCalendar and https://github.com/Infinidat/infi.systray/blob/develop/src/infi/systray/traybar.py respectively.
If you run this, it will make a icon in the system tray of a windows machine with the options Add and Quit. clicking on the app opens up the calender, no problem. Close the calender and click on the Add again. But this time it doesn't open the calendar and throws the following error
`
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 314, in 'calling callback function'
File "C:\Users\Koushik Naskar\AppData\Roaming\Python\Python27\site-packages\traybar.py", line 79, in WndProc
self._message_dict[msg](hwnd, msg, wparam.value, lparam.value)
File "C:\Users\Koushik Naskar\AppData\Roaming\Python\Python27\site-packages\traybar.py", line 276, in _command
self._execute_menu_option(id)
File "C:\Users\Koushik Naskar\AppData\Roaming\Python\Python27\site-packages\traybar.py", line 283, in _execute_menu_option
menu_action(self)
File "C:\Users\Koushik Naskar\Desktop\So\temp.py", line 11, in add
Add(root)
File "C:\Users\Koushik Naskar\Desktop\So\temp.py", line 7, in __init__
Calendar(master).pack()
File "C:\Users\Koushik Naskar\Desktop\So\cal.py", line 66, in __init__
state='disabled', browsecommand=self._set_selection)
File "C:\Python27\lib\lib-tk\tktable.py", line 118, in __init__
Tkinter.Widget.__init__(self, master, 'table', kw)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 2090, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: invalid command name "table"
`
This problem only appears when I use SysTrayIcon with the Calendar.Instead of Calendar if you use simple Tkinter Button or Label etc. this error doesn't appear. Also I can use the Calendar widget normally (without the SysTrayIcon ) in a usual Tkinter GUI as many times as I want, no error occur there. Now I don't have any clue about whats happenning here and how to fix this. What problem does SysTrayIcon have with Calendar and Why the error doesn't happen the first time I open the GUI? Please help.
TkTableCalendar requies the tktable module, which you have installed in lib-tk (3rd party modules usually go into lib/site-packages) as indicated by this part of the traceback.
File "C:\Python27\lib\lib-tk\tktable.py", line 118, in __init__
Tkinter.Widget.__init__(self, master, 'table', kw)
The tktable module requires that your tcl/tk installation have the tktable extension. That extension defines the 'table' widget. It is not part of the standard tcl/tk that is installed with Python on Windows. Hence
_tkinter.TclError: invalid command name "table"
The tktable source code (probably a mixture of tcl and C) is hosted at SourceForge. This page says that it is part of the ActiveState Batteries Included distribution. I don't know if the free version of AS tcl/tk has all the 'batteries'. And I don't know how to replace the tcl/tk installation you already have with a new one. I personally would use an alternative if possible.
The issue that I have is related to the GetItem() method from pywinauto. I was able to run the window.TreeView.GetItem('\\Desktop').Click() command on Windows 7 and 10 both 32 bit but it throws an exeption and does not run when calling it from the python command line of Windows 10 64 bit.
This is my full code I use:
import pywinauto
pwa_app = pywinauto.application.Application()
w_handle = pywinauto.findwindows.find_windows(title=u'Browse For Folder', class_name='#32770')[0]
window = pwa_app.window_(handle=w_handle)
window.TreeView.GetItem('\\Desktop').Click()
These are the errors that I receive:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pywinauto\controls\common_controls.py", line 1374, in GetItem
texts = [r.Text() for r in roots]
File "C:\Python27\lib\site-packages\pywinauto\controls\common_controls.py", line 872, in Text
return self._readitem()
File "C:\Python27\lib\site-packages\pywinauto\controls\common_controls.py", line 1263, in _readitem
raise ctypes.WinError()
WindowsError: [Error 0] The operation completed successfully.
Folder Dialog content
I have to mention that I can only access the root of the tree view by window.TreeView.GetItem([0]).Click()
It happens because Win32 API structure sizes for Windows messages are different for 32-bit and 64-bit apps. It's fixed in UIA branch (you can wait for 0.6.0 planned this summer).
Another way is just to set up 32-bit Python (and pywinauto) in addition to your 64-bit Python (you just need to care about full path to python.exe).
Try This one ...
import pywinauto
from pywinauto import Desktop, Application
import pywinauto
app = Application(backend="uia").connect(best_match='File Explorer')
dlg = app.File_Explorer
dlg = dlg.ItemsView.get_item('Documents')
dlg.click_input(double = True)
I'm developing a desktop app which uses the Mayavi package. So, I'm using anaconda with mayavi 4.4.0 and pyqt 4.11.3 (python 2.7). When I try to save the image using the Mayavi interface I get:
KGlobal::locale(): Warning your global KLocale is being recreated with a valid main component instead of a fake component, this usually means you tried to call i18n related functions before your main component was created. You should not do that since it most likely will not work
Object::connect: No such signal org::freedesktop::UPower::DeviceAdded(QDBusObjectPath)
Object::connect: No such signal org::freedesktop::UPower::DeviceRemoved(QDBusObjectPath)
kfilemodule(5709): couldn't create slave: "Unable to create io-slave:
klauncher said: Unknown protocol ''.
"
Traceback (most recent call last):
File "/home/facu/anaconda/lib/python2.7/site-packages/pyface/ui/qt4/action/action_item.py", line 358, in _qt4_on_triggered
action.perform(action_event)
File "/home/facu/anaconda/lib/python2.7/site-packages/pyface/action/action.py", line 100, in perform
self.on_perform()
File "/home/facu/anaconda/lib/python2.7/site-packages/tvtk/pyface/ui/qt4/decorated_scene.py", line 159, in _save_snapshot
if dialog.open() == OK:
File "/home/facu/anaconda/lib/python2.7/site-packages/pyface/i_dialog.py", line 122, in open
self.close()
File "/home/facu/anaconda/lib/python2.7/site-packages/pyface/ui/qt4/file_dialog.py", line 103, in close
self.wildcard_index = self.control.nameFilters().index(
AttributeError: 'QStringList' object has no attribute 'index'
I have fixed others issues editing *.py files, I don't know how to fix this one in particular .
I decided to look into Pyglet to experiment with graphics and hit the ground face first with some errors. Right off the bat, I had issue simply trying to create a window. I would get multiple errors due to the fact that I was using the 64-bit version of Python. I've switched to 32-bit, and whittled down the errors to this one:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
window = pyglet.window.Window()
File "C:\Python27\lib\site-packages\pyglet\window\win32\__init__.py", line 423, in __init__
super(Win32Window, self).__init__(*args, **kwargs)
File "C:\Python27\lib\site-packages\pyglet\window\__init__.py", line 686, in __init__
self._create()
File "C:\Python27\lib\site-packages\pyglet\window\win32\__init__.py", line 518, in _create
self.context._set_window(self)
File "C:\Python27\lib\site-packages\pyglet\window\win32\__init__.py", line 364, in _set_window
raise gl.ContextException('Unable to share contexts')
ContextException: Unable to share contexts
The error was caused by this line of code, which is the first line in the Pyglet tutorial on their website (omitting the import):
window = pyglet.window.Window()
It's worth noting that I have two monitors. According to the Pyglet documentation, it shouldn't be a problem as it chooses default values, but I don't want to rule it out.
EDIT: I'm working on Windows 7 64-bit.