timezones and time_t
Hi, I've got a Python application that (as well as lots of other stuff!) has to translate time_t values into strings in the TZ of the users choice. Looking at the Python Library Reference, I can see no platform independent way of setting the TZ that time.localtime() returns - tzset() is marked as only available on Unix and that is indeed the case. Is there really nothing "shipped as standard"? I'm using Python 2.4.3 on Windows XP. If not, what's the de-facto standard... pytz? Ta! John -- http://mail.python.org/mailman/listinfo/python-list
Re: timezones and time_t
Thanks for the reply. Unfortunately, a simple "+offset" type solution isn't really accurate enough for the kind of scenario I'm looking at. I'm often dealing with different timezones with DST changeovers on different dates or even different times of day! So I need industrial-strength timezone handling! Wrt your naming conventions... sorry, I'm a newbie to Python so not really qualified to comment. But what's a PEP? -- http://mail.python.org/mailman/listinfo/python-list
Modules... paths... newbie confusion
I wonder if someone could clarify how Python "knows" where modules are - or at least point to some documentation that might help me? Here's what I've been trying: I've installed Python 2.4 Windows, and have also installed tkinter, pmw, cx_Oracle, mssql and pytz (phew!) all under my c:\python24 folder. But when I try to "import pytz" or "import MSSQL" in a Python shell (via IDLE) it's not recognised - yet "import Tkinter", "import Pmw" and "import cx_Oracle" all work. I've experimented with "sys.path" to get the import of pytz to work, but without success so far. I feel as if I'm missing some key piece of information on how this all fits together! Please, help! John -- http://mail.python.org/mailman/listinfo/python-list
Re: Modules... paths... newbie confusion
Thanks for the suggestions, folks.. site-packages ~~ OK, I'm been trying to get MSSQL into c:\Python24\lib\site-packages. MSSQL comes (as a tar'd, zip'd file) with a folder hierarchy with MSSQL.py at the top level and then bin\python2.3\mssqldb.pyd. If I try and copy this folder hierarchy into site-packages and "import MSSQL" then it recognises MSSQL.py but fails to import mssqldb, as that's imported from MSSQL.py. I've noticed a setup.py in the MSSQL folder, but it looks like it has odd hard-coded paths in it (D:\...) and anyway when I tried to run it, I found the Usage message less than helpful! I really apologise if this is Bleeding Obvious to everyone else - is there a web page that will explain all this so the lightbulb will go on over my head?! John -- http://mail.python.org/mailman/listinfo/python-list
Re: Modules... paths... newbie confusion
Well thank you all... that's all very helpful (apart from the brief diversion into MySQL, but even that was instructive!). Your comments about "setup.py" prompted me to read the pytz README.txt a bit more carefully and there it says to run "python setup.py install". And this copies stuff into site-packages. So it's all starting to come together and make a bit more sense to me, hurrah! There's no README.txt with MSSQL, and "python setup.py install" gave me a compilation error: "c:\Python24\MSSQL-0.09\mssqldb.h(16) : fatal error C1083: Cannot open include file: 'sqlfront.h'". I suspect I'm missing some MS SQL Server developer stuff. Copying the files myself to site-packages didn't work either: there's only a mssqldb.pyd file, no .py or .pyc file. And as you pointed out, there's no 2.4 folder so I'm a bit worried about compatibility. So I abandoned this library and decided to try another SQL Server library instead. I tried pymssql and it came with a Windows installer so I didn't need to run setup.py, which meant I didn't need the MS SQL Server developer stuff. Worked First Time! To conclude: I've got all the answers I needed and have acquired some useful understanding... thank you very much indeed! -- http://mail.python.org/mailman/listinfo/python-list
Pmw ScrolledCanvas: How to scroll to specific item?
Hi, I've got a ScrolledCanvas object (sc) and have identified an item on the canvas to which I wish to scroll. I've been reading around and experimenting but with not much success. So far I've managed to get the item's bbox using sc.bbox(item) And got the proportion of the canvas that's visible using sc.xview() and sc.yview() And established the whole canvas bbox using sc.bbox(ALL) I've even gone on to use some rudimentary maths to work out whether I need to scroll, then used: sc.xview_moveto(itemX) But this is all rather messy and I've not yet got it working. There must be an easier way?! Thanks! John -- http://mail.python.org/mailman/listinfo/python-list
Re: Pmw ScrolledCanvas: How to scroll to specific item?
MrBlueSky wrote: > Hi, I've got a ScrolledCanvas object (sc) and have identified an item > on the canvas to which I wish to scroll. I've been reading around and > experimenting but with not much success. > > So far I've managed to get the item's bbox using sc.bbox(item) > And got the proportion of the canvas that's visible using sc.xview() > and sc.yview() > And established the whole canvas bbox using sc.bbox(ALL) > > I've even gone on to use some rudimentary maths to work out whether I > need to scroll, then used: > sc.xview_moveto(itemX) > > But this is all rather messy and I've not yet got it working. > There must be an easier way?! > > Thanks! > > John Done it! I realised that searching for the way to do this using Tk would give me the clue. For the benefit of any other poor soul who wants to do this, here's my code: def scrollToItem(self, item): """Work out whether the specified item is on display. If it's not, scroll to it.""" # Bounding box for the item xItemMin, yItemMin, xItemMax, yItemMax = self.bbox(item) # Find out what proportion (0.0 to 1.0) of the canvas is # currently on view xViewMinP, xViewMaxP = self.xview() yViewMinP, yViewMaxP = self.yview() # Find out the full extent of the canvas scrollRegionStr = self.component("canvas").cget("scrollregion") scrollRegionElementsStr=scrollRegionStr.split(' ',4) xCanvasMin = float(scrollRegionElementsStr[0]) yCanvasMin = float(scrollRegionElementsStr[1]) xCanvasMax = float(scrollRegionElementsStr[2]) yCanvasMax = float(scrollRegionElementsStr[3]) xRange = float(xCanvasMax - xCanvasMin) yRange = float(yCanvasMax - yCanvasMin) # Work out the canvas coordinates of the bit of the canvas that's # currently on view xViewMin = float(xViewMinP)*xRange xViewMax = float(xViewMaxP)*xRange yViewMin = float(yViewMinP)*yRange yViewMax = float(yViewMaxP)*yRange if xItemMin < xViewMin: newXViewP = float(xItemMin - xCanvasMin)/xRange self.xview_moveto(newXViewP) elif xItemMax > xViewMax: newXViewP = float(xItemMax - xCanvasMin - (xViewMax-xViewMin))/xRange self.xview_moveto(newXViewP) if yItemMin < yViewMin: newYViewP = float(yItemMin - yCanvasMin)/yRange self.yview_moveto(newYViewP) elif yItemMax > yViewMax: newYViewP = float(yItemMax - yCanvasMin - (yViewMax-yViewMin))/yRange self.xview_moveto(newYViewP) (I'd still very much appreciate any critique of this!) John -- http://mail.python.org/mailman/listinfo/python-list
What technologies should I use for my application manager?
Hello! I've just finished working on my first Python app (a Tkinter-based program that displays the content of our application log files in graphical format). It was a great experience that's had a very positive response from my colleagues. So I'd like to try something different for my second Python application. It's a simple server that can launch and monitor the state of our program, to help our software developers. In my mind I have a vision of: * a web server * allows the user to launch our product (choosing from a set of different launch scripts) * allow user to stop a launched product * report state by retrieving data from the RDBMS against which the product runs (Oracle or SQL Server) There seem to be a lot of web server related Python libraries around, and I've no experience in web servers at all. So I'd really appreciate some advice on what Python "technologies" you think I should base my application on. Thank you in advance! John -- http://mail.python.org/mailman/listinfo/python-list
Re: What technologies should I use for my application manager?
Thanks for the advice, Adam! Turbogears sounds like it does everything I want and looks like a great... except you've made me nervous with your comment on the instability of the Oracle API! Stability, good documentation and a wide user base are priorities. I was delighted by the quality of Tkinter in this regard. Am I wishing for the moon in hoping for the same quality in the framework I choose for this? Anyone else like to try and sell me on Zope or Django?! -- http://mail.python.org/mailman/listinfo/python-list
Re: Redirecting unittest output to a Text widget
Excellent, that seems to have done the trick! FWIW: I should admit that I haven't really taken the time to properly understand unittest... I'm too eager to get my tests written :-) So for reasons I do not as yet understand Peter's suggestion above didn't quite work for me but the following did testSuite = unittest.makeSuite(testX) testSuite = unittest.makeSuite(testY) testRunner = unittest.TextTestRunner(stream=myTextWindow, verbosity=2) testRunner.run(testSuite) I'm only mentioning this in case it's relevant to others. Thanks, Peter! -- http://mail.python.org/mailman/listinfo/python-list
Redirecting unittest output to a Text widget
Morning! I'm writing my first Python program, so please have patience! I'd like to redirect the output from my application's unit tests ("import unittest") to a Tkinter Text object. I found the magic to redirect stdout and stderr: sys.stdout = myTextWindow sys.stderr = myTextWindow where myTextWindow inherits from Text and implements write() and writelines(). But the output from my UT still appears in the command window, not the Text box. My own "print" statements *do* appear in the Text box. Can anyone suggest a way forward here? John -- http://mail.python.org/mailman/listinfo/python-list
IDLE confusion
Hi, I'm trying to use IDLE to develop My First Python App and my head hurts... I've a file called spalvi.py with this in it: from Test import * firstTest("Mike") And a file called Test.py with this in it: def firstTest(name): print "Yo",name I open spalvi.py with IDLE and Run it. It says "Yo Mike". I use the File menu to open Test.py and change the message from "Yo" to "Hi". I Run it again it still says "Yo Mike" :-( I close everything down, open spalvi.py with IDLE and Run it again. It says "Hi Mike". So I'm obviously not using IDLE in the "right" way. But what *is* the "right" way, when you're trying to develop using several source files? John -- http://mail.python.org/mailman/listinfo/python-list