Hi Mark,
I have a sample.py file like this
imports ....
imports....
Class Test TreeView(UnitTest.testcases) :
def setUp(self)
app= Application()
app.connect_( ...... ) I connect to application here, that is already opened.
# get the dialog and ensure it is correct...
my_dialog = app.window_(class_re = "...") # there is probably nothing to do with tree view on this line
my_dialog.DrawOutline("red") # you should see a red outline around the dialog
# try to get the treeview window...
my_tree = my_dialog.TTreeView1
my_tree.DrawOutline("green") # should see a green outline around the tree view
print my_tree.__class__.__name__ # is maybe printing windowspecification
# force to TreeViewWrapper
from pywinauto.controls.common_controls import TreeViewWrapper
my_tree = TreeViewWrapper(my_tree.handle)
print my_tree.__class__.__name__ # IS PRINTING TreeVIewWrapper
my_tree.Select((0,1)) #
def testSelect(self)
"Selecting the testcases"
if __name__ == "__main__"
unittest.main()
When I execute this in command prompt using " python samlpe.py "he clicks on TreeNode with no errors.
But when I have the code( with out class and func def) in a separate file called TriewView.py like this
# I have the necesay imports here ....
imports ....
imports....
app= Application()
app.connect_( ...... ) I connect to application here, that is already opened.
# get the dialog and ensure it is correct...
my_dialog = app.window_(class_re = "...") # there is probably nothing to do with tree view on this line
my_dialog.DrawOutline("red") # you should see a red outline around the dialog
# try to get the treeview window...
my_tree = my_dialog.TTreeView1
my_tree.DrawOutline("green") # should see a green outline around the tree view
print my_tree.__class__.__name__ # is maybe printing windowspecification
# force to TreeViewWrapper
from pywinauto.controls.common_controls import TreeViewWrapper
my_tree = TreeViewWrapper(my_tree.handle)
print my_tree.__class__.__name__ # *******************IS PRINTING DIALOGWrapper INstead of TreeViewWrapper**********
my_tree.Select((0,1)) #
When I try to execute this from cmd prompt it throws an attribute error
Attribute Error: DialogWrapper object does not have attribute select.
The difference between the two is I have a Class and two functions inside that , I have the code
in first approach, in the second one i dont have any class definition;
The mode of execution like shown in second approach is very important for me since I am trying to
parameterize the execution of python from Boost C++ Library
Could You please tell me where the mistake is ?
with regards,
Raghav
Hi Raghav,
Hmm - I have never used Boost.Python - and working with Embedded python is quite a bit different (or at least can bring up new challenges).
I would check first of all that you ONLY have one version of pywinauto on your machine.
Then in the Boost code - I would check what are the values of sys.path (e.g. "print sys.path"). Similarly you can try in both versions (with def's and without) to print out the module, which will show you the path it was loaded from.
e.g.
>>> import os
>>> print os
<module 'os' from 'c:\_tools\python261\lib\os.pyc'>
The only two ways I can think of you getting a DialogWrapper is ...
a) If you have added TTreeView to the windowclasses of DialogWrapper (don't do this
)
b) you are passing the handle of a dialog and you haven't modified TreeViewWrapper.windowclasses (note again - you need to modify the file, and not try to modify it in code, and remember that you need the updated __new__ from my earlier posting ALSO)
Finally where you say...
print my_tree.__class__.__name__ # is maybe printing windowspecification
If you change that to
print my_tree.WrapperObject().__class__.__name__ # is maybe printing windowspecification
After explicitly wrapping with TreeViewWrapper() - you need to use the original - as there is no WrapperObject in a TreeViewWrapper ![]()
Thanks
Mark
Hi Mark,
I was able to resolve the differences, I think I had not added import sys, and sys.path.add(".")
now even without the class definition I am able to run the script i,e I mean by the second approach;
but one strange thing is once I run the script in the cmd prompt window; he throws the dialogwrapper attribute error;
I have the file in d:\pywinauto0.3.8\Test\Connect.py
But once I run the same script in the Editor Pyscript( IDE for writing python script ) the same script works fine
Please note that I had installed pywinauto two times once in C:\pywinauto0.3.8\ I had run the setup file setup install;
and then I had also installed in d:\pywinauto0.3.8\
I have only one python version i,e 2.5
>>> import os
>>> print os
<module 'os' from 'c:\_tools\python25\lib\os.pyc'>
It looks very strange , I think there is some path problem could you help me to guess it
Raghav
Hi Mark,
I have one more update, Now from Boost-Python Interface, from C++ iam able to call the script but
then he throws the same error as in I do it in cmd prompt( start->run->cmd--> cd to the target dir and type python Connect.py"
Attibute Error:DialogWrapper object has no attribute Select.
If I solve this error, I am done with the interface of Boost-Python, and parameterization;
But the same things works vey well, when I run from Pyscript IDE,
Any workaround, hardcoding stuff, Like I tried defining the Select function in DialogWrapper also, but with no success,
Pls suggest if any workaround is present,
with regards,
Raghav
DAmn - lost a long reply to you because clearspace crashed ![]()
to make it short:
I suggest to remove your differnt versions - and have only one verion of pywinauto (where you make the changes I outlined earlier).
I believe at this point that the problems are actually in your environment rather than pywinauto.
I am out all next week on vacation - so I may well not be able to follow up on this until later.
Thanks
mark
Hi Mark,
Can you please tell me how can I uninstall the pywinauto;
the steps and crea i Need to take;
also can I have python 2.5 version
Thanks Mark for your support
with regards,
Raghav
Hi Raghav,
Just delete the folder pywinauto folder
(though I suggest to copy the HwndWrapper.py and common_controls.py first so that you have a history of the changes you made).
Thanks
Mark
