[Tutor] How to make tkMessage function to have duration

2011-07-30 Thread Emeka
Hello All,

Say I have the below(code),  I would want the message to last say 30
seconds and afterwards disappear. I won't want the user to be the one to
enable it to disappear.

Basically, what I want is to be able to show the user some message , and
after some seconds, the message goes away

import Tkinter
import tkMessageBox

top = Tkinter.Tk()
def hello():
   tkMessageBox.showinfo("Say Hello", "Hello World")

B1 = Tkinter.Button(top, text = "Say Hello", command = hello)
B1.pack()

top.mainloop()

-- 
*Satajanus  Nig. Ltd


*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to make tkMessage function to have duration

2011-07-30 Thread Steven D'Aprano

Emeka wrote:

Hello All,

Say I have the below(code),  I would want the message to last say 30
seconds and afterwards disappear. I won't want the user to be the one to
enable it to disappear.

Basically, what I want is to be able to show the user some message , and
after some seconds, the message goes away


I *hate* it when applications do that. Just as I'm trying to read the 
message, take a screen shot, or whatever, the message disappears. I 
think that's one of the worst things you can do in an application.


If the message isn't important enough to require it to stay visible 
until the user explicitly closes it, then it shouldn't go into a dialog 
in the first place.




--
Steven
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to make tkMessage function to have duration

2011-07-30 Thread Emeka
Steven,,


Thanks!


Emeka

On Sat, Jul 30, 2011 at 12:25 PM, Steven D'Aprano wrote:

> Emeka wrote:
>
>> Hello All,
>>
>> Say I have the below(code),  I would want the message to last say 30
>> seconds and afterwards disappear. I won't want the user to be the one to
>> enable it to disappear.
>>
>> Basically, what I want is to be able to show the user some message , and
>> after some seconds, the message goes away
>>
>
> I *hate* it when applications do that. Just as I'm trying to read the
> message, take a screen shot, or whatever, the message disappears. I think
> that's one of the worst things you can do in an application.
>
> If the message isn't important enough to require it to stay visible until
> the user explicitly closes it, then it shouldn't go into a dialog in the
> first place.
>
>
>
> --
> Steven
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>



-- 
*Satajanus  Nig. Ltd


*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] newbie needs pypy setup tips

2011-07-30 Thread Tom Roche

I need advice about configuring pypy to run other python code. Why I ask:

I'm running a model implemented in python. Unfortunately a run on "straight" 
python 2.6.x or 2.7.x requires

- 130 min on my ubuntu laptop (on which working would be more convenient)
- 55 min on a better build machine on which I currently have access

However I have read that this model runs 5x faster under pypy, so I wanna get 
me that, but I'm finding the pypy docs pretty inscrutable. Nevertheless, I have 
managed to do

me@it:~$ uname -rv
> 2.6.32-33-generic #70-Ubuntu SMP Thu Jul 7 21:13:52 UTC 2011
me@it:~$ which pypy
> /usr/local/bin/pypy
me@it:~$ ls -al $(which pypy)
> lrwxrwxrwx 1 root root 37 2011-07-30 16:06 /usr/local/bin/pypy -> 
> /opt/pypy-c-jit-1.5.0-alpha0/bin/pypy
me@it:~$ pypy --version
> Python 2.7.1 (b590cf6de419, Apr 30 2011, 02:00:34)
> [PyPy 1.5.0-alpha0 with GCC 4.4.3]

However, when I try to *really* run the @#$%^&! thing, it spews:

me@it:~$ pypy
> debug: WARNING: library path not found, using compiled-in sys.path and 
> sys.prefix will be unset
> 'import site' failed
> Python 2.7.1 (b590cf6de419, Apr 30 2011, 02:00:34)
> [PyPy 1.5.0-alpha0 with GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> debug: OperationError:
> debug:  operror-type: ImportError
> debug:  operror-value: No module named _pypy_interact

What do I need to do to fix its library path?

TIA, Tom Roche 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] newbie needs pypy setup tips

2011-07-30 Thread eire1130
I think, but not 100 percent, that pypy has a list. You might get better 
traction there if you don't get a good *nswer here.

Although I have a couple questions. Have you profiled in python to look for 
hotspots?

Have you tried writting portions in c?

What kind of model is it, out of curiousity.
Sent from my Verizon Wireless BlackBerry

-Original Message-
From: Tom Roche 
Sender: tutor-bounces+eire1130=gmail@python.org
Date: Sat, 30 Jul 2011 17:49:02 
To: 
Reply-To: tutor@python.org, Tom Roche 
Subject: [Tutor] newbie needs pypy setup tips


I need advice about configuring pypy to run other python code. Why I ask:

I'm running a model implemented in python. Unfortunately a run on "straight" 
python 2.6.x or 2.7.x requires

- 130 min on my ubuntu laptop (on which working would be more convenient)
- 55 min on a better build machine on which I currently have access

However I have read that this model runs 5x faster under pypy, so I wanna get 
me that, but I'm finding the pypy docs pretty inscrutable. Nevertheless, I have 
managed to do

me@it:~$ uname -rv
> 2.6.32-33-generic #70-Ubuntu SMP Thu Jul 7 21:13:52 UTC 2011
me@it:~$ which pypy
> /usr/local/bin/pypy
me@it:~$ ls -al $(which pypy)
> lrwxrwxrwx 1 root root 37 2011-07-30 16:06 /usr/local/bin/pypy -> 
> /opt/pypy-c-jit-1.5.0-alpha0/bin/pypy
me@it:~$ pypy --version
> Python 2.7.1 (b590cf6de419, Apr 30 2011, 02:00:34)
> [PyPy 1.5.0-alpha0 with GCC 4.4.3]

