[Tutor] packing up python code to transfer to another machine

2010-02-10 Thread dwbarne
I have become a true Pythonaholic. My newest problem is

I have a rather large Python code (1.5yrs + developing!) currently running on 
Windows machines that imports several modules, some from external libraries. It 
allows the user to easily access MySQL databases and plot selected columns and 
such.

I would like to bundle my (code + libraries + modules) and transfer all to a 
*nix environment, rather than just transferring my code over and then having to 
download and install all the relevant libraries again.

Is this possible? I would think so with Python but am not sure.

Is there a Python package that does this? If so, what?

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


[Tutor] python and kiviat diagrams

2009-12-22 Thread dwbarne
One of the drawbacks of Matplotlib is that it does not have the capability of 
drawing Kiviat diagrams.

Does anyone know of a software package for drawing Kiviat diagrams written in 
Python?

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


Re: [Tutor] python and kiviat diagrams

2009-12-22 Thread dwbarne
Kent and Hilton,

I'm a victim of outdated documentation. Mine is v0.98 (no radar charts), while 
latest is v0.99. A small step in numbers, but a giant leap in capability!

Thanks! Looks like Matplotlib will do the trick after all.

Daniel


-Original Message-
>From: Kent Johnson 
>Sent: Dec 22, 2009 4:45 PM
>To: dwba...@earthlink.net
>Cc: python tutor 
>Subject: Re: [Tutor] python and kiviat diagrams
>
>On Tue, Dec 22, 2009 at 1:18 PM,   wrote:
>> One of the drawbacks of Matplotlib is that it does not have the capability 
>> of drawing Kiviat diagrams.
>>
>> Does anyone know of a software package for drawing Kiviat diagrams written 
>> in Python?
>
>I don't know what a Kiviat diagram is but the images google shows me
>look a lot like this:
>http://matplotlib.sourceforge.net/examples/api/radar_chart.html
>
>Kent

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


[Tutor] trying to put Tkinter widget handlers in a module

2008-09-28 Thread dwbarne
I am writing a large Python/Tkinter/Pmw program. It has become so big that I 
would like to move some of the widget handlers to a module for import. The 
following small program illustrates:

# --- begin code ---

# checkbutton frame using python & Tkinter

from Tkinter import *
import string

class CheckButton_1(Frame):
def __init__(self,msg):
Frame.__init__(self,master)
self.grid(
)

self.createWidgets()

def createWidgets(self): 
self.var = IntVar()   
c = Checkbutton(
master, 
text='Check if yes',
variable=self.var,
command=self.handlerCheckButton,
)
c.grid(
)

def handlerCheckButton(self):
self.doNotSend=self.var.get()
if self.doNotSend:
print "\nChecked"
else:
print "\nNot checked"

if __name__ == "__main__":
master=Tk()
master.title("Checkbutton test")
msg='If checked, do NOT send me a copy of this email'
check=CheckButton_1(msg)
check.mainloop()

# --- end code ---

If the method 'handlerCheckButton(self)' is moved to a module, them imported, 
the button may come up but once the Checkbutton is checked, the code crashes 
with an error. 

Is there no way to put handlers in a module and import them? Is 'self' getting 
in the way?

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


[Tutor] keep from opening multiple Toplevel windows

2008-10-03 Thread dwbarne
I have a Tkinter button widget that when pressed invokes a Toplevel window call 
each time. The Toplevel window thus generated has a close button on it. As you 
might guess, when multiple Toplevel windows are open, I can press on a 'close' 
button to '.destroy' the window, but all other Toplevel windows remain and do 
not respond to their 'close' buttons. I understand why THIS happens, but...

The behavior I seek is that one and only one Toplevel window gets generated no 
matter how many times the original Tkinter button is pressed. A new Toplevel is 
generated only after the previous one is closed.

My question is: how does one check that a particular Toplevel window is open? 
I've tried just checking on the Toplevel widget name with try-except, but the 
value of the Toplevel name stays persistent even when the .destroy method is 
used to kill the Toplevel window, which makes try-except think the Toplevel is 
still open. 
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] remap tab key to 4 spaces in a Tkinter text box

2008-10-30 Thread dwbarne
Hi tutors.

Is there a way to remap a tab key to enter a user-specified number of spaces in 
a Tkinter text widget instead of a genuine tab? An internet search has turned 
up zilch. The tab option in a text widget lets you enter the number of 
centimeters to space over, but this option is truly useless when you want real 
live spaces instead.

I tried using 'bind' to call a method that inserts 4 spaces, for example, but 
this approach enters the number of spaces AND a tab as well (as expected, after 
thinking about it). Not good.

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


[Tutor] how to call a binding method from an imported module

2008-10-31 Thread dwbarne
This problem involves a callback method while using 'bind'. The bind statement 
and the callback function are both in a module imported to the main program. 
Relevant code snippets are as follows:

# begin snippet

# main code

import module_Editor
.
class MyClass():

def editor(self):

module_Editor.my_Editor(self,self.frameParent)

# end of main code

# module 'module_Editor'

def my_Editor(self,parentFrame):

self.textMyCode.bind(
"",
handlerTextLineNumbersReturn(self)
)

def handlerTextLineNumbersReturn(self,event):
def temp():

print '\n** In handlerTextLineNumbersReturn'

return temp

# end of module 'module_Editor'

#  end snippet

When the bind callback handler is called, the following error is returned:

 begin error
Exception in Tkinter callback
Traceback (most recent call last):
 File "c:\Python251_102507\lib\lib-tk\Tkinter.py", line 1403, in __call__
return self.func(*args)
TypeError: tempDef() takes no arguments (1 given)

 end error

The above approach works for widgets in the module calling callback handlers 
that return a def like the above, but bind statements apparently do not like 
this approach for some reason.

Any ideas on what I'm doing wrong here? Maybe a "*args" needs to go somewhere 
in the calling or def statements? If so, where does it go?

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


[Tutor] gnuplot from a python gui

2008-11-07 Thread dwbarne
Hello tutors,

I'm trying to generate a plot using gnuplot from within a python gui. In 
Windows, if after the plot is drawn I use a raw_input string demanding a 
'RETURN' be hit, the plot will persist on the screen until the 'RETURN' is 
pressed. In  *nix, one can use the 'persist' switch to easily and much more 
elegantly accomplish the same.

My question is, is there a better way IN WINDOWS to keep the plot on the screen 
rather than having to leave the gui and find the console window in which a 
'RETURN' must be pressed to continue? My gui will not 'quit' until I enter the 
'RETURN' in the console window. Kind of a chintzy way to end the gui, really.

There must be a better way than using raw_input???

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