Re: [Tutor] Left Alignment -- Tkinter

2009-03-27 Thread Wayne Watson
Title: Signature.html




It's very difficult to tell. I've tried it. 
    fLocation=Frame(master)
    fLocation.pack(side=LEFT)
I need to size the fLocation frame to make it big. As it is, it must be
giving the smallest possible size. 

I tried this
        fLocation.pack(expand=YES,fill=BOTH,side=TOP)

Have a good vacation ...

Alan Gauld wrote:
Try
packing the frame to the left and set it to expand.
  
  
HTH, Going on vacation
  
  
Bye
  
  
Alan G.
  
  
"Wayne Watson"  wrote in message
news:49cd0d40.5090...@sbcglobal.net...
  
  Signature.htmlThe code below is clearly not
shifting the contents of the frame to the left. It's supposed to look
like


 Geographic Location

Latitude BOX  Longitude BOX

    OK Cancel


but instead looks like:

 Geographic Location

  Latitude    BOX  Longitude BOX

    OK Cancel


Where BOX is just a data entry field. I've deliberately made the label
size big enough so as not to obscure what happens with default values.
A 30x5 size. That is if I remove the size options, then it looks OK. I
don't think it really gets shift to the left though even though it
looks like it does.  Comments?


# Framing it

from   Tkinter import *

from   tkSimpleDialog import Dialog

import tkSimpleDialog

import tkMessageBox