However, when I try to *really* run the @#$%^&! thing, it spews:

me@it:~$ pypy
> debug: WARNING: library path not found, using compiled-in sys.path and 
> sys.prefix will be unset
> 'import site' failed
> Python 2.7.1 (b590cf6de419, Apr 30 2011, 02:00:34)
> [PyPy 1.5.0-alpha0 with GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> debug: OperationError:
> debug:  operror-type: ImportError
> debug:  operror-value: No module named _pypy_interact

What do I need to do to fix its library path?

TIA, Tom Roche 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Mainloop conflict

2011-07-30 Thread Christopher King
I think I'll go with threading. I've become more familiar with it.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Mainloop conflict

2011-07-30 Thread Stefan Behnel

Christopher King, 31.07.2011 04:30:

I think I'll go with threading. I've become more familiar with it.


That's ok. When used carefully, threads can be pretty helpful to gain 
concurrency in I/O tasks.


But just in case you ever feel like using them for anything else, this is 
worth a read:


http://ptolemy.eecs.berkeley.edu/publications/papers/06/problemwithThreads/

Stefan

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] How to replace the '\'s in a path with '/'s?

2011-07-30 Thread Richard D. Moores
64-bit Vista
Python 3.2.1

I would like to write a function that would take a path such as
'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
and return 'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf' . I've
tried this:

def test(path):
   return path.replace('\', '/')

print(test('C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'))

gets me

File "c:\P32Working\untitled-5.py", line 2
   return path.replace('\', '/')
   ^
SyntaxError: EOL while scanning string literal
Process terminated with an exit code of 1

Thanks,

Dick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-30 Thread Dharmit Shah
Ruchard,

Try return path.replace('\\', '/'). That gave me the output desired by you.
I don't know the reason. But I guess it's because \ is used as escape
character. I am sure someone in the list will point out the accurate reason.

On Sun, Jul 31, 2011 at 10:58 AM, Richard D. Moores wrote:

> 64-bit Vista
> Python 3.2.1
>
> I would like to write a function that would take a path such as
> 'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
> and return 'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf' . I've
> tried this:
>
> def test(path):
>return path.replace('\', '/')
>
> print(test('C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'))
>
> gets me
>
> File "c:\P32Working\untitled-5.py", line 2
>return path.replace('\', '/')
>^
> SyntaxError: EOL while scanning string literal
> Process terminated with an exit code of 1
>
> Thanks,
>
> Dick
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Regards

Dharmit Shah 
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-30 Thread ian douglas
Try a double backslash

replace('\\','/')
On Jul 30, 2011 10:30 PM, "Richard D. Moores"  wrote:
> 64-bit Vista
> Python 3.2.1
>
> I would like to write a function that would take a path such as
> 'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
> and return 'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf' .
I've
> tried this:
>
> def test(path):
> return path.replace('\', '/')
>
> print(test('C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'))
>
> gets me
>
> File "c:\P32Working\untitled-5.py", line 2
> return path.replace('\', '/')
> ^
> SyntaxError: EOL while scanning string literal
> Process terminated with an exit code of 1
>
> Thanks,
>
> Dick
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-30 Thread Alexander Etter
On Jul 31, 2011, at 1:28, "Richard D. Moores"  wrote:

> 64-bit Vista
> Python 3.2.1
> 
> I would like to write a function that would take a path such as 
> 'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'
> and return 'C:/Users/Dick/Desktop/Documents/Notes/College Notes.rtf' . I've 
> tried this:
> 
> def test(path):
>return path.replace('\', '/')
> 
> print(test('C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'))
> 
> gets me
> 
> File "c:\P32Working\untitled-5.py", line 2
>return path.replace('\', '/')
>^
> SyntaxError: EOL while scanning string literal
> Process terminated with an exit code of 1
> 
> Thanks,
> 
> Dick
> 
Hi Dick. EOL means End-of-line. Try using double slashes when specifying a 
path. The back slash  \ by itself may be interpreted as an escape character or 
keyword. For example:
print(test('C:\\Users\\Dick\\Desktop\\Documents\\Notes\\CollegeNotes.rtf'))
Hope that helps,
Alexander
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] How to replace the '\'s in a path with '/'s?

2011-07-30 Thread Sandip Bhattacharya
On Sat, Jul 30, 2011 at 10:28:11PM -0700, Richard D. Moores wrote:
> File "c:\P32Working\untitled-5.py", line 2
>return path.replace('\', '/')
>^
> SyntaxError: EOL while scanning string literal
> Process terminated with an exit code of 1

The first backslash up there is escaping the ending quote. This is  what
you want:
return path.replace('\\', '/')

Generally, converting slashes manually should be kept at a minimum. You
should be using library functions as much as possible. The experts here
can correct me here, but this is a roundabout way I would be doing this:

# I use a linux machine. Using this to work with Windows paths
# Use os.path if you are on windows
import ntpath

# Use raw strings so that backslash doesnt matter
path=r'C:\Users\Dick\Desktop\Documents\Notes\College Notes.rtf'

#take out drive first because ntpath.split end sentinel is predictable that 
way
drive,rest = ntpath.splitdrive(path)

# This will store the path components
comps = []
comps.append(drive)

while rest != '\\':
parts = ntpath.split(rest)
comps.insert(1,parts[1])
rest = parts[0]


print '/'.join(comps)

I am not happy with the loop to collect the components. But I couldn't
find a single path function which splits a path into all the components
in one go.

- Sandip


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor