Re: Webbrowser On Windows
It seems to me that there is no way to create a new instance of Internet Explorer (if there are already some IE windows opened). Does anyone know a possible solution? Or a workaround (without using startfile, maybe?) that will force IE to create a new instance? Should I suppose no solution exists? Thanks for every suggestions. Andrea -- http://mail.python.org/mailman/listinfo/python-list
The C++ part of the .. Has been deleted, wsTaskBarIcon
Hello Alex, first of all, I would suggest you to upgrade wxPython to 2.5.5.1. There is no particular reason to stick with 2.4, whatever someone else is thinkink/saying. Secondly, I strongly suggest you to abandon the syntax: from wxPython.wx import * And to use: import wx This will help you in future versions of wxPython. At last, looking at your 3 functions: def OnExit(self, event): del self.tbIcon sys.exit() def OnCloseWindow(self, event): del self.tbIcon sys.exit() def OnTaskBarClose(self, event): del self.tbIcon sys.exit() It is not enough to call del self.tbicon. You need to add: self.tbicon.RemoveIcon() self.tbicon.Destroy() del self.tbicon And you *don't* need the call to sys.exit(). Just call self.Destroy() and everything will terminate. HTH. Andrea. -- http://mail.python.org/mailman/listinfo/python-list
Registering File Extension?!?
Hello NG, probably this question has been asked before, but I am unable to find an answer... I have a big application (written in Python + a GUI in wxPython) which allows the user to save its work in a file with an extension .glb. Does anyone know if is there a way (on Windows, but also on other platforms if possible, thought I know almost nothing about Unix/Linux/Mac things) to automatically register the extension .glb so that when the user double-clicks the project file my application is launched with the project file name as a first argument? Thank you for every suggestion/pointer. Andrea. -- http://mail.python.org/mailman/listinfo/python-list
Add System Path?!?
Hello NG, I have a GUI (written in wxPython) that calls some external exe files. Some of them requires that I add to the PATH variable 1 directory. Basically, the exe are located in: /MyApp/Solvers/FirstExe /MyApp/Solvers/SecondExe And so on, while the dll needed by these exe are located in: /MyApp/MyDll These exe files do not work if I don't set the PATH variable also to that adress. I know I can do it by hand (and also my users can), but I wonder if there is a way to do it in Python... Thank you for all suggestions/pointers. Andrea. -- http://mail.python.org/mailman/listinfo/python-list
How To Do It Faster?!?
Hello Simo NG, Correct me if I'm wrong but since it _seems_ that the listing doesn't need to be up-to-date each minute/hour as the users will be looking primarily for old/unused files, why not have a daily cronjob on the Unix server to produce an appropriate file list on e.g. the root directory of your file server? You are correct. I don't need this list to be updated every minute/hour. $ find . -type f -printf %T@ %u %s %p\n /yourserverroot/files.txt That is a nice idea. I don't know very much about Unix, but I suppose that on a ksh I can run this command (or a similar one) in order to obtain the list I need. If anyone knows if that command will run also on a simple ksh, could please confirm that? Moreover, I could run this script in a while loop, like: while 1: do if -e [/yourserverroot/filesbackup.txt]; then find . -type f -printf %T@ %u %s %p\n /yourserverroot/files.txt copy /yourserverroot/files.txt /yourserverroot/filesbackup.txt else find . -type f -printf %T@ %u %s %p\n /yourserverroot/filesbackup.txt fi done or something similar (I don't have Unix at hand now, I can not test the commands and, as I said, I don't know Unix very well...). In this way, I always have the filesbackup.txt up-to-date, as a function of the find speed on the server. Then my GUI could scan the filesbackup.txt file and search for a particular user information. Thanks to all the NG for your suggestions! Andrea. -- http://mail.python.org/mailman/listinfo/python-list
How To Do It Faster?!?
Hello Jeremy NG, * Poke around in the Windows API for a function that does what you want, and hope it can do it faster due to being in the kernel. I could try it, but I think I have to explain a little bit more my problem. If you post more information about how you are using this data, I can try to help you. Basically, I have to scan a really BIG directory: essentially, is a UNIX file system where all our projects resides, with thousand and thousand of files and more than 1 TB of information. However, we are about 200-300 users of this space. This is what I do now and I would like to improve: 1) For a particular user (1 and only 1 at a time), I would like to scan all directories and subdirectories in order to find which FILES are owned by this user (I am NOT interested in directory owner, only files). Noting that I am searching only for 1 user, its disc quota is around 20-30 GB, or something like this; 2) My application is a GUI designed with wxPython. It run on Windows, at the moment (this is why I am asking for Windows user IDs and similar, on Unix is much simpler); 3) While scanning the directories (using os.walk), I process the results of my command dir /q /-c /a-d MyDirectory and I display this results on a wxListCtrl (a list viewer) of wxPython in my GUI; 4) I would not use the suggested command dir /S on a DOS shell because, even if it scans recursively all directories, I am NOT able to process intermediate results because this command never returns until it has finished to scan ALL directories (and for 1 TB of files, it can take a LOT of time); 5) For all the files in each directory scanned, I do: - IF a file belongs to that particular user THEN: Get the file name; Get the file size; Get the last modification date; Display the result on my wxListCtrl - ELSE: Disregard the information; - END I get the file owner using the /Q switch of the DIR command, and I exclude a priori the subdirectories using the /a-d switch. That because I am using os.walk(). 6) All of our users can see this big unix directory on their PC, labeled as E:\ or F:\ or whatever. I can not anyway use UNIX command on dos (and I can not use rsh to communicate with the unix machine and then use something like find . -name etc. I hope to have been clearer this time... I really welcome all your suggestions. Andrea. -- http://mail.python.org/mailman/listinfo/python-list
How To Do It Faster?!?
Hello max NG, I don't quite understand what your program is doing. The user=a[18::20] looks really fragile/specific to a directory to me. I corrected it to user=a[18::5][:-2], it was my mistake. However, that command is NOT specific to a particular directory. You can try to whatever directory or net resource mounted on your system. It works. a=os.popen(dir /s /q /-c /a-d + root).read().splitlines() Mhm... have you tried this command on a BIG directory? On your C: drive for example? I had to kill Python after having issued that command because it ate up all my CPU (1GB) for a quite long time. There simply are too many files/information to retrieve in a single command. In my first mail, I said I have to work with a BIG directory (more than 1 TB) and I need to retrieve information when they become available (I put this info on a wxPython ListCtrl). This is why I have chosen os.walk() and that command (that runs on a separate thread wrt the ListCtrl). It does NOT run faster than your command (probably my solution is slower), but I can get information on every directory I scan, while with your command I have to wait a long time to process the results, plus the user can not interact with the results already found. To get a list containing files owned by a specific user, do something like: files=[line.split()[-1] for line in a if owner in line] I will try this solution also. Thanks NG for your useful suggestions. Andrea. -- http://mail.python.org/mailman/listinfo/python-list
Overloaded Constructors?!?
Hello NG, I am trying to port a useful class from wxWidgets (C++) to a pure Python/wxPython implementation. In the C++ source code, a unique class is initialized with 2 different methods (???). This is what it seems to me. I have this declarations: class wxFoldWindowItem { private: wxWindow *_wnd; int _type, _flags; int _leftSpacing, _rightSpacing, _ySpacing; int _lineWidth, _lineY; wxColour _sepLineColour; public: enum { WINDOW = 0, SEPARATOR }; // wxWindow constructor. This initialises the class as a wxWindow type wxFoldWindowItem(wxWindow *wnd, int flags = wxFPB_ALIGN_WIDTH, int ySpacing = wxFPB_DEFAULT_YSPACING, int leftSpacing = wxFPB_DEFAULT_LEFTSPACING, int rightSpacing = wxFPB_DEFAULT_RIGHTSPACING) : _wnd(wnd) , _type(WINDOW) , _flags(flags) , _leftSpacing(leftSpacing) , _rightSpacing(rightSpacing) , _ySpacing(ySpacing) , _lineWidth(0) , _lineY(0) { }; // separator constructor. This initialises the class as a separator type wxFoldWindowItem(int y, const wxColour lineColor = *wxBLACK, int ySpacing = wxFPB_DEFAULT_YSPACING, int leftSpacing = wxFPB_DEFAULT_LEFTLINESPACING, int rightSpacing = wxFPB_DEFAULT_RIGHTLINESPACING) : _wnd(0) , _type(SEPARATOR) , _flags(wxFPB_ALIGN_WIDTH) , _leftSpacing(leftSpacing) , _rightSpacing(rightSpacing) , _ySpacing(ySpacing) , _lineWidth(0) , _lineY(y) , _sepLineColour(lineColor) { }; The 2 different initializations refers to completely different objects (the first one is a wx.Window, the second one is an horizontal line). Next, there are a lot of functions that, depending on the variable _type, return properties of the wx.Window or of the line. I would like to keep the same names for classes/methods, so it would be useful to have the same class with 2 different initializations. Does anyone know if is there a way to achieve the same thing in Python/wxPython? Someone else has talked about overloaded constructors, but I don't have any idea on how to implement this kind of constructors in Python. Does anyone have a small example of overloaded constructors in Python? I have no idea... Or am I missing something obvious? Thanks to you all. Andrea. -- http://mail.python.org/mailman/listinfo/python-list
Overloaded Constructors?!?
Hello Kent, thank you a lot for your answer. I was starting to think that my question was a little bit strange to obtain an answer... This is a strange design. My first reaction is, why do you want to do that? Maybe you should split the class in two? You are right. The problem is that this is not my code. Someone else has written it and, since it is a useful widget to have in a wxPython GUI, I was trying to port it to Python. I don't want to mess with things like SWIG, because this widget (compiled in C++) is not portable through all platforms, while pure Python code should be. I could split the class in two, but I would like to keep the class/functions definitions as closer as possible to the original one. Next, there are a lot of functions that, depending on the variable _type, return properties of the wx.Window or of the line. I would like to keep the same names for classes/methods, so it would be useful to have the same class with 2 different initializations. One way to do this in Python is to have a single constructor that looks at the type / number of arguments to figure out what it is supposed to do. I am trying to figure it out using something like: def __init__(self, parent, **kw): and processing the keyword args, but it does not satisfy me very much... Another way is to make two factory methods that create instances of the class and do the correct initialization. I am sorry to be so tedious, but I am still quite a newbie in Python... could you please provide a very small example of your last sentence? Looks quite interesting... Thank you a lot. Andrea. -- http://mail.python.org/mailman/listinfo/python-list
Integer From A Float List?!?
Hello NG, probably because I still have Python 2.3.4, these are the results I'm getting: C:\Python23\Libpython timeit.py -s floats = map(float, range(1000)) ints = m ap(int, floats) 1000 loops, best of 3: 398 usec per loop C:\Python23\Libpython timeit.py -s floats = map(float, range(1000)) ints = [ int(x) for x in floats] 1000 loops, best of 3: 820 usec per loop C:\Python23\Libpython timeit.py -s floats = map(float, range(1000)) ints = [ ] for x in floats: ints.append(int(x)) 1000 loops, best of 3: 932 usec per loop C:\Python23\Libpython timeit.py -s floats = map(float, range(1000)) -s from itertools import starmap, izip ints = list(starmap(int, izip(floats))) 1000 loops, best of 3: 513 usec per loop So, the last (very smart) solution, works slightly slower on my PC wrt the first solution. I don't know really what has changed in Python 2.4... At the moment I cannot switch to 2.4 because some site-packages I use are still not updated to Python 2.4. Anyway, thanks to you all for your smart suggestion. It is really a nice newsgroup. Andrea. -- http://mail.python.org/mailman/listinfo/python-list
Integer From A Float List?!?
Hello NG, sorry to bother you again with this question... I never used the timeit function, and I would like to ask you if the call I am doing is correct: C:\Python23\Libpython timeit.py -n 1000 -s from Numeric import ones -s floa ts=ones((1000,1),'f') -s ints = floats.astype(int) 1000 loops, best of 3: 0.0536 usec per loop I used Numeric module to create a 1000 floats matrix of ones, and it seems to me that is a lot faster than other solutions... but probably I am doing something wrong in my call to the timeit function... Thank you a lot. Andrea. -- http://mail.python.org/mailman/listinfo/python-list
Integer From A Float List?!?
Hello NG, I was wondering if there is a way to obtain, from a list of floats, a list of integers without loops. Probably is a basic question, but I can't find an answer... I have had my eyes blinded by Matlab for years, but now that I discovered Python+wxPython there seems to be no limit on what one can do with these 2 tools. Anyway, following the Matlab style, I would like to do something like this: matrix = [1.5, 4.3, 5.5] integer_matrix = int(matrix) (float for Matlab) (In Matlab, integer_matrix is always a double anyway, here I would like only to show the vector-matrix operation). Obviously, Python complains about: Traceback (most recent call last): File interactive input, line 1, in ? TypeError: int() argument must be a string or a number I would like to avoid loops because, having been blinded by Matlab vector-matrix abilities (and corresponding SLOW for-while loops operations), I tend to think that also Python will be slow if I use loops. Does anyone have a suggestion (or maybe could anyone show me that I'm wrong about loops?) Thanks you a lot. Andrea. -- http://mail.python.org/mailman/listinfo/python-list
Controlling Pc From Server?
Hello NG, I am trying to find some information about the possibility to control two (or more) clients (PCs) via a Python application running on a main server. Ideally, this application should be able to monitor (almost in real time) the activity of these clients (which applications are launched, closed and so on, if this is even possible, obviously). Does anyone have to share some information/pointer? Thank you a lot. Andrea. -- http://mail.python.org/mailman/listinfo/python-list
Controlling Pc From Server?
Hello Kartic NG, Thank you for your prompt answer. In effect, I'm trying to work on a NT network of 6 PC (plus the server). Sorry to not have been clearer. Ideally, I'm trying to monitor the Internet activity of each client (PC) on this network (but I'm not a boss trying to control my emplyees, I'm just curious on it). I would like to know which PC is connected to Internet (by starting something like a timer for every PC, and then periodically check if a particular PC is connected or not). This should be done from the main server. Did I make myself clear? Do you think it would be a huge task? Sorry, it may be a very basic question, but thank you for your help. Andrea. -- http://mail.python.org/mailman/listinfo/python-list