class DialogPrototype(Dialog):


   def body(self, master):


   # Frames

   fLocationTitle = Frame(master,)  # fL... f for frame

   fLocationTitle.pack()

   fLocation=Frame(master)

   fLocation.pack()

   fCoords = Frame(fLocation)  # lat/long coords in a frame

   fCoords.pack()



   self.title("Enter Site/Misc. Data")


   # Latitude and Longitude


   Label(fLocationTitle, text="Geographic
Location").grid(row=0,column=0)

   #Label(fCoords, text='Latitude:').grid(row=0, sticky=W)

   self.lab=Label(fCoords, text='Latitude:',width=30, height=5)

   self.lab.grid(row=0, sticky=W)

   self.lat = Entry(fCoords, width=12)

   self.lat.grid(row=0, column=1)


   Label(fCoords, text='Longitude:').grid(row=0, column=2)

   self.long = Entry(fCoords, width=12)

   self.long.grid(row=0, column=3)


   return


   def apply(self):

   print "apply"

   print self.lat.get()

   print self.long.get()


   print "setting"

   lat=1.0

   long=0.0


root = Tk()

root.withdraw()

DialogPrototype(root)


-- 

  Wayne Watson (Watson Adventures, Prop., Nevada City, CA)


    (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)



   "Life is one damn thing after another."

    -- Mark Twain


  
  
  

  
  
  
  ___

Tutor maillist  -  Tutor@python.org

http://mail.python.org/mailman/listinfo/tutor


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


-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


“Life is one damn thing after another."
 -- Mark Twain 





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


Re: [Tutor] Left Alignment -- Tkinter

2009-03-27 Thread Alan Gauld

Try packing the frame to the left and set it to expand.

HTH, Going on vacation

Bye

Alan G.

"Wayne Watson"  wrote in message 
news:49cd0d40.5090...@sbcglobal.net...
Signature.htmlThe code below is clearly not shifting the contents of the 
frame to the left. It's supposed to look like


 Geographic Location
Latitude BOX  Longitude BOX
OK Cancel

but instead looks like:
 Geographic Location
  LatitudeBOX  Longitude BOX
OK Cancel

Where BOX is just a data entry field. I've deliberately made the label 
size big enough so as not to obscure what happens with default values. A 
30x5 size. That is if I remove the size options, then it looks OK. I 
don't think it really gets shift to the left though even though it looks 
like it does.  Comments?


# Framing it
from   Tkinter import *
from   tkSimpleDialog import Dialog
import tkSimpleDialog
import tkMessageBox

class DialogPrototype(Dialog):

   def body(self, master):

   # Frames
   fLocationTitle = Frame(master,)  # fL... f for frame
   fLocationTitle.pack()
   fLocation=Frame(master)
   fLocation.pack()
   fCoords = Frame(fLocation)  # lat/long coords in a frame
   fCoords.pack()


   self.title("Enter Site/Misc. Data")

   # Latitude and Longitude

   Label(fLocationTitle, text="Geographic 
Location").grid(row=0,column=0)

   #Label(fCoords, text='Latitude:').grid(row=0, sticky=W)
   self.lab=Label(fCoords, text='Latitude:',width=30, height=5)
   self.lab.grid(row=0, sticky=W)
   self.lat = Entry(fCoords, width=12)
   self.lat.grid(row=0, column=1)

   Label(fCoords, text='Longitude:').grid(row=0, column=2)
   self.long = Entry(fCoords, width=12)
   self.long.grid(row=0, column=3)

   return

   def apply(self):
   print "apply"
   print self.lat.get()
   print self.long.get()

   print "setting"
   lat=1.0
   long=0.0

root = Tk()
root.withdraw()
DialogPrototype(root)

--

  Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

(121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


   "Life is one damn thing after another."
-- Mark Twain








___
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] Adding key, value to Dictionary

2009-03-27 Thread Emile van Sebille

David wrote:

greg whittier wrote:

On Fri, Mar 27, 2009 at 1:31 PM, David  wrote:

But I can not get this to update after the first time it is ran.

def get_todo():


Other common ways this is done include:

def get_todo(todo={}):
...

This works well if one copy is to be used the entire time the 
application is live, although it's also often cited as a gotcha...



and

def get_todo(todo=None):
if todo==None:
todo = {}
...

Both the above allow you to pass in a starting todo dict, so you could 
juggle multiple todo dicts...


HTH,

Emile

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


Re: [Tutor] Adding key, value to Dictionary

2009-03-27 Thread David

greg whittier wrote:

On Fri, Mar 27, 2009 at 1:31 PM, David  wrote:

But I can not get this to update after the first time it is ran.

def get_todo():
   todo = {}

moved todo{} outside of the function


This set todo to an empty dictionary each time you execute get_todo.


Ok I see it now.



todo = {key:value} again resets the value of todo.  You only need
todo[key]=value.


Yep, thanks


--
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu

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


Re: [Tutor] Adding key, value to Dictionary

2009-03-27 Thread David

David wrote:
I am trying to make a simple Todo program and I can not get the 
dictionary to update.

This works;

#!/usr/bin/python
key = 'Clean house'
value = (1,2,3,4)
todo = {key:value}
value = (5,6,7,8)
todo['Walk Dog'] = value
print todo

results
{'Walk Dog': (5, 6, 7, 8), 'Clean house': (1, 2, 3, 4)}
OK good


I also thought this would work if I did not start out with a blank 
dictionary;

def get_todo():
key = raw_input('Enter Todo Title: ')
print '\n', key, 'has been added.'
print 'Next, enter date for Todo: '
curr_date = time.strftime('%Y %m %d', time.gmtime())
print 'Format as ', curr_date
yr = int(raw_input('\nEnter Year: '))
mt = int(raw_input('Enter Month: '))
dy = int(raw_input('Enter Day: '))
hr = int(raw_input('Enter Hour (24h): '))
mn = int(raw_input('Enter Minute (01-59): '))
value = [yr, mt, dy, hr, mn]
todo = {key:value}
todo[key] = value
print todo
response = raw_input('Do you want to add another Todo? (y/n) ')
if response == 'y':
get_todo()
else:
print 'Goodbye'

get_todo()

same result

--
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu

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


Re: [Tutor] Left Alignment -- Tkinter

2009-03-27 Thread Wayne Watson
Title: Signature.html




Correction. The size of the button is interfering with positioning
here. I'm pretty sure that if the frame size is set to a large value,
width, in particular, then the entry of four columns will not be
adjusted to the left, but will appear centered. The point is that I
want this line left justified. If I put a similar frame above it, the
lower one gets centered.
-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


“Life is one damn thing after another."
 -- Mark Twain 




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


Re: [Tutor] Adding key, value to Dictionary

2009-03-27 Thread greg whittier
On Fri, Mar 27, 2009 at 1:31 PM, David  wrote:
> But I can not get this to update after the first time it is ran.
>
> def get_todo():
>    todo = {}

This set todo to an empty dictionary each time you execute get_todo.

>    key = raw_input('Enter Todo Title: ')
>    todo[key] = key
>    print '\n', key, 'has been added.'
>    print 'Next, enter date for Todo: '
>    curr_date = time.strftime('%Y %m %d', time.gmtime())
>    print 'Format as ', curr_date
>    yr = int(raw_input('\nEnter Year: '))
>    mt = int(raw_input('Enter Month: '))
>    dy = int(raw_input('Enter Day: '))
>    hr = int(raw_input('Enter Hour (24h): '))
>    mn = int(raw_input('Enter Minute (01-59): '))
>    value = [yr, mt, dy, hr, mn]
>    todo = {key:value}
>    todo[key] = value

todo = {key:value} again resets the value of todo.  You only need
todo[key]=value.

>    print todo
>    response = raw_input('Do you want to add another Todo? (y/n) ')
>    if response == 'y':
>        get_todo()
>    else:
>        print 'Goodbye'
>
> get_todo()
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Adding key, value to Dictionary

2009-03-27 Thread David
I am trying to make a simple Todo program and I can not get the 
dictionary to update.

This works;

#!/usr/bin/python
key = 'Clean house'
value = (1,2,3,4)
todo = {key:value}
value = (5,6,7,8)
todo['Walk Dog'] = value
print todo

results
{'Walk Dog': (5, 6, 7, 8), 'Clean house': (1, 2, 3, 4)}
OK good

But I can not get this to update after the first time it is ran.

def get_todo():
todo = {}
key = raw_input('Enter Todo Title: ')
todo[key] = key
print '\n', key, 'has been added.'
print 'Next, enter date for Todo: '
curr_date = time.strftime('%Y %m %d', time.gmtime())
print 'Format as ', curr_date
yr = int(raw_input('\nEnter Year: '))
mt = int(raw_input('Enter Month: '))
dy = int(raw_input('Enter Day: '))
hr = int(raw_input('Enter Hour (24h): '))
mn = int(raw_input('Enter Minute (01-59): '))
value = [yr, mt, dy, hr, mn]
todo = {key:value}
todo[key] = value
print todo
response = raw_input('Do you want to add another Todo? (y/n) ')
if response == 'y':
get_todo()
else:
print 'Goodbye'

get_todo()

results

Enter Todo Title: Clean House

Clean House has been added.
Next, enter date for Todo:
Format as  2009 03 27

Enter Year: 2009
Enter Month: 3
Enter Day: 27
Enter Hour (24h): 13
Enter Minute (01-59): 28
{'Clean House': [2009, 3, 27, 13, 28]}
Do you want to add another Todo? (y/n) y
Enter Todo Title: Walk Dog

Walk Dog has been added.
Next, enter date for Todo:
Format as  2009 03 27

Enter Year: 2009
Enter Month: 3
Enter Day: 27
Enter Hour (24h): 14
Enter Minute (01-59): 35
{'Walk Dog': [2009, 3, 27, 14, 35]}
Do you want to add another Todo? (y/n)

Not so good:(



--
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
pgp.mit.edu

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


[Tutor] Left Alignment -- Tkinter

2009-03-27 Thread Wayne Watson
Title: Signature.html




The code below is clearly not shifting the contents of the frame to the
left. It's supposed to look like

  Geographic Location
Latitude BOX  Longitude BOX
 OK Cancel

but instead looks like:
  Geographic Location
   Latitude    BOX  Longitude BOX
 OK Cancel

Where BOX is just a data entry field. I've deliberately made the label
size big enough so as not to obscure what happens with default values.
A 30x5 size. That is if I remove the size options, then it looks OK. I
don't think it really gets shift to the left though even though it
looks like it does.  Comments? 

# Framing it
from   Tkinter import *
from   tkSimpleDialog import Dialog
import tkSimpleDialog
import tkMessageBox

class DialogPrototype(Dialog):

    def body(self, master):

    # Frames
    fLocationTitle = Frame(master,)  # fL... f for frame
    fLocationTitle.pack()
    fLocation=Frame(master)
    fLocation.pack()
    fCoords = Frame(fLocation)  # lat/long coords in a frame
    fCoords.pack()

    
    self.title("Enter Site/Misc. Data")

    # Latitude and Longitude

    Label(fLocationTitle, text="Geographic
Location").grid(row=0,column=0)
    #Label(fCoords, text='Latitude:').grid(row=0, sticky=W)
    self.lab=Label(fCoords, text='Latitude:',width=30, height=5)
    self.lab.grid(row=0, sticky=W)
    self.lat = Entry(fCoords, width=12)
    self.lat.grid(row=0, column=1)
    
    Label(fCoords, text='Longitude:').grid(row=0, column=2)
    self.long = Entry(fCoords, width=12)
    self.long.grid(row=0, column=3)

    return
    
    def apply(self):
    print "apply"
    print self.lat.get()
    print self.long.get()

    print "setting"
    lat=1.0
    long=0.0

root = Tk()
root.withdraw()
DialogPrototype(root)
-- 


   Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

 (121.01 Deg. W, 39.26 Deg. N) GMT-8 hr std. time)


“Life is one damn thing after another."
 -- Mark Twain 





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


Re: [Tutor] plotting with python

2009-03-27 Thread greg whittier
matplotlib and pylab are two APIs to the same library.  Using
matplotlib is a more object-oriented, pythonic API.  pylab is modeled
after the Matlab plotting functions to make it easier for those coming
from that environment.

There's a matplotlib mailing list and you can often figure out what
you need from perusing the examples and the thumbnail gallery.  In
your case, I think
http://matplotlib.sourceforge.net/examples/api/two_scales.html is what
you want.

On Fri, Mar 27, 2009 at 7:46 AM, Bala subramanian
 wrote:
> Friends,
> I am not sure if this forum is appropriate to ask question about a
> particular package. After getting suggestions from some of you for python
> based plotting, I have just started with matplotlib. I am bit confused with
> the relation between matplotlib and pylab.
>
> In the matplotlib homepage, example plots are shown with both
> matplotlib.pyplot and pylab. Inaddition within matplotlib, there is a module
> called matplotlib.pylab
>
> i) matplotlib and pylab -> both are same or different modules ?. Is there
> any advantage of using one over the other ?
>
> ii) Is it like i can plot the graphs with both matplotlib and pylab ?
>
> iii) can some kindly show me an example of ploting multy Y axes plot, ie
> NXY.
>
> Thanks in advance,
> Bala
>
>
> ___
> Tutor maillist  -  tu...@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] plotting with python

