[Tutor] run in "deamon" mode?

2008-01-09 Thread Allen Fowler
Hello,

How can a make a python script run in "deamon mode"? (on a linux box)

That is, I want to run the program via "python myfile.py" and have it drop me 
back to the command line.  The program should continue running until I kill it 
via it's PID, the machine shuts down, or the program itself decides to 
shutdown.   It should _not_  die when I simply log-out, etc.

Is there a standard library module to help with this?

-- Thank you





  

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  
http://tools.search.yahoo.com/newsearch/category.php?category=shopping

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


Re: [Tutor] Scope and elegance revisited

2008-01-09 Thread Michael H. Goldwasser


On Wednesday January 9, 2008, Kent Johnson wrote: 

>James Newton wrote:
>> Hi Python Purists!
>> 
>> I want all instances of a given class to share a piece of information,
>> but I want to set that information on the fly.  I have found that this
>> works:
>> 
>> 
>>   class Foo(object):
>>   # class_variable = None # There is no real need to declare this 
>> 
>>   def __init__(self):
>>   print self.__class__.class_variable
>
>could be just self.class_variable, attributes are looked up in the class 
>if not found in the instance (that's how method access works, e.g.).

Though Kent is correct that the class namespace will be searched when
the variable is not found in the instance namespace, I still prefer to
use the syntax  Foo.class_variable in this context as it makes the
code more legible in regard to this being a class variable.

The only reason I can imagine using the self.__class__ syntax would be
if you expect subclasses to be defined and intentionally want to rely
on the subclass namespace rather than Foo.


>>   def main():
>>   Foo.class_variable = "Done"
>>   Foo()

Notice the above change matches the style you are using in main().

Michael

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


Re: [Tutor] how to open a file using os.system

2008-01-09 Thread Tiger12506
> hi
>
> i am developing a GUI application using TKINTER
>
> i want to open a file from the askopenfile(which is a tkFileDialog) using
> OS.SYSTEM.
>
> i have already created the file open dilog using
> tkFileDialog.askopenfile(parent=root,mode='rb',title='choose a file')
> Now i want to open a file from this dialog using OS.SYSTEM

I am not completely familiar with tkFileDialog but I would bet that it 
returns the file you choose as a string. Try this.

fn = tkFileDialog.askopenfile(parent=root,mode='rb',title='choose a file')
os.system(fn)

Note: This means open a file as explorer.exe would open a file, such as an 
executable 

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


Re: [Tutor] [tutor] Zoom in and zoom out capability

2008-01-09 Thread Varsha Purohit
Hi Alan,
 Yeah i read about them. i tried using the resize function but i was
having difficulty with clarity of the image. I had asked similar thing in
another post. I didnt get any satisfying answer for that. Tried
imagefiltereven
thats not workin out properly. :(

Well in my application i need to make a button which when pressed should
zoom in the image so i was wondering how can i implement it i mean how
should i present the image with more size in a fixed size image panel. Any
ideas.. i am even plannin to implement a slider which will zoom in and out
the image accordingly..



-
Varsha

On Jan 9, 2008 12:11 PM, Alan Gauld <[EMAIL PROTECTED]> wrote:

>
> "Varsha Purohit" <[EMAIL PROTECTED]> wrote
>
> > I want to implement zoom in and zoom out functions using wxpython
> > and PIL. I
> > am tryin to find in PIL if there is any functionality like that.
>
> A few minutes browsing the PIL documentation leads
> me to think there are. Try reading about crop and resize and
> maybe thumbnail.
>
> Between them these should just about cover your needs I think.
>
> HTH,
>
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.freenetpages.co.uk/hp/alan.gauld
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Windowss sidebar gadgets with Python?

2008-01-09 Thread Michael Langford
The answer is "Sort of" or "Not really" depending on how you define "in python".

http://microsoftgadgets.com/Sidebar/DevelopmentOverview.aspx
and
http://msdn2.microsoft.com/en-us/library/bb508513.aspx

are the apropos pieces of documentation. You can call a python program
via the System.Shell.execute function in your sidebar script, and have
it change the html files (or better yet, an xml file) that the toolbar
app uses. After it completes, you update the UI via reloading the XML
file.

It's not the least roundabout way to do something I've ever seen, but
it looks possible.

--Michael

PS: I've had notes on this for awhile, but haven't had the time to
try. If it works, let me know.


On 1/9/08, Timothy Sikes <[EMAIL PROTECTED]> wrote:
>
> Hello all.
>
> I have been working with Python for a couple years off and on, and am
> currently enrolled in a java class. Python was my first language, and I
> think it's probably my favorite. But anyway, I was wondering about whether a
> Windows SideBar application could be built with Python.  I'm not completely
> sure how they work, as honestly, HTML just confuses me I know you can
> use JavaScript, but I don't know if you can apply it with Python.  I'll
> probably be back with more questions, as I like to develop different Python
> scripts and programs for my enjoyment, and I'm starting basic Socket and
> Network programming.
>
> Thank you
> 
> Put your friends on the big screen with Windows Vista(R) + Windows Live™.
> Start now!
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Michael Langford
Phone: 404-386-0495
Consulting: http://www.RowdyLabs.com
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Windowss sidebar gadgets with Python?

2008-01-09 Thread Timothy Sikes
Hello all.I have been working with Python for a couple years off and on, and am 
currently enrolled in a java class. Python was my first language, and I think 
it's probably my favorite. But anyway, I was wondering about whether a Windows 
SideBar application could be built with Python.  I'm not completely sure how 
they work, as honestly, HTML just confuses me I know you can use 
JavaScript, but I don't know if you can apply it with Python.  I'll probably be 
back with more questions, as I like to develop different Python scripts and 
programs for my enjoyment, and I'm starting basic Socket and Network 
programming.Thank you
_
Put your friends on the big screen with Windows Vista® + Windows Live™.
http://www.microsoft.com/windows/shop/specialoffers.mspx?ocid=TXT_TAGLM_CPC_MediaCtr_bigscreen_012008___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Scope and elegance revisited

2008-01-09 Thread Kent Johnson
James Newton wrote:
> The folder in question contains images for counters for a board game.
> Each player instance will use a separate counter image, but all counter
> images will be chosen from the same folder.
> 
> It looks as if the Borg pattern would make all players use the same
> counter image.
> 
> Or am I misunderstanding something?

You understand correctly. Borg is not appropriate for this. I was 
guessing (incorrectly) about what you might be doing.

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


Re: [Tutor] Scope and elegance revisited

2008-01-09 Thread James Newton
Kent Johnson wrote: 
>> To give you the context: my application allows you to select a skin
for
>> the user interface.  I want to set the access path to the skin folder
as
>> a class variable, so that all instances of that class use images from
>> the appropriate folder.  The access path will be read in from a
>> preferences file before any instances of the class are created.

> Why do you have multiple instances of the class? You might be
interested 
> in the Borg pattern:
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531

Hi Kent,

Thanks for your suggestion.

The folder in question contains images for counters for a board game.
Each player instance will use a separate counter image, but all counter
images will be chosen from the same folder.

It looks as if the Borg pattern would make all players use the same
counter image.

Or am I misunderstanding something?

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


Re: [Tutor] Scope and elegance revisited

2008-01-09 Thread Kent Johnson
James Newton wrote:
> Hi Python Purists!
> 
> I want all instances of a given class to share a piece of information,
> but I want to set that information on the fly.  I have found that this
> works:
> 
> 
>   class Foo(object):
>   # class_variable = None # There is no real need to declare this 
> 
>   def __init__(self):
>   print self.__class__.class_variable

could be just self.class_variable, attributes are looked up in the class 
if not found in the instance (that's how method access works, e.g.).

>   def main():
>   Foo.class_variable = "Done"
>   Foo()
> 
> 
>   if __name__ == '__main__': main()
> 
> 
> Running the script prints out "Done" as expected.
> 
> However, this looks ugly to me.  Is there a more elegant way of doing
> this?

Seems OK to me.

> To give you the context: my application allows you to select a skin for
> the user interface.  I want to set the access path to the skin folder as
> a class variable, so that all instances of that class use images from
> the appropriate folder.  The access path will be read in from a
> preferences file before any instances of the class are created.

Why do you have multiple instances of the class? You might be interested 
in the Borg pattern:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66531

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


Re: [Tutor] [tutor] Zoom in and zoom out capability

2008-01-09 Thread Alan Gauld

"Varsha Purohit" <[EMAIL PROTECTED]> wrote

> I want to implement zoom in and zoom out functions using wxpython 
> and PIL. I
> am tryin to find in PIL if there is any functionality like that.

A few minutes browsing the PIL documentation leads
me to think there are. Try reading about crop and resize and
maybe thumbnail.

Between them these should just about cover your needs I think.

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld


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


[Tutor] Scope and elegance revisited

2008-01-09 Thread James Newton
Hi Python Purists!

I want all instances of a given class to share a piece of information,
but I want to set that information on the fly.  I have found that this
works:


  class Foo(object):
  # class_variable = None # There is no real need to declare this 

  def __init__(self):
  print self.__class__.class_variable


  def main():
  Foo.class_variable = "Done"
  Foo()


  if __name__ == '__main__': main()


Running the script prints out "Done" as expected.

However, this looks ugly to me.  Is there a more elegant way of doing
this?


To give you the context: my application allows you to select a skin for
the user interface.  I want to set the access path to the skin folder as
a class variable, so that all instances of that class use images from
the appropriate folder.  The access path will be read in from a
preferences file before any instances of the class are created.

Thanks in advance for your advice.

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


[Tutor] [tutor] Zoom in and zoom out capability

2008-01-09 Thread Varsha Purohit
Hello All,
In my program i have a gui where i am showing an image on the panel.
I want to implement zoom in and zoom out functions using wxpython and PIL. I
am tryin to find in PIL if there is any functionality like that. I want the
user to select either of the button and when they click on the image panel
it shd accordingly zoomin or zoom out. Or may be once user selects an area
inside the image where he wants to zoom in and see. Lemme know if anybody
came across this kind of implementation.

Any help is appreciated.

-- 
Varsha Purohit,
Graduate Student
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] how to open a file using os.system

2008-01-09 Thread Alan Gauld
"brindly sujith" <[EMAIL PROTECTED]> wrote

> i am developing a GUI application using TKINTER
>
> i want to open a file from the askopenfile(which is a tkFileDialog) 
> using
> OS.SYSTEM.

Your terminology is a bit confusing.

os.system(lowercase) is for executing system commands.
Do you want to execute a file as a command?
Do you  want to pass a file to a command?

In either case executing os.system requires a command
string, and the askopenfile dialog returns you a filename
as a string.

So what is the problem that you are experiencing?
Can you show us what you have tried and explain
what you want to happen.

Also be aware that os.system does not give you access
to the output of the executed command, for that
you need to use the subprocess module.

> i have already created the file open dilog using
> tkFileDialog.askopenfile(parent=root,mode='rb',title='choose a 
> file')
> Now i want to open a file from this dialog using OS.SYSTEM

You can execute a file but you cannot "open" it in any
meaningful (to Python) sense.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


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


Re: [Tutor] how to open a file using os.system

2008-01-09 Thread Torsten Marek

On Mi, 2008-01-09 at 15:54 +0530, brindly sujith wrote:
> hi
> 
> i am developing a GUI application using TKINTER
> 
> i want to open a file from the askopenfile(which is a tkFileDialog)
> using OS.SYSTEM.
> 
> i have already created the file open dilog using
> tkFileDialog.askopenfile (parent=root,mode='rb',title='choose a file')
> Now i want to open a file from this dialog using OS.SYSTEM

Hi, 

why would you want to open it using os.system, and how? os.system is for 
executing
commands in a subshell. If you want to open a file for reading, just do

f = open(filename, "r")

and then read from using using .read(), .readline() or by looping over it.

best,

Torsten
-- 
Torsten Marek <[EMAIL PROTECTED]>
ID: A244C858 -- FP: 1902 0002 5DFC 856B F146  894C 7CC5 451E A244 C858
Keyserver: subkeys.pgp.net



signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Zooming option in TKinter

2008-01-09 Thread Alan Gauld

"goldgod a" <[EMAIL PROTECTED]> wrote

>> Can you explain what you mean?
>
> I want to zoom the page like 100,200,300. For example, take a pdf
> viewers we can zoom like what ever the sizes. Like that is there any
> packages available.

Ok, I see.

Sadly the answer is no. There is nothing in Tkinter's Text
widget that allows zooming of the image that is something
you would need to do yourself by changing fonts etc.

You might find someone has created a zoomabnle Text widget
if you ask on the Tkinter mailing list, but I'm pretty sure it's not
a feature thats standard.

Sorry,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 


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


[Tutor] how to open a file using os.system

2008-01-09 Thread brindly sujith
hi

i am developing a GUI application using TKINTER

i want to open a file from the askopenfile(which is a tkFileDialog) using
OS.SYSTEM.

i have already created the file open dilog using
tkFileDialog.askopenfile(parent=root,mode='rb',title='choose a file')
Now i want to open a file from this dialog using OS.SYSTEM
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Zooming option in TKinter

2008-01-09 Thread goldgod a
hi,
> Sorry, I'm not sure what you mean by zoom in/out?
> Are you talking about graphics? Or some other widget?
>
> Can you explain what you mean?

I want to zoom the page like 100,200,300. For example, take a pdf
viewers we can zoom like what ever the sizes. Like that is there any
packages available.

-- 
Thanks & Regards,
goldgod
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Zooming option in TKinter

2008-01-09 Thread Alan Gauld

"goldgod a" <[EMAIL PROTECTED]> wrote

>I am developing one project using python-tkinter. I want to know
> whether the zoom in and zoom out option is present in Tkinter.  If 
> it
> is not present then Can you give some idea to create a option in
> manually.

Sorry, I'm not sure what you mean by zoom in/out?
Are you talking about graphics? Or some other widget?

Can you explain what you mean?

Alan G. 


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