Re: [Tutor] How to kill an app from python on windows?

2006-12-04 Thread Tim Golden
[Paulino]

| To launch an app one can state os.startfile('hello.pdf') and 
| the file is opened in acrobat .
| 
| And how can I kill the app from python, in order to, for 
| instance, rename the file?
| 
| Is it possible?

This link may get you started:

http://effbot.org/pyfaq/how-do-i-emulate-os-kill-in-windows.htm

although it may not apply, depending on the exact
circumstances of what you're doing.

TJG


This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Rounding a float to n significant digits

2006-12-04 Thread Dick Moores
At 12:52 PM 11/30/2006, Dick Moores wrote:
At 11:19 PM 11/27/2006, Dick Moores wrote:
 I just dug this Tim Smith creation out of the Tutor archive.
 
 def round_to_n(x, n):
  
  Rounds float x to n significant digits, in scientific notation.
  Written by Tim Peters. See his Tutor list post of 7/3/04 at
  http://mail.python.org/pipermail/tutor/2004-July/030324.html
  
  if n  1:
  raise ValueError(number of significant digits 
 must be = 1)
  return %.*e % (n-1, x)
 
 Thought others might find it of use.
 
 Dick Moores

I've run into the limitation on the size of an int that can be
converted to a float.

I back with this topic.

I'd completely forgotten that I had written numberRounding(), which 
doesn't suffer from that limitation:

def numberRounding(n, significantDigits=4):
 import decimal
 def d(x):
 return decimal.Decimal(str(x))
 decimal.getcontext().prec = significantDigits
 return d(n)/d(1)

Thus,
  n = 2**2000
  print numberRounding(n,6)
1.14813E+602

BTW the last line of numberRounding() seems strange (even though it 
works)? Why wouldn't return d(n) do the job?

Thanks,

Dick Moores


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Getting the screen size....using Tkinter

2006-12-04 Thread Asrarahmed Kadri

Hi folks,

Is it possible to get the screen size using a standard API of Tkinter?

And also any function to position the window in the center of the screen..??

Thanks in anticipation.

Regards,

Asrarahmed Kadri

--
To HIM you shall return.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Why is startfile unavailable on my mac?

2006-12-04 Thread Nathan Cain

When I type the following in macpython IDLE,:

 import os
 os.startfile()

I get the following error:

Traceback (most recent call last):
  File pyshell#10, line 1, in module
os.startfile()
AttributeError: 'module' object has no attribute 'startfile'

Why is this unavailable to me?

I am trying to open a url in a browser window.

If startfile is just not available on the mac, can someone please  
give me some simple example code that will open http://www.python.org  
in a safari window?


Thank you.

***
Nathan Cain
http://www.Web-Magnets.com

Refrigerator Magnets  Promotional Products

Office: 1-877-WEB-MAGNETS (932-6246)
Cell Phone: 1-501-276-0817
Fax: 1-267-295-8776

Click here if you want me to email you
when we run sales or specials.
***



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Why is startfile unavailable on my mac?

2006-12-04 Thread Kent Johnson
Nathan Cain wrote:
   When I type the following in macpython IDLE,:
 
  import os
  os.startfile()
 
 I get the following error:
 
 Traceback (most recent call last):
   File pyshell#10, line 1, in module
 os.startfile()
 AttributeError: 'module' object has no attribute 'startfile'
 
 Why is this unavailable to me?

The docs for os.startfile() say it is available on Windows only.
 
 I am trying to open a url in a browser window.
 
 If startfile is just not available on the mac, can someone please give 
 me some simple example code that will open http://www.python.org in a 
 safari window?

Try webbrowser.open('http://www.python.org')

Kent

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Getting the screen size....using Tkinter

2006-12-04 Thread Feise, David
Try this:

 from Tkinter import *
 root = Tk()
 root.winfo_screenwidth()
1280
 root.winfo_screenheight()
1024



-Dave

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Asrarahmed Kadri
Sent: Monday, December 04, 2006 8:44 AM
To: tutor-python
Subject: [Tutor] Getting the screen sizeusing Tkinter



Hi folks,

Is it possible to get the screen size using a standard API of Tkinter?

And also any function to position the window in the center of the
screen..??

Thanks in anticipation. 

Regards,

Asrarahmed Kadri

-- 
To HIM you shall return. 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] difflib.SequenceMatcher with get_matching_blocks is incorrect

2006-12-04 Thread Thomas
I'm trying to write a program to test someone's typing speed and show
them their mistakes. However I'm getting weird results when looking
for the differences in longer (than 100 chars) strings:

import difflib

# a tape measure string (just makes it easier to locate a given index)
a = 
'1-3-5-7-9-12-15-18-21-24-27-30-33-36-39-42-45-48-51-54-57-60-63-66-69-72-75-78-81-84-87-90-93-96-99-103-107-111-115-119-123-127-131-135-139-143-147-151-155-159-163-167-171-175-179-183-187-191-195--200'

# now with a few mistakes
b = 
'1-3-5-7-l-12-15-18-21-24-27-30-33-36-39o42-45-48-51-54-57-60-63-66-69-72-75-78-81-84-8k-90-93-96-9l-103-107-111-115-119-12b-1v7-131-135-139-143-147-151-m55-159-163-167-a71-175j179-183-187-191-195--200'

s = difflib.SequenceMatcher(None, a ,b)
ms = s.get_matching_blocks()

print ms


[(0, 0, 8), (200, 200, 0)]


Have I made a mistake or is this function designed to give up when the
input strings get too long?

Thanks in advance,
Thomas
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] clicking a javascript link in a browser

2006-12-04 Thread Nathan Cain
There is a link on a pop-up window from a page that I opened with  
webbrowser.open()


the link is:  javascript:Events.clearList();

is there a way for python to click that link?

Thank you.

***
Nathan Cain
http://www.Web-Magnets.com

Refrigerator Magnets  Promotional Products

Office: 1-877-WEB-MAGNETS (932-6246)
Cell Phone: 1-501-276-0817
Fax: 1-267-295-8776

Click here if you want me to email you
when we run sales or specials.
***



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Why is startfile unavailable on my mac?

2006-12-04 Thread John Fouhy
On 05/12/06, Kent Johnson [EMAIL PROTECTED] wrote:
 The docs for os.startfile() say it is available on Windows only.

Hmm, well you could do a basic Mac version of startfile like this:

def startfile(fn):
os.system('open %s' % fn)

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Getting the screen size....using Tkinter

2006-12-04 Thread Michael Lange
On Mon, 4 Dec 2006 16:43:42 +
Asrarahmed Kadri [EMAIL PROTECTED] wrote:

 Hi folks,
 
 Is it possible to get the screen size using a standard API of Tkinter?
 
 And also any function to position the window in the center of the screen..??
 
 Thanks in anticipation.
 

You might want to have a look at Pmw's _centreonscreen method:

def _centreonscreen(self):
# Centre the window on the screen.  (Actually halfway across
# and one third down.)

parent = self.winfo_parent()
if type(parent) == types.StringType:
parent = self._hull._nametowidget(parent)

# Find size of window.
self.update_idletasks()
width = self.winfo_width()
height = self.winfo_height()
if width == 1 and height == 1:
# If the window has not yet been displayed, its size is
# reported as 1x1, so use requested size.
width = self.winfo_reqwidth()
height = self.winfo_reqheight()

# Place in centre of screen:
x = (self.winfo_screenwidth() - width) / 2 - parent.winfo_vrootx()
y = (self.winfo_screenheight() - height) / 3 - parent.winfo_vrooty()
if x  0:
x = 0
if y  0:
y = 0
return '+%d+%d' % (x, y)

If you replace self resp. self._hull with your window and pass the return value 
to
a call of its geometry() method it should do what you want.

I hope this helps

Michael
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tutor Digest, Vol 34, Issue 7

2006-12-04 Thread Lazarus billa
Dear Sir,
When I wanted to Browse [EMAIL PROTECTED] I am not
able to get it and it indicates cannot find server
due to Syntax Error. Plz Advise.
Urs in His Service 
Rev. Billa. Lazarus
Ph: 91 9948189975
--- [EMAIL PROTECTED] wrote:

 Send Tutor mailing list submissions to
   tutor@python.org
 
 To subscribe or unsubscribe via the World Wide Web,
 visit
   http://mail.python.org/mailman/listinfo/tutor
 or, via email, send a message with subject or body
 'help' to
   [EMAIL PROTECTED]
 
 You can reach the person managing the list at
   [EMAIL PROTECTED]
 
 When replying, please edit your Subject line so it
 is more specific
 than Re: Contents of Tutor digest...
 
 
 Today's Topics:
 