2009-03-27 Thread Kent Johnson
On Fri, Mar 27, 2009 at 7:46 AM, Bala subramanian
 wrote:
> Friends,
> I am not sure if this forum is appropriate to ask question about a
> particular package. After getting suggestions from some of you for python
> based plotting, I have just started with matplotlib. I am bit confused with
> the relation between matplotlib and pylab.
>
> In the matplotlib homepage, example plots are shown with both
> matplotlib.pyplot and pylab. Inaddition within matplotlib, there is a module
> called matplotlib.pylab
>
> i) matplotlib and pylab -> both are same or different modules ?. Is there
> any advantage of using one over the other ?
>
> ii) Is it like i can plot the graphs with both matplotlib and pylab ?

IIUC, pylab is part of matplotlib. It provides a simplified,
functional (not object-oriented) interface to matplotlib. Using
matplotlib directly gives you more control over the result.

> iii) can some kindly show me an example of ploting multy Y axes plot, ie NXY.
Take a look at the gallery for something similar to what you want.
Clicking on a gallery image will show you a larger image and the code
that created it.
http://matplotlib.sourceforge.net/gallery.html

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


[Tutor] plotting with python

2009-03-27 Thread Bala subramanian
Friends,
I am not sure if this forum is appropriate to ask question about a
particular package. After getting suggestions from some of you for python
based plotting, I have just started with matplotlib. I am bit confused with
the relation between matplotlib and pylab.

In the matplotlib homepage, example plots are shown with both *
matplotlib.pyplot* and* pylab*. Inaddition within matplotlib, there is a
module called *matplotlib.pylab*

i) matplotlib and pylab -> both are same or different modules ?. Is there
any advantage of using one over the other ?

ii) Is it like i can plot the graphs with both matplotlib and pylab ?

iii) can some kindly show me an example of ploting multy Y axes plot, ie
NXY.

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