1. Getting the screen sizeusing Tkinter
 (Asrarahmed Kadri)
2. Why is startfile unavailable on my mac?
 (Nathan Cain)
3. Re: Why is startfile unavailable on my mac?
 (Mike Hansen)
4. Re: Why is startfile unavailable on my mac?
 (Kent Johnson)
5. Re: Getting the screen sizeusing Tkinter
 (Feise, David)
6. difflib.SequenceMatcher with
 get_matching_blocks isincorrect
   (Thomas)
 
 

--
 
 Message: 1
 Date: Mon, 4 Dec 2006 16:43:42 +
 From: Asrarahmed Kadri [EMAIL PROTECTED]
 Subject: [Tutor] Getting the screen sizeusing
 Tkinter
 To: tutor-python tutor@python.org
 Message-ID:
 

[EMAIL PROTECTED]
 Content-Type: text/plain; charset=iso-8859-1
 
 Hi folks,
 
 Is it possible to get the screen size using a
 standard API of Tkinter?
 
 And also any function to position the window in the
 center of the screen..??
 
 Thanks in anticipation.
 
 Regards,
 
 Asrarahmed Kadri
 
 -- 
 To HIM you shall return.
 -- next part --
 An HTML attachment was scrubbed...
 URL:

http://mail.python.org/pipermail/tutor/attachments/20061204/6dbfe8ac/attachment-0001.html
 
 
 --
 
 Message: 2
 Date: Mon, 4 Dec 2006 10:51:58 -0600
 From: Nathan Cain [EMAIL PROTECTED]
 Subject: [Tutor] Why is startfile unavailable on my
 mac?
 To: tutor@python.org
 Message-ID:

[EMAIL PROTECTED]
 Content-Type: text/plain; charset=us-ascii
 
 When I type the following in macpython IDLE,:
 
   import os
   os.startfile()
 
 I get the following error:
 
 Traceback (most recent call last):
File pyshell#10, line 1, in module
  os.startfile()
 AttributeError: 'module' object has no attribute
 'startfile'
 
 Why is this unavailable to me?
 
 I am trying to open a url in a browser window.
 
 If startfile is just not available on the mac, can
 someone please  
 give me some simple example code that will open
 http://www.python.org  
 in a safari window?
 
 Thank you.
 
 ***
 Nathan Cain
 http://www.Web-Magnets.com
 
 Refrigerator Magnets  Promotional Products
 
 Office: 1-877-WEB-MAGNETS (932-6246)
 Cell Phone: 1-501-276-0817
 Fax: 1-267-295-8776
 
 Click here if you want me to email you
 when we run sales or specials.
 ***
 
 
 
 -- next part --
 An HTML attachment was scrubbed...
 URL:

http://mail.python.org/pipermail/tutor/attachments/20061204/7bde4b84/attachment-0001.htm
 
 
 --
 
 Message: 3
 Date: Mon, 4 Dec 2006 10:01:13 -0700
 From: Mike Hansen [EMAIL PROTECTED]
 Subject: Re: [Tutor] Why is startfile unavailable on
 my mac?
 To: tutor@python.org
 Message-ID:
 

[EMAIL PROTECTED]
 Content-Type: text/plain; charset=us-ascii
 
  
 
  -Original Message-
  From: [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of
 Nathan Cain
  Sent: Monday, December 04, 2006 9:52 AM
  To: tutor@python.org
  Subject: [Tutor] Why is startfile unavailable on
 my mac?
  
  When I type the following in macpython IDLE,:
  
   import os
   os.startfile()
  
  I get the following error:
  
  Traceback (most recent call last):
File pyshell#10, line 1, in module
  os.startfile()
  AttributeError: 'module' object has no attribute
 'startfile'
  
  
  Why is this unavailable to me?
  
  
  I am trying to open a url in a browser window.
  
  
  If startfile is just not available on the mac, can
 someone 
  please give me some simple example code that will
 open 
  http://www.python.org in a safari window?
  
  
  Thank you.
  
  ***
  Nathan Cain
 
 I just read the docs. I'm assuming that
 Availability: Windows means
 that it's Windows only.
 
 Mike 
 -- next part --
 -
 
   NOTICE:  This e-mail transmission and any
 documents or files attached to
   it contain information for the sole use of the
 above-identified individual or entity.
 
   Its contents may be privileged, confidential, and
 exempt from disclosure under the law.
   Any dissemination, distribution, or copying of
 this 
=== message truncated