Re: [Tutor] Matplotlib error with Python

2017-05-17 Thread Pooja Bhalode
Hi Alan,

Yes, that was the issue, I had a tempfile.py created my me some time back.
That was interfering with this one.
Thanks a lot for your input.

Hope you have a great day!
Pooja

On Wed, May 17, 2017 at 11:27 AM, Alan Gauld via Tutor <tutor@python.org>
wrote:

> On 17/05/17 15:07, Pooja Bhalode wrote:
>
> > */Users/poojabhalode/.bash_profile: line 1: .bashrc: No such file or
> > directory*
>
> I'd start with this one.
> Where is the bash script error coming from?
> Is there really no .bashrc?
> If not what is the impact of not having it?
>
> I'm also not clear what is calling bashrc...
>
> > *[[ 2 -1  0]*
> > * [-1  2 -1]*
>
> I have no idea what these numbers are.
>
> > *Traceback (most recent call last):*
> > *  File "/Users/poojabhalode/Google Drive/PYTHON/files/1sttest/
> May17.py",
> > line 7, in *
> > *import matplotlib*
> > *  File
> > "/System/Library/Frameworks/Python.framework/Versions/2.7/
> Extras/lib/python/matplotlib/__init__.py",
> > line 947, in *
> > *rcParams = rc_params()*
> > *  File
> > "/System/Library/Frameworks/Python.framework/Versions/2.7/
> Extras/lib/python/matplotlib/__init__.py",
> > line 856, in rc_params*
> > *fname = matplotlib_fname()*
> > *  File
> > "/System/Library/Frameworks/Python.framework/Versions/2.7/
> Extras/lib/python/matplotlib/__init__.py",
> > line 726, in matplotlib_fname*
> > *configdir = _get_configdir()*
> > *  File
> > "/System/Library/Frameworks/Python.framework/Versions/2.7/
> Extras/lib/python/matplotlib/__init__.py",
> > line 597, in _get_configdir*
> > *return _get_config_or_cache_dir(_get_xdg_config_dir())*
> > *  File
> > "/System/Library/Frameworks/Python.framework/Versions/2.7/
> Extras/lib/python/matplotlib/__init__.py",
> > line 566, in _get_config_or_cache_dir*
> > *if not _is_writable_dir(p):*
> > *  File
> > "/System/Library/Frameworks/Python.framework/Versions/2.7/
> Extras/lib/python/matplotlib/__init__.py",
> > line 228, in _is_writable_dir*
> > *t = tempfile.TemporaryFile(dir=p)*
> > *AttributeError: 'module' object has no attribute 'TemporaryFile'*
>
> You don't happen to have a file called tempfile.py in your
> folder by any chance? It could be that the code is picking
> it up instead of the standard library version?
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Matplotlib error with Python

2017-05-17 Thread Pooja Bhalode
*Hi, *

*I have been working on a graphic user interface with matplotlib and
suddenly(Earlier, I didnt get these errors, and when I opened the files
now, I am) getting these errors: *
*/Users/poojabhalode/.bash_profile: line 1: .bashrc: No such file or
directory*
*[[ 2 -1  0]*
* [-1  2 -1]*
* [ 0 -1  2]]*
*[[  3.41421356e+00   8.32667268e-17  -6.37995760e-17]*
* [  0.e+00   2.e+00   1.35170527e-16]*
* [  0.e+00   0.e+00   5.85786438e-01]]*
*8.32667268469e-17*
*8.32667268469e-17*
*-6.37995760397e-17*
*0.0*
*1.35170526715e-16*
*0.0*
*0.0*
*[[ 3.41421356  0.  0.]*
* [ 0.  2.  0.]*
* [ 0.  0.  0.58578644]]*
*Traceback (most recent call last):*
*  File "/Users/poojabhalode/Google Drive/PYTHON/files/1sttest/May17.py",
line 7, in *
*import matplotlib*
*  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py",
line 947, in *
*rcParams = rc_params()*
*  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py",
line 856, in rc_params*
*fname = matplotlib_fname()*
*  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py",
line 726, in matplotlib_fname*
*configdir = _get_configdir()*
*  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py",
line 597, in _get_configdir*
*return _get_config_or_cache_dir(_get_xdg_config_dir())*
*  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py",
line 566, in _get_config_or_cache_dir*
*if not _is_writable_dir(p):*
*  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py",
line 228, in _is_writable_dir*
*t = tempfile.TemporaryFile(dir=p)*
*AttributeError: 'module' object has no attribute 'TemporaryFile'*
*[Finished in 0.2s with exit code 1]*
*[shell_cmd: python -u "/Users/poojabhalode/Google
Drive/PYTHON/files/1sttest/May17.py"]*
*[dir: /Users/poojabhalode/Google Drive/PYTHON/files/1sttest]*
*[path: /usr/bin:/bin:/usr/sbin:/sbin]*


*My code gives errors at the import statement itself: *

*Code::*
*import matplotlib*
*ERROR indicated here. *
*matplotlib.use("TkAgg")*
*from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,
NavigationToolbar2TkAgg*
*from matplotlib.figure import Figure*

*Can someone please let me know what is going wrong with this?*
*Thank you. I would really appreciate it.*

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


Re: [Tutor] All Entry Boxes taking the same value

2017-03-31 Thread Pooja Bhalode
Hi Peter and Alan,

Yes, thank you for your suggestions. I really appreciate it. I would look
into a proper tutorial and try to follow it up. The suggestion regarding
this piece of code worked when I tried StringVar instead of " ".

Thank you once again.
Yours truly,
Pooja


On Fri, Mar 31, 2017 at 6:28 AM, Alan Gauld via Tutor <tutor@python.org>
wrote:

> On 30/03/17 21:35, Pooja Bhalode wrote:
>
> > *However, when I execute it, and type something in one entrybox, it shows
> > in all the entry boxes using multi-cursor option. *
>
> I'm not sure whats going on and don;t habe tome to experiment but one
> thing I noticed:
>
> > average = [" ", " ", " "]
> > lowest = [" ", " ", " "]
> > highest = [" ", " ", " "]
> ...
> > for i in range(len(reactants)):
> > *Entry*(root, textvariable =* average[i]*, width = 15,
> > state=DISABLED).grid(row = 3+i, column = 1, sticky = W)
>
> You are setting textvariable to a string but it should be
> a StrinVar object. You could probably fix that by changing
> your data definitions to StringVars:
>
> average = [StringVar(), StringVar(), StringVar()]
>
> I don't know if that will fix the problem but its probably
> a good thing to do anyhow...
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] All Entry Boxes taking the same value

2017-03-31 Thread Pooja Bhalode
Hi,
I am working on a GUI application where I have a multiple number of entry
boxes and I created a loop for the label and entry boxes depending upon the
number of times it needs to be shown. However, I tried assigning different
values to each label and entry boxes in the for loop using lists, so that I
can save different values obtained from the entry boxes in the entry lists
and use them later.

*However, when I execute it, and type something in one entrybox, it shows
in all the entry boxes using multi-cursor option. *

Can someone please tell me how I can avoid this error?
I am trying to put a for loop since I need to create the gui such that the
number of times it needs to be done would be unknown. Hence, the way I went
about this was to take an upper limit of 3 and thus, reacoriginal = [" ", "
", " "]. This can be used as an upper limit and the required number can
thus fit in as needed.
Here, for example, I have taken the required number as two. this would be
later modified.

Code:
from Tkinter import *

root = Tk()
root.geometry("500x350")

# Variables:
reacoriginal = [" ", " ", " "]
conca = [1,0,0]
print conca[0]
concunit = [" ", " ", " "]

concunit11 = StringVar()
concunit21 = StringVar()
concunit31 = StringVar()
conca1 = IntVar()
conca1.set(1)
concb1 = IntVar()
concc1 = IntVar()

average = [" ", " ", " "]
lowest = [" ", " ", " "]
highest = [" ", " ", " "]
averageformulation = [" ", " ", " "]
lowestformulation = [" ", " ", " "]
highestformulation = [" ", " ", " "]

print average
reactants = ["A", "B", "C"]
for i in range(len(reactants)):
Label(root, text = "Experimental Range").grid(row = 0, column = 0, sticky =
W)
labeldown = Label(root, text = "For Parameter Estimation")
labeldown.grid(row = 1, column = 0, sticky = W)
labeldown.config(state='disable')

Label(root, text = "Average ").grid(row = 2, column = 1, sticky = W)
Label(root, text = "Lowest ").grid(row = 2, column = 2, sticky = W)
Label(root, text = "Highest").grid(row = 2, column = 3, sticky = W)
Label(root, text = "Units").grid(row = 2, column = 4, sticky = W)
Checkbutton(root, text = reactants[i], variable = conca[i]).grid(row = 3+i,
column = 0, sticky = W)
optionlist2 = [u'\u03bcmol/L',  'mmol/L','mol/L']
concunitdrop = OptionMenu(root, concunit[i], *optionlist2)
concunitdrop.config(width = 8)
concunitdrop.grid(row = 3+i, column = 4, sticky = W)

for i in range(len(reactants)):
*Entry*(root, textvariable =* average[i]*, width = 15,
state=DISABLED).grid(row = 3+i, column = 1, sticky = W)
*Entry*(root, textvariable = *lowest[i]*, width = 15).grid(row = 3+i,
column = 2, sticky = W)
*Entry*(root, textvariable = *highest[i]*, width = 15).grid(row = 3+i,
column = 3, sticky = W)

root.mainloop()
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Scrollbar

2017-03-27 Thread Pooja Bhalode
Hi, I am going wrong somewhere in the following code. here is given a
simplified code of the work that I am trying to do.
The scrollbar goes not work in the window. Can someone please let me know
what the issue is.
Thank you

Code:
from Tkinter import *

root = Tk()
root.geometry("500x400")
scrollbar = Scrollbar(root, orient = "vertical")
scrollbar.grid(column = 5,sticky = W)

for i in range(0,20):
Label(root, text = i).grid(row = 1+i, column = 1, sticky = W)

root.mainloop()
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Problems with matplotlib

2017-03-04 Thread Pooja Bhalode
I had a similar issue when I tried to download matplotlib in my python
directory. I think what Peter suggested is correct, if you remove the new
file it would work for you. I had the same issue with copy.py file.

Hope that helps.



On Sat, Mar 4, 2017 at 2:30 AM, Peter Otten <__pete...@web.de> wrote:

> Jason Snyder wrote:
>
> > I installed the python module matplotlib on a computer and when I try to
> > run a program with the commands:
> >
> > import matplotlib.pyplot as plt I get the following errors:
> >
> > Traceback (most recent call last):
> >   File "new.py", line 1, in 
> > import matplotlib
> >   File "/usr/lib64/python2.7/site-packages/matplotlib/__init__.py", line
> > 151, in 
> > from matplotlib.rcsetup import (defaultParams,
> >   File "/usr/lib64/python2.7/site-packages/matplotlib/rcsetup.py", line
> >   20,
> > in 
> > from matplotlib.colors import is_color_like
> >   File "/usr/lib64/python2.7/site-packages/matplotlib/colors.py", line
> 54,
> > in 
> > import matplotlib.cbook as cbook
> >   File "/usr/lib64/python2.7/site-packages/matplotlib/cbook.py", line
> 32,
> > in 
> > import new
> >   File "/home/www/html/auroratest/new.py", line 8, in 
> > plt.scatter(x,y)
> > NameError: name 'plt' is not defined
> >
> > when I try to use something like import matplotlib.image as image I get
> > the following errors:
> >
> > Traceback (most recent call last):
> >   File "new.py", line 1, in 
> > import matplotlib.image as image
> >   File "/usr/lib64/python2.7/site-packages/matplotlib/__init__.py", line
> > 151, in 
> > from matplotlib.rcsetup import (defaultParams,
> >   File "/usr/lib64/python2.7/site-packages/matplotlib/rcsetup.py", line
> >   20,
> > in 
> > from matplotlib.colors import is_color_like
> >   File "/usr/lib64/python2.7/site-packages/matplotlib/colors.py", line
> 54,
> > in 
> > import matplotlib.cbook as cbook
> >   File "/usr/lib64/python2.7/site-packages/matplotlib/cbook.py", line
> 32,
> > in 
> > import new
>
> This looks like a name clash. There is a module called "new" in Python's
> standard library, and matplotlib is trying to install that. Instead your
> own
>
> >   File "/home/www/html/auroratest/new.py", line 1, in 
>
> is found. Once you rename your new.py to something else (and remove the
> corresponding new.pyc) things should start to work again.
>
> > import matplotlib.image as image
> >   File "/usr/lib64/python2.7/site-packages/matplotlib/image.py", line
> 13,
> > in 
> > from matplotlib import rcParams
> > ImportError: cannot import name rcParams
> >
> > What is causing these errors and what specific things do I need to do to
> > resolve this.  I need this explained clearly in a step by step way.
> >
> > Thanks,
> >
> > Jason
> >
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tables in Tkinter

2017-03-03 Thread Pooja Bhalode
Hi Alan,

Can you please guide me to an example related to this problem? I do not
know how to use the scrollable frame, set backgrounds etc.
Sorry, I am new to tables in Tkinter. I could not find any examples as well

Please let me know.
Thank you

Pooja

On Fri, Mar 3, 2017 at 2:35 PM, Alan Gauld via Tutor <tutor@python.org>
wrote:

> On 03/03/17 16:07, Pooja Bhalode wrote:
>
> > The table that I am trying to get is a table with scrollable rows. I just
> > want to display the data in the table in the Tkinter window. I do not
> wish
> > to make it interactive, since  just want to display the data.
>
> In that case you could just use a scrolled frame (from PMW, which you
> installed as part of the tkintertable install). Simply add labels
> using the grid manager into your frame. Set a different background
> colour for the top row to make them headings and choose appropriate
> borders and styles.
>
> It should be fairly easy to build up a simple display grid that way.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Radiobuttons (two options out of 4)

2017-03-03 Thread Pooja Bhalode
Hi Alan,

Thank you for letting me know.
I tried putting in the event handlers for the checkbuttons as shown below.


num = 0
def selfcheck(event):
 print "Self Check"
 num = num + 1
 if num == 2:
check1butt.config(state = 'disabled')
check2butt.config(state = 'disabled')
check3butt.config(state = 'disabled')
check4sbutt.config(state = 'disabled')

Label(lom, text = "Choose two options from:").grid(row = 9, column = 1,
sticky = W)
check1butt = Checkbutton(lom, text = "A-optimality", variable = check1)
check1butt.bind("", selfcheck)
check1butt.grid(row = 10, column = 1, sticky = W)
check2butt = Checkbutton(lom, text = "D-optimality", variable = check2)
check2butt.bind("", selfcheck)
check2butt.grid(row = 11, column = 1, sticky = W)

check3butt = Checkbutton(lom, text = "E-optimality", variable = check3)
check3butt.bind("", selfcheck)
check3butt.grid(row = 12, column = 1, sticky = W)

check4butt = Checkbutton(lom, text = "Parameter Co-Variance", variable =
check4)
check4butt.bind("", selfcheck)
check4butt.grid(row = 13, column = 1, sticky = W)
if check1.get() == 1:
if check2.get() == 1:
check3butt.config(state = 'disabled')
check4butt.config(state = 'disabled')

But here, I have the problem where I do not know how to design the function
selfcheck. Here, the function should disable the rest of the checkbuttons
which are not selected after two options are selected by the user. Can you
please let me know how to design the function?
Thank you

Pooja

On Fri, Mar 3, 2017 at 2:42 PM, Alan Gauld via Tutor <tutor@python.org>
wrote:

> On 03/03/17 16:43, Pooja Bhalode wrote:
>
> > I am trying to create a GUI with four options out of which the user is
> > supposed to select two. But once the user selected two out of those four
> > options, the others need to get greyed out at that instant.
> >
> > I tried the following thing:
> >
> > *Label(lom, text = "Choose two options from:").grid(row = 9, column = 1,
> > sticky = W)*
> > * check1butt = Checkbutton(lom, text = "A-optimality", variable =
> > check1).grid(row = 10, column = 1, sticky = W)*
> > * check2butt = Checkbutton(lom, text = "D-optimality", variable =
> > check2).grid(row = 11, column = 1, sticky = W)*
> > * check3butt = Checkbutton(lom, text = "E-optimality", variable =
> > check3).grid(row = 12, column = 1, sticky = W)*
> > * check4butt = Checkbutton(lom, text = "Parameter Co-Variance", variable
> =
> > check4).grid(row = 13, column = 1, sticky = W)*
> > * if check1.get() == 1:*
> > * if check2.get() == 1:*
> > * check3butt.config(state = 'disabled')*
> > * check4butt.config(state = 'disabled')*
>
> The problem is you are not thinking about this in an event driven way.
> The two if statements are only ever executed once when you create the
> GUI, they are never used again.
>
> What you need to do is create an event handler that will check how
> many buttons are checked and if it is 2 set the unchecked buttons to
> disabled. Then bind that event handler to all four buttons.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Radiobuttons (two options out of 4)

2017-03-03 Thread Pooja Bhalode
Hi,

I am trying to create a GUI with four options out of which the user is
supposed to select two. But once the user selected two out of those four
options, the others need to get greyed out at that instant.

I tried the following thing:

*Label(lom, text = "Choose two options from:").grid(row = 9, column = 1,
sticky = W)*
* check1butt = Checkbutton(lom, text = "A-optimality", variable =
check1).grid(row = 10, column = 1, sticky = W)*
* check2butt = Checkbutton(lom, text = "D-optimality", variable =
check2).grid(row = 11, column = 1, sticky = W)*
* check3butt = Checkbutton(lom, text = "E-optimality", variable =
check3).grid(row = 12, column = 1, sticky = W)*
* check4butt = Checkbutton(lom, text = "Parameter Co-Variance", variable =
check4).grid(row = 13, column = 1, sticky = W)*
* if check1.get() == 1:*
* if check2.get() == 1:*
* check3butt.config(state = 'disabled')*
* check4butt.config(state = 'disabled')*
But here, the other two options do not greyed out after selecting the first
and the second option. I am aware that this is still half way there, but
this snippet doesnot seem to work the way it should.

Can someone please suggest me what I can do? Or any other ways to do this?
I was thinking of using Radiobuttons, but then radiobuttons only allow one
option to be chosen. Is there a way?
Thank you

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


[Tutor] Tables in Tkinter

2017-03-03 Thread Pooja Bhalode
Hi,

I am trying to use tkintertable in Python 2.7 to create a table in GUI
using Tkinter.
The table that I am trying to get is a table with scrollable rows. I just
want to display the data in the table in the Tkinter window. I do not wish
to make it interactive, since  just want to display the data.

it would have two columns: Experiments and sensitivity
And number of rows based on the number of experiments present. These number
of rows would have a scrollbar attached to it so that the user can scroll
to the last row if needed.
Can someone please suggest me how I can proceed?
I tried reading through the page: https://github.com/dmnfarrell/tkintertable
But I am not able to understand how to create or edit the row and column
names.
I would really appreciate it if you could let me know.
Thank you so much.

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


Re: [Tutor] Tables in Tkinter

2017-03-02 Thread Pooja Bhalode
Hi Alan,

Thank you for that advice. Sorry, I should have caught that.
Also, i can look into the documentation of tkintertable for creating the
table.

Thank you

Pooja
On Thu, Mar 2, 2017 at 10:12 AM Alan Gauld via Tutor <tutor@python.org>
wrote:

> On 02/03/17 14:25, Pooja Bhalode wrote:
>
> > when I tried to install tkintertable using pip: i got the following
> errors:
> >
> > OSError: [Errno 13] Permission denied:
> > '/Library/Python/2.7/site-packages/Pmw'
>
>
> Based on this I'm guessing you need to run pip with sudo?
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tables in Tkinter

2017-03-02 Thread Pooja Bhalode
I am currently using python 2.7 in mac system.
I think tkinter would be a problem since I use Tkinter for Python 2.7. But
I do not know the corresponding part of tkintertable for python 2.7

Thank you

Pooja

On Thu, Mar 2, 2017 at 9:25 AM, Pooja Bhalode <poojabhalod...@gmail.com>
wrote:

> Hi Alan,
>
> Sorry for being ambiguous earlier. I can make it more clear in this email.
> I am planning on creating a scrollable table (grid of values) with title
> labels for each column and rows present in it and a title for the overall
> table.
>
> I saw it online that to create a table in tkinter, I can use a built in
> module tkintertable but would have to download it.
> when I tried to install tkintertable using pip: i got the following errors:
>
> Poojas-MacBook-Pro:~ poojabhalode$ pip install tkintertable
>
> Collecting tkintertable
>
> Collecting Pmw (from tkintertable)
>
> Installing collected packages: Pmw, tkintertable
>
> Exception:
>
> Traceback (most recent call last):
>
>   File 
> "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py",
> line 215, in main
>
> status = self.run(options, args)
>
>   File 
> "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py",
> line 342, in run
>
> prefix=options.prefix_path,
>
>   File 
> "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py",
> line 784, in install
>
> **kwargs
>
>   File 
> "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py",
> line 851, in install
>
> self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
>
>   File 
> "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py",
> line 1064, in move_wheel_files
>
> isolated=self.isolated,
>
>   File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py",
> line 345, in move_wheel_files
>
> clobber(source, lib_dir, True)
>
>   File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py",
> line 316, in clobber
>
> ensure_dir(destdir)
>
>   File 
> "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py",
> line 83, in ensure_dir
>
> os.makedirs(path)
>
>   File 
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
> line 157, in makedirs
>
> mkdir(name, mode)
>
> OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-
> packages/Pmw'
>
>
> After this, if I tried to import
>
> From tkintertable import TableCanvas
>
> It gave me an error saying no module tkintertable found.
>
> Can you please suggest me as to what I can do and how I can create the
> table required? I also want to create another table wherein there would be
> scrollable rows and columns. There would be one main column, which would be
> subdivided into three and then the three columns subdivided into more
> columns.
>
>
> Please let me know.
>
> Thank you
>
>
> Pooja
>
> On Wed, Mar 1, 2017 at 8:27 PM, Alan Gauld via Tutor <tutor@python.org>
> wrote:
>
>> On 01/03/17 23:40, Pooja Bhalode wrote:
>>
>> > I am trying to create normal tables in Tkinter.
>>
>> First you need to define what a "normal table" is.
>> There is no such thing in standard Tkinter, so any
>> kind of table is not normal.
>>
>> Do you want a simple grid of values?
>> Do you want a spreadsheet type grid with editable cells?
>> Do you want a live link to an underlying data store?
>> Do you want it scrollable? Or re-sizeable? within the form?
>>
>> All of these features are "normal" for tables in
>> different GUI toolkits, but none of them are normal
>> in Tkinter.
>>
>> > as to what functions I can use, I looked into tkintertable, but that
>> does
>> > not seem to work for me.
>>
>> What does "not work" mean?
>>
>> Did it display on screen?
>> Did it have empty values?
>> Were the values not editable (assuming you wanted them to be?
>>
>> You need to be much more specific when describing problems.
>>
>> > I tried installing it but it gave me a bunch of
>> > errors while installation and does not work.
>>
>> How did you install it?
>> What were the errors?
>> What does "not work" mean? (How could it work if the
>> installation gave "a bunch of errors"?)
>>
>> > Is there any other simpler way for creating table and configuring 

Re: [Tutor] Tables in Tkinter

2017-03-02 Thread Pooja Bhalode
Hi Alan,

Sorry for being ambiguous earlier. I can make it more clear in this email.
I am planning on creating a scrollable table (grid of values) with title
labels for each column and rows present in it and a title for the overall
table.

I saw it online that to create a table in tkinter, I can use a built in
module tkintertable but would have to download it.
when I tried to install tkintertable using pip: i got the following errors:

Poojas-MacBook-Pro:~ poojabhalode$ pip install tkintertable

Collecting tkintertable

Collecting Pmw (from tkintertable)

Installing collected packages: Pmw, tkintertable

Exception:

Traceback (most recent call last):

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py",
line 215, in main

status = self.run(options, args)

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py",
line 342, in run

prefix=options.prefix_path,

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py",
line 784, in install

**kwargs

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py",
line 851, in install

self.move_wheel_files(self.source_dir, root=root, prefix=prefix)

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py",
line 1064, in move_wheel_files

isolated=self.isolated,

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line
345, in move_wheel_files

clobber(source, lib_dir, True)

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line
316, in clobber

ensure_dir(destdir)

  File
"/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py",
line 83, in ensure_dir

os.makedirs(path)

  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py",
line 157, in makedirs

mkdir(name, mode)

OSError: [Errno 13] Permission denied:
'/Library/Python/2.7/site-packages/Pmw'


After this, if I tried to import

>From tkintertable import TableCanvas

It gave me an error saying no module tkintertable found.

Can you please suggest me as to what I can do and how I can create the
table required? I also want to create another table wherein there would be
scrollable rows and columns. There would be one main column, which would be
subdivided into three and then the three columns subdivided into more
columns.


Please let me know.

Thank you


Pooja

On Wed, Mar 1, 2017 at 8:27 PM, Alan Gauld via Tutor <tutor@python.org>
wrote:

> On 01/03/17 23:40, Pooja Bhalode wrote:
>
> > I am trying to create normal tables in Tkinter.
>
> First you need to define what a "normal table" is.
> There is no such thing in standard Tkinter, so any
> kind of table is not normal.
>
> Do you want a simple grid of values?
> Do you want a spreadsheet type grid with editable cells?
> Do you want a live link to an underlying data store?
> Do you want it scrollable? Or re-sizeable? within the form?
>
> All of these features are "normal" for tables in
> different GUI toolkits, but none of them are normal
> in Tkinter.
>
> > as to what functions I can use, I looked into tkintertable, but that does
> > not seem to work for me.
>
> What does "not work" mean?
>
> Did it display on screen?
> Did it have empty values?
> Were the values not editable (assuming you wanted them to be?
>
> You need to be much more specific when describing problems.
>
> > I tried installing it but it gave me a bunch of
> > errors while installation and does not work.
>
> How did you install it?
> What were the errors?
> What does "not work" mean? (How could it work if the
> installation gave "a bunch of errors"?)
>
> > Is there any other simpler way for creating table and configuring them as
> > per needed?
>
> It depends what you want. Tell us what you are trying
> to achieve and we may be able to suggest something.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Tables in Tkinter

2017-03-01 Thread Pooja Bhalode
Hi,

I am trying to create normal tables in Tkinter. Can someone please guide me
as to what functions I can use, I looked into tkintertable, but that does
not seem to work for me. I tried installing it but it gave me a bunch of
errors while installation and does not work.

Is there any other simpler way for creating table and configuring them as
per needed?
Thank you so much.
 I tried installing tkintertable-1.2.tar.gz file earlier.

Please let me know.
Thank you

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


[Tutor] Checkbuttons Variables PY_VAR

2017-02-27 Thread Pooja Bhalode
Hi,

The following code creates a list of checkboxes (each associated with
different variables) for the user to select from, after having selected the
ones that user wants, I am trying to add the selected variables to another
list so that the selected variables can be accessed later in the code.
However, when I try appending to the new list, it gets appended as PY_VAR
instead of the variable name associated.
Can someone please let me know where I am going wrong. I would really
appreciate it.
Thank you

Pooja
Code given below:

keqparam = IntVar()
delHrxnparam = IntVar()
kfparam = IntVar()
Afparam = IntVar()
ksimparam = IntVar()
Aparam = IntVar()
RAparam = IntVar()
RCparam = IntVar()

total_number_parameters = IntVar()
selectedparam = []
checkboxVars = [keqparam, delHrxnparam, kfparam, Afparam, ksimparam,
Aparam, RAparam, RCparam]

def EstimateParameters():
print "EstimateParameters"
paramroot = Toplevel(root)
paramroot.title("Selection of Parameters to be estimated")
def SelectAll():
for var in checkboxVars:
var.set(1)
def DeselectAll():
for var in checkboxVars:
var.set(0)

Button(paramroot, text = "Select all", command = SelectAll).grid(row = 0,
column = 2, sticky = W)
Button(paramroot, text = "Deselect all", command = DeselectAll).grid(row =
0, column = 3, sticky = W)
Label(paramroot, text = "Select all the parameters to be estimated:
").grid(row = 0, column = 0, sticky = W)
sticklabel = Label(paramroot, text = "1. Reversible reaction001")
sticklabel.grid(row = 1, column = 0, sticky = W)
Label(paramroot, text = u"\t A + B \u21cc D").grid(row = 3, column = 0,
sticky = W)
Checkbutton(paramroot, text = "K_eq", variable = keqparam).grid(row = 2,
column = 1, sticky = W)
Checkbutton(paramroot, text = u"\u0394Hrxn", variable =
delHrxnparam).grid(row = 3, column = 1, sticky = W)
Checkbutton(paramroot, text = "K_f", variable = kfparam).grid(row = 4,
column = 1, sticky = W)
Checkbutton(paramroot, text = "Eact_f", variable = Afparam).grid(row = 5,
column = 1, sticky = W)

sticklabel = Label(paramroot, text = "2. Simple reaction001")
sticklabel.grid(row = 10, column = 0, sticky = W)
Label(paramroot, text = u"\t A + C \u2192 E").grid(row = 12, column = 0,
sticky = W)
Checkbutton(paramroot, text = "Rate of reaction (k)", variable =
ksimparam).grid(row = 11, column = 1, sticky = W)
Checkbutton(paramroot, text = "Act Energy (A)", variable = Aparam).grid(row
= 12, column = 1, sticky = W)
Label(paramroot, text = "Order of reaction:").grid(row = 13, column=1,
sticky = W)
Checkbutton(paramroot, text = "Reactant A", variable = RAparam).grid(row =
13, column = 2, sticky = W)
Checkbutton(paramroot, text = "Reactant C", variable = RCparam).grid(row =
14, column = 2, sticky = W)

def SubmitParam():
global total_number_parameters
total_number_parameters = RCparam.get() + RAparam.get() + Aparam.get() +
ksimparam.get() + Afparam.get() + kfparam.get() + delHrxnparam.get() +
keqparam.get()
print total_number_parameters

for i in range(len(checkboxVars)):
if checkboxVars[i].get() == 1:
print checkboxVars[i]
selectedparam.append(checkboxVars[i])

print selectedparam


Button(paramroot, text = "Submit", command = SubmitParam).grid(row = 17,
column = 3, sticky =W)


butt1 = Button(explorer, text = "Parameters to be estimated",width = 15,
command = EstimateParameters)
butt1.pack(side = TOP)
butt1.config(font=("",9))

The highlighted area is where I am checking if the checkbutton is selected
and if selected, I am trying to append the variable name in the list
checkboxVar to the new list-selectedparam.

however, when I try to print selectedparam, I get the following output:
[, ]
And when I try to print out checkboxVar[i] which is just above the previous
line, I get PY_VAR2
PY_VAR3

Can someone please let me know where I am going wrong?

Thankyou

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


Re: [Tutor] Multiple muti-selection dropdown options

2017-02-24 Thread Pooja Bhalode
Hi Alan,

Thank you for your inputs. I made the lists global in the Toplevel root. I
still have the problem where in if I select few options from the first
list, and then move to the next list, I loose the selections made on the
screen in the first list. I can however print it out and store it in the
code, but I would like to show it on the screen as well as highlighted even
after moving to the next list. Can you please tell me if there is a way?
Sorry about inserting the images, I was unaware of that and also regarding
some of my nomenclature mistakes, still learning :)

Thank you

Pooja

On Thu, Feb 23, 2017 at 10:37 PM, Pooja Bhalode <poojabhalod...@gmail.com>
wrote:

>
> -- Forwarded message --
> From: Alan Gauld via Tutor <tutor@python.org>
> Date: Thu, Feb 23, 2017 at 8:51 PM
> Subject: Re: [Tutor] Multiple muti-selection dropdown options
> To: tutor@python.org
>
>
> On 23/02/17 22:25, Pooja Bhalode wrote:
>
> > I am working on GUI where I have two dropdown menus in a Toplevel of the
> > main root.
>
> That's not what your code shows. It shows scrolling listboxes, not
> menus. But it seems like a Frame with a set of checkboxes would be
> closer to what you actually want?
>
> Anyway...
>
> > The window shows as below:
> > [image: Inline image 1]
>
> As I keep pointing out you cannot send images to this list,
> the server throws them away as potential security risks.
>
> > Whereas the code is:
> >
> > def selectexp():
> > newlist = list()
> > selection = lstbox.curselection()
> > for i in selection:
> > tempvar = lstbox.get(i)
> > newlist.append(tempvar)
> >
>
> Note that in this function you create a list, populate
> it with values and then throw them all away. If you want
> to keep the values you need to declare the list as a
> global variable.
>
> > for val in newlist:
> > print (val)
>
> Because you are not posting in plain text I can't
> tell if those two lines are inside the previous
> function or not. I'm assuming they are inside the
> function? If not I'd expect a name error for newlist?
>
> > def selectexp2():
> > newlist2 = list()
> > selection2 = lstbox2.curselection()
> > for i in selection2:
> > tempvar2 = lstbox2.get(i)
> > newlist2.append(tempvar2)
> >
> > for val in newlist2:
> > print (val)
>
> Same problem here, you declare newlist2 as a new
> list inside the function, then when the function
> exits it throws it away. If you want to access
> variables after the function exits you need to
> make them global (or start using classes and
> objects)
>
> > However, the issue is that when the user selects options from the first
> > dropdown menu and moves on to selecting the second one, the first
> dropdown
> > selections are lost,
>
> See comments above. Make the lists global.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Multiple muti-selection dropdown options

2017-02-23 Thread Pooja Bhalode
Hi,

I am working on GUI where I have two dropdown menus in a Toplevel of the
main root. Here, both the dropdown menus have mutiple selection option and
thus, the selections can be taken as an input from the user and printed out
in the code.

The window shows as below:
[image: Inline image 1]
Whereas the code is:

simroot = Toplevel(root)
simroot.title("Simulation of experiments")

Label(simroot, text = "Displaying concentration profiles with respect to
time:").grid(row = 0, column = 0, sticky = W)

Label(simroot, text = "Select the experiments to be displayed: ").grid(row
= 1, column = 0, sticky = W)
varlist = StringVar()
varlist.set("Experiment1 Experiment2 Experiment3 Experiment4 Experiment5")
scroll1 = Scrollbar(simroot, orient = "vertical")
scroll1.grid(column = 2, sticky = W)

lstbox = Listbox(simroot, listvariable = varlist, selectmode = MULTIPLE,
yscrollcommand = scroll1.set, width = 20, height = 3)
lstbox.grid(row = 2, column = 1, sticky = W)
scroll1.config(command = lstbox.yview)

def selectexp():
newlist = list()
selection = lstbox.curselection()
for i in selection:
tempvar = lstbox.get(i)
newlist.append(tempvar)

for val in newlist:
print (val)


selectbutt = Button(simroot, text = "Submit", command = selectexp)
selectbutt.grid(row = 6,column = 1, sticky = W)
# Row 1 would print the name of the experiment selected and the species
displayed would be in row3.

Label(simroot, text = "Select concentration species:").grid(row = 7, column
= 0, sticky = W)
concvarlist = StringVar()
concvarlist.set("A B C D E")
scroll2 = Scrollbar(simroot, orient = "vertical")
scroll2.grid(column = 2, sticky = W)
lstbox2 = Listbox(simroot, listvariable = concvarlist, selectmode =
MULTIPLE, yscrollcommand = scroll2.set, width = 20, height = 3)
lstbox2.grid(row = 8, column = 1, sticky = W)
scroll2.config(command = lstbox2.yview)
def selectexp2():
newlist2 = list()
selection2 = lstbox2.curselection()
for i in selection2:
tempvar2 = lstbox2.get(i)
newlist2.append(tempvar2)

for val in newlist2:
print (val)
selectbutt = Button(simroot, text = "Submit", command = selectexp2)
selectbutt.grid(row = 9,column = 1, sticky = W)


def Submitplot():
print "Create plot"

Button(simroot, text = "Submit and Plot", command = Submitplot).grid(row =
10, column = 0, sticky = W)

However, the issue is that when the user selects options from the first
dropdown menu and moves on to selecting the second one, the first dropdown
selections are lost, is there a way to store the highlighted selections on
the display screen? In the code, I can get them printed and save the
selections, however I was looking for a way to keep them highlighted on the
screen as well for both the drop down menus.
Please let me know.
Thank you

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


Re: [Tutor] Matplotlib in Tkinter

2017-02-20 Thread Pooja Bhalode
Hi,

Another issue, in this that is happening  which is far more important from
the perspective that I am looking at, is that when I click the button
twice, two graphs get created one below the other.

I tried adding a delete("all") statement as shown below.
Code:
  def Submitplot():
print "Create plot"
print concsim.get()
f = Figure(figsize = (5,5), dpi = 80)
canvas = FigureCanvasTkAgg(f, simroot)
canvas.get_tk_widget().delete("all")
a = f.add_subplot(111)
a.plot([1,2,3,4,5],[10,11,12,14,15])
canvas.show()
canvas.get_tk_widget().pack(side = TOP)

toolbar = NavigationToolbar2TkAgg(canvas, simroot)
toolbar.update()
canvas._tkcanvas.pack(side = TOP)

Button(simroot, text = "Submit and Plot", command = Submitplot).pack(side =
TOP)

But this still does not clear the earlier made canvas and creates another
graph at the bottom. Can someone please tell me what I am doing wrong here?
I would really appreciate it.
I have also added the image as to how the two plots look like.
[image: Inline image 1]

Thankyou


On Sun, Feb 19, 2017 at 2:36 PM, Pooja Bhalode <poojabhalod...@gmail.com>
wrote:

> Hi,
>
> I am trying to create a graph in Tkinter window. And following is a snipet
> of the code.
>
> Code:
>   simroot = Toplevel(root)
> simroot.title("Simulation of experiments")
> Label(simroot, text = "Displaying concentration profiles with respect to
> time:").pack(side = TOP)
>
> Label(simroot, text = "Select the experiments to be displayed:
> ").pack(side = TOP)
> optionexp = ['Experiment 1', 'Experiment 2', 'Experiment 3', 'Experiment
> 4', 'Experiment 5']
> expsim = StringVar()
> dropexp = OptionMenu(simroot, expsim, *optionexp)
> dropexp.pack(side = TOP)
> dropexp.config(width = 15)
>
> # Row 1 would print the name of the experiment selected and the species
> displayed would be in row3.
> Label(simroot, text = "Select concentration species:").pack(side = TOP)
> concsim = StringVar()
> optionlistsim = ['A', 'B', 'C', 'D', 'E']
> dropsim = OptionMenu(simroot, concsim, *optionlistsim)
> dropsim.pack(side = TOP)
> dropsim.config(width = 8)
> Label(simroot, text = "").pack(side = LEFT)
>
> def Submitplot():
> print "Create plot"
>
> f = Figure(figsize = (5,5), dpi = 80)
> a = f.add_subplot(111)
> a.plot([1,2,3,4,5],[10,11,12,14,15])
>
> canvas = FigureCanvasTkAgg(f, simroot)
> canvas.show()
> canvas.get_tk_widget().pack(side = BOTTOM)
>
> toolbar = NavigationToolbar2TkAgg(canvas, simroot)
> toolbar.update()
> canvas._tkcanvas.pack(side = BOTTOM)
> Button(simroot, text = "Submit and Plot", command = Submitplot).pack(side
> = BOTTOM)
>
> Here, the output comes as:
> [image: Inline image 1]
> The problem is I am not able to use grid layout instead of pack (used
> here). I want to place the text to the left, top side in the window.
>
> Also, when I hover the mouse over the figure and the x and y values are
> shown, it flickers really fast and the white space in the Tkinter window
> turns black when it flickers. Can someone please tell me what the issue
> could be? Also, the toolbar should have been at the bottom but it shows up
> at the top.
>
> I am using pack in this Toplevel of the main root whereas in the rest of
> the code, I am using grid layout. I switched to pack for this
> snipet because I could not figure out how grid would work for this part.
>
> Can someone please let me know how to correct these issues?
> Thankyou so much.
>
> Pooja
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Matplotlib in Tkinter

2017-02-19 Thread Pooja Bhalode
Hi,

I am trying to create a graph in Tkinter window. And following is a snipet
of the code.

Code:
  simroot = Toplevel(root)
simroot.title("Simulation of experiments")
Label(simroot, text = "Displaying concentration profiles with respect to
time:").pack(side = TOP)

Label(simroot, text = "Select the experiments to be displayed: ").pack(side
= TOP)
optionexp = ['Experiment 1', 'Experiment 2', 'Experiment 3', 'Experiment
4', 'Experiment 5']
expsim = StringVar()
dropexp = OptionMenu(simroot, expsim, *optionexp)
dropexp.pack(side = TOP)
dropexp.config(width = 15)

# Row 1 would print the name of the experiment selected and the species
displayed would be in row3.
Label(simroot, text = "Select concentration species:").pack(side = TOP)
concsim = StringVar()
optionlistsim = ['A', 'B', 'C', 'D', 'E']
dropsim = OptionMenu(simroot, concsim, *optionlistsim)
dropsim.pack(side = TOP)
dropsim.config(width = 8)
Label(simroot, text = "").pack(side = LEFT)

def Submitplot():
print "Create plot"

f = Figure(figsize = (5,5), dpi = 80)
a = f.add_subplot(111)
a.plot([1,2,3,4,5],[10,11,12,14,15])

canvas = FigureCanvasTkAgg(f, simroot)
canvas.show()
canvas.get_tk_widget().pack(side = BOTTOM)

toolbar = NavigationToolbar2TkAgg(canvas, simroot)
toolbar.update()
canvas._tkcanvas.pack(side = BOTTOM)
Button(simroot, text = "Submit and Plot", command = Submitplot).pack(side =
BOTTOM)

Here, the output comes as:
[image: Inline image 1]
The problem is I am not able to use grid layout instead of pack (used
here). I want to place the text to the left, top side in the window.

Also, when I hover the mouse over the figure and the x and y values are
shown, it flickers really fast and the white space in the Tkinter window
turns black when it flickers. Can someone please tell me what the issue
could be? Also, the toolbar should have been at the bottom but it shows up
at the top.

I am using pack in this Toplevel of the main root whereas in the rest of
the code, I am using grid layout. I switched to pack for this
snipet because I could not figure out how grid would work for this part.

Can someone please let me know how to correct these issues?
Thankyou so much.

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


[Tutor] Creating tables in Tkinter

2017-02-19 Thread Pooja Bhalode
Hi,

I am trying to create a simple table. But I was wondering how do I get the
title of the table to span over multiple columns in the first row.
Code:

from Tkinter import *

root = Tk()
root.geometry("700x500")
Label(root, text = "Table 1").grid(row = 0, column = 0, sticky = W)
Label
for i in range(1,11):

Label(root, text = i).grid(row = 1, column = i+1, sticky = W)
Label(root, text = i).grid(row = i+1, column = 0, sticky = W)

for j in range(1, 11):
Label(root, text = i*j).grid(row= i+1, column = j+1, sticky = W)
root.mainloop()

It opens a Tkinter window:
[image: Inline image 1]
So, here, how do I make the Table 1 span over the column range, or insert a
title: Table 1 multiplication table such that it doesn't affect the spacing
below. I am using grid packing in the code.

Also, how to make the labels for columns and rows: such that the labels are
placed in the centre of the range.

Thank you so much.

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


Re: [Tutor] Problems with matplotlib

2017-02-19 Thread Pooja Bhalode
Hi Peter,

Thank you for that advice, that worked after I deleted the copy.py that I
had created.

Hope you are having a great weekend.

Thanks
Pooja

On Sat, Feb 18, 2017 at 7:32 PM, Peter Otten <__pete...@web.de> wrote:

> Pooja Bhalode wrote:
>
> > Hi,
> >
> > I am trying to create a simple normal plot. But I am getting some
> > errors which I am not able to understand. Would be a great help if
> someone
> > can guide me to what I am doing wrong.
> >
> > Thankyou so much.
> > Here is the code:
> >
> > # import matplotlib.pyplot as plt
> > from matplotlib import pyplot as plt
> > (Here, I have tried both these import statements, but both give me the
> > same error.)
> >
> > x = [1,2,4,5,6,8,9,10]
> > y = [6,7,8,9,10,11,12,14]
> > plt.figure()
> > plt.plot(x,y)
> > plt.show()
> >
> > Error:
> >
> > /Users/poojabhalode/.bash_profile: line 1: .bashrc: No such file or
> > directory
> > Traceback (most recent call last):
> >   File "/Users/poojabhalode/Google Drive/GUI Python/matplot.py", line 3,
> >   in
> > 
> > from matplotlib import pyplot as plt
> >   File
> >
> "/System/Library/Frameworks/Python.framework/Versions/2.7/
> Extras/lib/python/matplotlib/__init__.py",
> > line 123, in 
> > import pyparsing
> >   File
> >
> "/System/Library/Frameworks/Python.framework/Versions/2.7/
> Extras/lib/python/pyparsing.py",
> > line 3260, in 
> > _reBracketExpr = Literal("[") + Optional("^").setResultsName("
> negate")
> > + Group( OneOrMore( _charRange | _singleChar ) ).setResultsName("body") +
> > "]"
> >   File
> >
> "/System/Library/Frameworks/Python.framework/Versions/2.7/
> Extras/lib/python/pyparsing.py",
> > line 775, in setResultsName
> > newself = self.copy()
> >   File
> >
> "/System/Library/Frameworks/Python.framework/Versions/2.7/
> Extras/lib/python/pyparsing.py",
> > line 749, in copy
> > cpy = copy.copy( self )
> > AttributeError: 'module' object has no attribute 'copy'
> > [Finished in 2.4s with exit code 1]
> > [shell_cmd: python -u "/Users/poojabhalode/Google Drive/GUI
> > Python/matplot.py"]
> > [dir: /Users/poojabhalode/Google Drive/GUI Python]
> > [path: /usr/bin:/bin:/usr/sbin:/sbin]
> >
> > I am running this on the inbuilt python in Mac10.12
> > When I try running the same in terminal it works, but here it is not able
> > to compile.
> > Please let me know.
>
> You have a file copy.py, probably written by yourself, that shades the copy
> module in Python's standard library. To locate this module (if it is not in
> the current working directory) add the lines
>
> import copy
> print copy.__file__
>
> If I'm guessing right everything should work after you have removed the
> pyc-
> file and renamed the corresponding copy.py.
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Problems with matplotlib

2017-02-18 Thread Pooja Bhalode
Hi,

I am trying to create a simple normal plot. But I am getting some
errors which I am not able to understand. Would be a great help if someone
can guide me to what I am doing wrong.

Thankyou so much.
Here is the code:

# import matplotlib.pyplot as plt
from matplotlib import pyplot as plt
(Here, I have tried both these import statements, but both give me the same
error.)

x = [1,2,4,5,6,8,9,10]
y = [6,7,8,9,10,11,12,14]
plt.figure()
plt.plot(x,y)
plt.show()

Error:

/Users/poojabhalode/.bash_profile: line 1: .bashrc: No such file or
directory
Traceback (most recent call last):
  File "/Users/poojabhalode/Google Drive/GUI Python/matplot.py", line 3, in

from matplotlib import pyplot as plt
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py",
line 123, in 
import pyparsing
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pyparsing.py",
line 3260, in 
_reBracketExpr = Literal("[") + Optional("^").setResultsName("negate")
+ Group( OneOrMore( _charRange | _singleChar ) ).setResultsName("body") +
"]"
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pyparsing.py",
line 775, in setResultsName
newself = self.copy()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pyparsing.py",
line 749, in copy
cpy = copy.copy( self )
AttributeError: 'module' object has no attribute 'copy'
[Finished in 2.4s with exit code 1]
[shell_cmd: python -u "/Users/poojabhalode/Google Drive/GUI
Python/matplot.py"]
[dir: /Users/poojabhalode/Google Drive/GUI Python]
[path: /usr/bin:/bin:/usr/sbin:/sbin]

I am running this on the inbuilt python in Mac10.12
When I try running the same in terminal it works, but here it is not able
to compile.
Please let me know.

Thankyou.

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


Re: [Tutor] Select and deselect for multiple checkboxes in Tkinter

2017-02-18 Thread Pooja Bhalode
Hi Alan,

Thank you for your input. That was an easy fix to it.
Thanks a lot.

Pooja

On Fri, Feb 17, 2017 at 8:23 PM, Alan Gauld via Tutor <tutor@python.org>
wrote:

> On 17/02/17 18:31, Pooja Bhalode wrote:
>
> > I am writing to create two buttons, for selecting and de-selecting
> multiple
> > checkboxes that I have created previously. These checkboxes have
> different
> > variables that they are associated with for their values and thus cannot
> > create a loop for the same.
>
> You can still use a loop by putting the variables in
> a list/tuple:
>
> checkboxVars = [keqparam,delHrxnparam,kfparam,Afparam,RCparam]
>
> for var in checkboxVars:
> var = 0  #or whatever.
>
> You can even use different reset values if necessary
> by putting them in tuples:
>
> checkboxVars = [(keqparam,0),(delHrxnparam,1),
> (kfparam,2),(Afparam,
>  ...(RCparam,42)]
>
> for var,val in checkboxVars:
> var = val  #or whatever.
>
> HTH
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Select and deselect for multiple checkboxes in Tkinter

2017-02-17 Thread Pooja Bhalode
Hi,

I am writing to create two buttons, for selecting and de-selecting multiple
checkboxes that I have created previously. These checkboxes have different
variables that they are associated with for their values and thus cannot
create a loop for the same.

Is there any way that I could create the above-mentioned buttons, without
having to manually select/deselect each checkbox under a select/deselect
function associated with the buttons?

Checkboxes are as shown below:
Checkbutton(paramroot, text = "K_eq", variable = keqparam).grid(row = 2,
column = 1, sticky = W)
Checkbutton(paramroot, text = "Hrxn", variable = delHrxnparam).grid(row =
3, column = 1, sticky = W)
Checkbutton(paramroot, text = "Kf", variable = kfparam).grid(row = 4,
column = 1, sticky = W)
Checkbutton(paramroot, text = "Af", variable = Afparam).grid(row = 5,
column = 1, sticky = W)
Checkbutton(paramroot, text = "k", variable = ksimparam).grid(row = 11,
column = 1, sticky = W)
Checkbutton(paramroot, text = "A", variable = Aparam).grid(row = 12, column
= 1, sticky = W)

Checkbutton(paramroot, text = "Reactant A", variable = RAparam).grid(row =
13, column = 2, sticky = W)
Checkbutton(paramroot, text = "Reactant B", variable = RBparam).grid(row =
14, column = 2, sticky = W)
Checkbutton(paramroot, text = "Reactant C", variable = RCparam).grid(row =
15, column = 2, sticky = W)

Please let me know.
Thank you

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


Re: [Tutor] Accessing an entry value input by the user

2017-02-12 Thread Pooja Bhalode
Hi Alan,

Thank you so much for providing me your input on these things. I made all
the corrections to the code as per you suggested.

Thank you so much. I got stuck in another section:

Code:

from Tkinter import *


root=Tk()
root.title("Design Point Suggestions")
root.geometry("650x400")
frame1 = Frame(root)
frame1.grid(row=0, column=0)
entrynumberspeciesvar = IntVar()
Label(frame1, text="1. Responses to include: ").grid(row=0,
column=0,sticky=W )
Label(frame1, text = "Number of species:").grid(row=0, column = 1, sticky=W)
entrynumberspecies = Entry(frame1, textvariable = entrynumberspeciesvar)
entrynumberspecies.grid(row=0, column = 2, sticky=W)

conclowerentry = []
concupperentry = []

def Print():
print entrynumberspeciesvar.get()
for i in range(entrynumberspeciesvar.get()):
conclowertemp = StringVar()
concuppertemp = StringVar()

textvar = "\t Conc"+str(i+1)
Label(frame1, text=textvar).grid(row=(9+i), column=0,sticky=W)
Entry(frame1, textvariable = conclowertemp).grid(row= (9+i), column
= 1, sticky = W)
Entry(frame1, textvariable = concuppertemp).grid(row= (9+i), column
= 2, sticky = W)

if len(concuppertemp.get()) != 0 and len(conclowertemp.get()) != 0:
concupperentry.append(int(concuppertemp.get()))
conclowerentry.append(int(conclowertemp.get()))

def Submit():
print "Submitted. "
print conclowerentry.get()
print concupperentry.get()

Button(frame1, text="Submit", command = Submit).grid(row = 2,
column = 1, sticky = W)

Button(frame1, text = "Click", command = Print).grid(row = 2, column = 2,
sticky = W)
root.mainloop()

print conclowerentry
print concupperentry

This creates a window as given below:
[image: Inline image 1]
where the user inputs the number and the corresponding number of entry
boxes and labels get created.
Submit button is used for storing in the values in a list and then
printing.

But here, I am not able to store the value associated with each entry boxes
in the created list.
Can you please let me know where I am going wrong?
Thank you Alan.

Pooja

On Sat, Feb 11, 2017 at 8:03 PM, Alan Gauld via Tutor <tutor@python.org>
wrote:

> On 11/02/17 18:59, Pooja Bhalode wrote:
> > Hi Alan,
> >
> > I had done what you suggested here, I also tried creating another file
> for
> > that snipet of the code to see if that section works. The other file
> works,
> > but I am not able to figure out why the original one doesn't work.
>
> Too late at night for a detailed analysis but your code
> should be restructured its ghetting very messy and hard
> to see whats going on. More on that another time.
> Meanwhile some immediate thoughts...
>
> > from Tkinter import *
> > import datetime
> > import tkMessageBox
> > from tkFileDialog import *
> > from tkMessageBox import *
>
> If you do this there's no point in importing tkmessagebox earlier.
>
> > root = Tk()
> > root.title("Design of Experiments with Parameter Estimation")
> > root.geometry("1000x1000")
> >
> > statusvar = StringVar()
> > statusvar = "Status Bar"
>
> You create the stringvar but then throw it waay by overwriting it with a
> string.
>
> Maybe you meant to do:
>
> statusvar = StringVar()
> statusvar.set("Status Bar")
>
> ???
>
>
> > var1 = IntVar()
> > var2 = IntVar()
> > var3 = IntVar()
> > var4 = IntVar()
> >
> > varreac = IntVar()
> > varint = IntVar()
> > varpro = IntVar()
> >
> > varconc = IntVar()
> > vartemp = IntVar()
> > entrynumberspeciesvar = IntVar()
>
> You can only use a stringvar with an Entry because
> the Entry only holds text, not integers. You will
> need to do the conversions yourself when you set/get
> the values.
>
> > def DesignPoint():
> > print "Inside Design Point"
> > rootdesign=Tk()
>
> You are still creating multiple roots, that is
> really bad practice and almost sure to create
> problems later. Define the function as:
>
> def DesignPoint(root):...
>
> and call it as
>
> DesignPoint(root)
>
> > rootdesign.title("Design Point Suggestions")
> > rootdesign.geometry("700x400")
> > frame1 = Frame(rootdesign)
> > frame1.grid(row=0, column=0)
> >
>
> If you want a second window you should be
> using a Toplevel widget not Frame here.
>
>
> > label1 = Label(frame1, text="1. Responses to include: ")
> > label1.grid(row=0, column=0,sticky=W)
> >
> >
> > Label(frame1, text = "Number of specie

Re: [Tutor] Accessing an entry value input by the user

2017-02-11 Thread Pooja Bhalode
")
label1.grid(row=0, column=0,sticky=W )
Label(frame1, text = "Number of species:").grid(row=0, column = 1, sticky=W)
entrynumberspecies = Entry(frame1, textvariable = entrynumberspeciesvar)
entrynumberspecies.grid(row=0, column = 2, sticky=W)

def Print():
print entrynumberspeciesvar.get()
for i in range(entrynumberspeciesvar.get()):
print i
textvar = "\t Conc"+str(i+1)
Label(frame1, text=textvar).grid(row=(9+i), column=0,sticky=W)
conclowerentry = Entry(frame1)
conclowerentry.grid(row= (9+i), column = 1, sticky = W)
concupperentry = Entry(frame1)
concupperentry.grid(row= (9+i), column = 2, sticky = W)

Button(frame1, text = "Click", command = Print).grid(row = 2, column = 2,
sticky = W)
Label(frame1, text="\t Temperature").grid(row=8, column=0,sticky=W)
templowerentry = Entry(frame1, text="0.0")
templowerentry.grid(row= 8, column = 1, sticky = W)
tempupperentry = Entry(frame1)
tempupperentry.grid(row= 8, column = 2, sticky = W)
rootdesign.mainloop()


Please let me know where I am going wrong. Thank you so much.
Pooja

On Sat, Feb 11, 2017 at 12:52 PM, Alan Gauld via Tutor <tutor@python.org>
wrote:

> On 11/02/17 15:28, Pooja Bhalode wrote:
>
> > I am trying to create a label and an entry widget. I am not able to
> > understand as to how to access the value input by the user in the entry
> > widget.
> >
> > Label(frame1, text = "Number of species:").grid(row=0, column = 1,
> sticky=W)
> > entrynumberspecies = Entry(frame1)
> > entrynumberspecies.grid(row=0, column = 2, sticky=W)
> >
> > print entrynumberspecies.get()
>
> You just accessed it, via the get() method. Did that not work?
>
> > How can I make the entrynumberspecies store the value in once the user
> > inputs it and then use that value for later part of my code?
>
> You can do it the way you did above using the get() method.
>
> But you can also do what you did for the checkboxes - use
> a StringVar and attach it to the Entry widget textvariable
> attribute. That way the variable will reflect whats in
> the Entry automatically and if you update the variable
> it will update the Entry. (Personally I prefer to use
> get() in most cases but many use the StringVar technique.)
> See the example at the bottom...
>
> > or print it for that matter.
>
> You can print it as you did above or you can store it in
> a variable and then print it or you can print the StringVar:
>
> print myEntry.get()
>
> myVar = MyEntry.get()
> print myVar
>
> entryVar = StringVar()
> myEntry = Entry(.textvariable=entryVar)
> print entryVar.get()
>
> Here is a minimal example:
>
> 
> from Tkinter import *
>
> def show():
> print "entry says: " + e.get()
> print "Variable holds: " + v.get()
>
> top = Tk()
> v = StringVar()
> e = Entry(top,textvariable=v)
> e.pack()
> Button(top,text="Set foobar", command=lambda : v.set("foobar")).pack()
> Button(top,text="Show me", command=show).pack()
>
> top.mainloop()
> #
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Accessing an entry value input by the user

2017-02-11 Thread Pooja Bhalode
Hi,

I am trying to create a label and an entry widget. I am not able to
understand as to how to access the value input by the user in the entry
widget.

Label(frame1, text = "Number of species:").grid(row=0, column = 1, sticky=W)
entrynumberspecies = Entry(frame1)
entrynumberspecies.grid(row=0, column = 2, sticky=W)

print entrynumberspecies.get()

How can I make the entrynumberspecies store the value in once the user
inputs it and then use that value for later part of my code? or print it
for that matter.

Thank you

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


Re: [Tutor] CheckButtons reset to default values

2017-02-10 Thread Pooja Bhalode
Hi Peter,

The code is as shown below.  I have put it in the manner you have told me.

root = Tk()
root.title("Design of Experiments with Parameter Estimation")
root.geometry("1000x1000")

def DesignPoint():
print "Inside Design Point"
rootdesign=Tk()
rootdesign.title("Estimation of Experimental Precision for Data
Var-CoVar")
rootdesign.geometry("600x400")
frame1 = Frame(rootdesign)
frame1.grid(row=0, column=0)

## Inserting Checkboxes:
label1 = Label(frame1, text="1. Design Point Suggestions")
label1.grid(row=0, column=0,sticky=W )
var1 = IntVar()
var2 = IntVar()
var3 = IntVar()
var4 = IntVar()
Checkbutton(frame1, text = "Vertices", variable=var1, onvalue=1,
offvalue=0).grid(row=1, column = 1, sticky=W)
Checkbutton(frame1, text = "Edges", variable=var2).grid(row=2, column =
1, sticky=W)
Checkbutton(frame1, text = "Faces", variable=var3).grid(row=3, column =
1, sticky=W)
check = Checkbutton(frame1, text = "Center", variable=var4)
check.grid(row=4, column = 1, sticky=W)
check.select()


label2 = Label(frame1, text="2. Cut off Improvement %")
label2.grid(row=5, column=0,sticky=W)
Entry2 = Entry(frame1)
Entry2.insert(END, '05')
Entry2.grid(row=5, column = 1, sticky = W)

label3 = Label(frame1, text="3. Simulation of proposed Experiments: ")
label3.grid(row=5, column=0,sticky=W)

label4 = Label(frame1, text="4. Calculate sensitivities")
label4.grid(row=6, column=0,sticky=W)

def default():
print "Inside default"

var1.set(0)
var2.set(0)
var3.set(0)
var4.set(1)
Entry2.delete(0, END)
Entry2.insert(END,'05')
   Button(frame1, text = "Select Default value",
command=default.grid(row=0, column = 2, sticky=W)

rootdesign.mainloop()


## Secondary menu bar:
menusec = Frame(root, bg="white")
butt1 = Button(menusec, text="Part One", command=DesignPoint)
butt1.pack(side=LEFT, padx=1)
menusec.pack(side=TOP, fill=X)


root.mainloop()

It still doesn't work for me for the reason I am not able to figure out.
Please let me know.
Thank you once again in advance.

Pooja

On Fri, Feb 10, 2017 at 4:48 AM, Peter Otten <__pete...@web.de> wrote:

> Pooja Bhalode wrote:
>
> > Hi,
> >
> > I have a bunch of checkbuttons in my code and a default settings button
> > which restores the original setting in the checkbuttons. The code is
> given
> > below:
> >
> >
> > var1 = IntVar()
> > var2 = IntVar()
> > var3 = IntVar()
> > var4 = IntVar()
> > Checkbutton(frame1, text = "Vertices", variable=var1, onvalue=1,
> > offvalue=0).grid(row=1, column = 1, sticky=W)
> > Checkbutton(frame1, text = "Edges", variable=var2).grid(row=2, column
> > =
> > 1, sticky=W)
> > Checkbutton(frame1, text = "Faces", variable=var3).grid(row=3, column
> > =
> > 1, sticky=W)
> > check = Checkbutton(frame1, text = "Center", variable=var4)
> > check.grid(row=4, column = 1, sticky=W)
> > check.select()
> >
> > label2 = Label(frame1, text="2. Cut off Improvement %")
> > label2.grid(row=5, column=0,sticky=W)
> > Entry2 = Entry(frame1)
> > Entry2.insert(END, '05')
> > Entry2.grid(row=5, column = 1, sticky = W)
> >
> > def default():
> > print "Inside default"
> >
> > var1.set(0)
> > var2.set(0)
> > var3.set(0)
> > var4.set(1)
> > Entry2.delete(0, END)
> > Entry2.insert(END,'05')
> >
> > Button(frame1, text = "Select Default value",
> > command=default).grid(row=0, column = 2, sticky=W)
> >
> >
> > This resets the Entry2 but it does not reset the checkbuttons selection
> to
> > the values specified in default function.
> > Can some one please tell me where I am going wrong?
>
> The problem has to be elsewhere in your code. If I run a script
>
> from Tkinter import *
>
> root = frame1 = Tk()
>
> if 1:
># your snippet shown above goes here
>
> root.mainloop()
>
> clicking the button unchecks Vertices, Edges, Faces and checks Center.
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] CheckButtons reset to default values

2017-02-10 Thread Pooja Bhalode
Hi,

I have a bunch of checkbuttons in my code and a default settings button
which restores the original setting in the checkbuttons. The code is given
below:


var1 = IntVar()
var2 = IntVar()
var3 = IntVar()
var4 = IntVar()
Checkbutton(frame1, text = "Vertices", variable=var1, onvalue=1,
offvalue=0).grid(row=1, column = 1, sticky=W)
Checkbutton(frame1, text = "Edges", variable=var2).grid(row=2, column =
1, sticky=W)
Checkbutton(frame1, text = "Faces", variable=var3).grid(row=3, column =
1, sticky=W)
check = Checkbutton(frame1, text = "Center", variable=var4)
check.grid(row=4, column = 1, sticky=W)
check.select()

label2 = Label(frame1, text="2. Cut off Improvement %")
label2.grid(row=5, column=0,sticky=W)
Entry2 = Entry(frame1)
Entry2.insert(END, '05')
Entry2.grid(row=5, column = 1, sticky = W)

def default():
print "Inside default"

var1.set(0)
var2.set(0)
var3.set(0)
var4.set(1)
Entry2.delete(0, END)
Entry2.insert(END,'05')

Button(frame1, text = "Select Default value",
command=default).grid(row=0, column = 2, sticky=W)


This resets the Entry2 but it does not reset the checkbuttons selection to
the values specified in default function.
Can some one please tell me where I am going wrong?
Thank you so much.

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


[Tutor] Explorer bar window(wxpython) combined to Tkinter

2017-02-08 Thread Pooja Bhalode
Hi,

I have been working on creating an explorer bar in GUI. I found the code
the explorer bar online using wx python. This creates a window shown below.
[image: Inline image 1]

But, I want to create this in the original GUI window that I am working in
using Tkinter. However, when I tried importing it, I am not able to
understand how to deal with different roots,

wxpython:
root = wx.App(False)

Tkinter
root = Tk()

The code for the wxpython is given below:
import os
import wx

class MainWindow(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)

self.panel = wx.Panel(self)
self.dir = wx.GenericDirCtrl(self.panel, size=(200, -1),
style=wx.DIRCTRL_DIR_ONLY)
self.files = wx.ListCtrl(self.panel, style=wx.LC_LIST)

self.sizer = wx.BoxSizer()
self.sizer.Add(self.dir, flag=wx.EXPAND)
self.sizer.Add(self.files, proportion=1, flag=wx.EXPAND)

self.border = wx.BoxSizer()
self.border.Add(self.sizer, 1, wx.ALL | wx.EXPAND, 5)

self.panel.SetSizerAndFit(self.border)
self.Show()

self.dir.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelect)


def OnSelect(self, e):
self.files.ClearAll()
list = os.listdir(self.dir.GetPath())
for a in reversed(list):
self.files.InsertStringItem(0, a)

root = wx.App(False)

win = MainWindow(None, size=(600, 400))
root.MainLoop()

whereas the code for the GUI that I am working on using Tkinter is given
below:

from Tkinter import *
import datetime
import tkMessageBox
from tkFileDialog import *
from tkMessageBox import *

root = Tk()
root.title("Design of Experiments with Parameter Estimation")
root.geometry("1000x1000")

menu = Menu(root)

root.config(menu=menu)

submenu = Menu(menu)
menu.add_cascade(label="File", menu=submenu)

submenu.add_command(label="New", command=NewWindow)
submenu.add_command(label="Open", command=OpenFile)
submenu.add_command(label="Load", command=LoadNew)
submenu.add_separator()
submenu.add_command(label="Save", command=save)
submenu.add_command(label="Save As", command=Doit)

root.mainloop()

The GUI shows as below:

[image: Inline image 2]


Can someone please tell me how to combine these two so that the
Explorer bar shows up in the space shown in the figure.

Thank you so much in advance.

Yours truly,

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


Re: [Tutor] Tkinter Calendar to receive user entry.

2017-02-07 Thread Pooja Bhalode
Hi Alan,

Thank you so much for your advice, I would start looking into learning some
object oriented programming to make myself familiar with it. That would
help me move ahead as well.

Hi Peter,

Thank you so much for your reply. Yes, that was the example that I was
looking at on stackoverflow. Yes, it works for me as well now. Thanks a lot
for your help there.

Yours truly,
Pooja

On Tue, Feb 7, 2017 at 5:18 AM, Peter Otten <__pete...@web.de> wrote:

> Alan Gauld via Tutor wrote:
>
> > On 07/02/17 00:24, Pooja Bhalode wrote:
> >
> >> I am trying to create a calendar using tkinter GUI such that when the
> >> user opens the GUI,
> >
> > So far as I'm aware there is no such Calendar widget in the standard
> > modules, you would need to find a third party module.
> >
> >> Can some one please help me with this? I looked up on the website, I
> came
> >> across this one,
> >> http://stackoverflow.com/questions/27774089/
> >> python-calendar-widget-return-the-user-selected-date
> >> But when I try to run it, it gives me an error saying that it is not
> able
> >> to recognize Calendar.
> >
> > I'm really puzzled by that post because there is non Calendar widget
> > in ttk (or Tix) as of Python 3.4. They are discussing code that
> > should not work but they seem to have it working. I assume there
> > is a non standard ttk module out there somewhere?
>
> The question on stackoverflow points to
>
> http://svn.python.org/projects/sandbox/trunk/ttk-
> gsoc/samples/ttkcalendar.py
>
> A few imports are sufficient to turn test2() from the answer into a working
> script (python 2):
>
> $ cat demo.py
> #!/usr/bin/env python
> import calendar
> import ttk
> import Tkinter
> from ttkcalendar import Calendar
>
> def test2():
> import sys
> root = Tkinter.Tk()
> root.title('Ttk Calendar')
> ttkcal = Calendar(firstweekday=calendar.SUNDAY)
> ttkcal.pack(expand=1, fill='both')
>
> if 'win' not in sys.platform:
> style = ttk.Style()
> style.theme_use('clam')
>
> root.mainloop()
>
> x = ttkcal.selection
> print 'x is: ', x
>
> test2()
> $ ./demo.py
> x is:  2017-05-11 00:00:00
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Multiple tabs using tkinter

2017-02-07 Thread Pooja Bhalode
Hi Alan and Zackary,

Thank you so much for your inputs. I really appreciate any help on these
things.

Alan,

you mentioned that there are multiple toolkits which can be used instead of
tkinter. I was also looking into wxpython for building a explorer bar.
Mainly, I have to build a software entirely using python and thus, needed
all these things put in place. I have been exploring things on how to do
small bits of these using Tkinter. Would you suggest me to use some other
toolkit instead of tkinter or maybe combine and use whichever whenever
needed?

I was just going through your website and looking at the tutorials, wanted
to thank you. I think those would be really really helpful.

Zackary,

I tried using ttk for the multiple tabs feature and that worked out really
nicely.
Thank you once again.
I would also look into the ttk.Combobox package. Thank you

Yours truly,
Pooja


On Mon, Feb 6, 2017 at 10:31 PM, Zachary Ware <zachary.ware+py...@gmail.com>
wrote:

> On Mon, Feb 6, 2017 at 7:31 PM, Alan Gauld via Tutor <tutor@python.org>
> wrote:
> > On 06/02/17 16:40, Pooja Bhalode wrote:
> >
> >> I was wondering if someone could help me regarding multiple tabs in
> >> tkinter.
> >
> > Look at the tabbed notebook in the Tix module.
> > It should do what you want.
>
> ttk rather than Tix; Tix is unmaintained and soft-deprecated in 3.6+.
> ttk provides most of the useful parts of Tix, is maintained as part of
> Tk, and also looks significantly more native than classic Tk or Tix.
> Tix is also less available on platforms other than Windows, whereas
> ttk is present in any Tk 8.5 or greater.
>
> > I give a tutorial on its use in my recent book but you can
> > also find online tutorials, especially in Tcl (Python ones
> > are much harder to find)
> >
> >> Also, I was wondering if there is a way in tkinter to create an explorer
> >> bar that we see in finder in OS Mac or windows. I found a way to do that
> >> using wxpython, but was wondering if there is a way using tkinter.
> >
> > Tkinter is a relatively low level GUI toolkit. You can
> > build most things but you have to start with the basic
> > widgets. So an explorer bar is just an Entry widget to
> > which you can attach any functionality you care to create.
>
> Also have a look at ttk.Combobox, which combines an Entry and Listbox
> (and, I think, if the list is long enough, a Scrollbar) into a
> drop-down menu widget.
>
> --
> Zach
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Tkinter Calendar to receive user entry.

2017-02-07 Thread Pooja Bhalode
Hi,

I am trying to create a calendar using tkinter GUI such that when the user
opens the GUI, it would show a drop down menu similar to the one seen on
flight websites for booking and then the user can select any specific date.
I need to make this such that the user can navigate between years and
months in the same window.

Can some one please help me with this? I looked up on the website, I came
across this one,
http://stackoverflow.com/questions/27774089/python-calendar-widget-return-the-user-selected-date
But when I try to run it, it gives me an error saying that it is not able
to recognize Calendar.

I would really appreciate some help with this. I also came to know that I
could use calendar.Calendar to create an object for the same, but I am not
good with working with objects and thus, not able to proceed or understand
how to link it up with GUI.

Please let me know.
Thankyou

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


[Tutor] Multiple tabs using tkinter

2017-02-06 Thread Pooja Bhalode
Hi,

I was wondering if someone could help me regarding multiple tabs in
tkinter.
I am working on a GUI which would have tabs similar to the ones we see in
excel, wherein we can navigate from one tab to the other and back. Could
you please direct me towards some information regarding how I should
proceed with this issue.
It would be a great help.

Also, I was wondering if there is a way in tkinter to create an explorer
bar that we see in finder in OS Mac or windows. I found a way to do that
using wxpython, but was wondering if there is a way using tkinter.
Please let me know. It would help me a lot. Would appreciate any help.
thank you

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


Re: [Tutor] Copy/Paste in Tkinter

2017-02-04 Thread Pooja Bhalode
Hi Alan,

Thank you so much for guiding me towards this. I am new to tkinter hence
not aware of all these features.
I am trying to find some simple examples, of how to use copy/paste/cut. I
do not have a text box, but a GUI similar to a word editor. I was wondering
if you could direct me towards or show me towards some simple examples of
the same, so that it would be easier to understand. I was learning from
youtube videos about this.
It would be a huge help. Thank you so much

Pooja

On Sat, Feb 4, 2017 at 5:32 AM, Alan Gauld via Tutor <tutor@python.org>
wrote:

> On 04/02/17 00:24, Pooja Bhalode wrote:
>
> > I am trying to write a simple Tkinter code in Python in order to
> > demonstrate select/copy/paste/cut functionalities using keyboard keys and
> > menu options.
>
> You are going a fairly long winded way about it.
> Rather than generating events use the Text/Entry
> widget methods directly.
>
> Check the documentation for the following methods:
>
> Text.get()   # copy
> Text.selection_get(...) # copy a selection
> Text.delete(...)  # cut
> Text.insert(...)  # paste
>
> To control selections look at the tag methods,
> but that is more complex.
>
> > def show_menu(e):
> > w = e.widget
> > # the_menu.entryconfigure("Select",command=lambda:
> > w.event_generate("<>"))
> > the_menu.entryconfigure("Cut",command=lambda:
> w.event_generate("<>"))
> > the_menu.entryconfigure("Copy",command=lambda:
> w.event_generate("<>"))
> > the_menu.entryconfigure("Paste",command=lambda:
>
> These should be in the create function. You don't need
> to configure the command every time you show the menu.
>
> > w.event_generate("<>"))
> > the_menu.tk.call("tk_popup", the_menu, e.x_root, e.y_root)
>
> You should only need to call the tk.call() method very,
> very rarely, there is usually a more direct way to do things.
>
> > root = Tkinter.Tk()
> > make_menu(root)
> >
> > e1 = Tkinter.Entry(); e1.pack()
> > e2 = Tkinter.Entry(); e2.pack()
>
> Shouldn't these Entries have a parent?
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Tkinter Copy/Paste/Cut functionalities

2017-02-04 Thread Pooja Bhalode
Hi,

I am new to tkinter and looking for some help with select/copy/paste
functionalities. I wish to keep these tabs in the Edit menu and as well as
be able to do it using the shortcut keys.
Here, I am trying to create a GUI and needed some help with that.
I came across some snippets of the code to do this but using a self class.
I was wondering if some one could help me create these functionalities in a
manner similar to the following code. (similar to the Quitcommand
function).

Another question I had, was how to make the status bar text as a variable
such that it keeps on displaying what is going on in the program?

I would really appreciate your help on this.
Thank you so much.

Pooja

Code:

from Tkinter import *
import datetime
import tkMessageBox

root = Tk()
root.title("Name of the interface")

def Doit():
   print "Inside the function"

from tkMessageBox import *

def Quitcommand():
if askyesno('Verify', 'Are you sure you want to quit?'):
if askyesno('Save file', 'Do you want to save the current file?'):
print 'Saving file'
root.quit()
else:
showinfo('Quit not implemented.')

def LoadNew():
print 'Loading new .gPROMS files'
# User enters the name of the to be executed.
if tkMessageBox.askyesno('Reading new file','Do you want to read
in the new files'):
print 'Reading new files. '

def show_about():
print 'HELP function'

from tkFileDialog import askopenfilename

def OpenFile():
name = askopenfilename()
print name

### --- Menu bar  
menu = Menu(root)
root.config(menu=menu)

editmenu = Menu(menu, tearoff=0)
menu.add_cascade(label="Edit", menu=editmenu)

editmenu.add_command(label="Cut",accelerator="Ctrl+X",command=DoCut)
editmenu.add_command(label="Copy",accelerator="Ctrl+C",command=DoCopy)
editmenu.add_command(label="Paste", accelerator="Ctrl+V"command=DoPaste)
editmenu.add_command(label="Make Changes", command=TimeAllowed)
editmenu.add_command(label="Line", command=Doit)


### --- Status bar  
Status = Label(root, text = 'Static',bd=1, relief=SUNKEN, anchor=W)
Status.pack(side=BOTTOM, fill=X)



root.mainloop()
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Copy/Paste in Tkinter

2017-02-04 Thread Pooja Bhalode
Hi,
I am trying to write a simple Tkinter code in Python in order to
demonstrate select/copy/paste/cut functionalities using keyboard keys and
menu options.
I tried looking up online, but I am finding examples of these in which they
create an event and then it is used:
eg.:

import Tkinter

def make_menu(w):
global the_menu
the_menu = Tkinter.Menu(w, tearoff=0)
# the_menu.add_command(label="Select")
the_menu.add_command(label="Cut")
the_menu.add_command(label="Copy")
the_menu.add_command(label="Paste")

def show_menu(e):
w = e.widget
# the_menu.entryconfigure("Select",command=lambda:
w.event_generate("<>"))
the_menu.entryconfigure("Cut",command=lambda: w.event_generate("<>"))
the_menu.entryconfigure("Copy",command=lambda: w.event_generate("<>"))
the_menu.entryconfigure("Paste",command=lambda:
w.event_generate("<>"))
the_menu.tk.call("tk_popup", the_menu, e.x_root, e.y_root)

root = Tkinter.Tk()
make_menu(root)

e1 = Tkinter.Entry(); e1.pack()
e2 = Tkinter.Entry(); e2.pack()
e1.bind_class("Entry", "", show_menu)

root.mainloop()

I was wondering if someone could please tell me a simplified different way
of doing this, that would be great. Thank you.

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


Re: [Tutor] Error: 'IndexedVar' object is not callable

2016-09-10 Thread Pooja Bhalode
Hi everyone,

I am sorry about the confusion earlier,
I am trying to run Pyomo environment in Python on sublime text editor.
Python version of 2.7.11. I am running the code in sublime itself.

The code is somewhat long, around 200 lines.
I can add snippets of it though.

Code:

m.z = ContinuousSet(bounds = (0,10))
m.t = ContinuousSet(bounds = (0,10))
where all the variables that I am defining, are varying along the z and t
direction.

Variables:
m.C = Var(m.z,m.t)
m.Cair = Var(m.z,m.t)
m.masswater = Var(m.z,m.t)
m.massair = Param(initialize = 1833.50)

that is C and Cair and all other variables are varying along z and t
direction.

After this, when I define the equations,

def _calculations(m,i,j):
if i == 0 or i == 1 or j == 0:
return Constraint.Skip

return m.wateraccumulated(j) == 916.50 - (m.C(i,j)*46*28/(28*18*1.205 +
m.C(i,j) * 46*28))*2750

if i == 0:
return m.vel(i,j) == m.inmassflowrate/ ((m.outerdiameter * m.outerdiameter
* m.pi/4)*m.densityfeed)
if i == 1:
return m.vel(i,j) == m.outmassflowrate/((m.outerdiameter * m.outerdiameter
* m.pi/4)*m.densityfeed)

return m.vel(i,j) == m.flowrate/((m.outerdiameter * m.outerdiameter *
m.pi/4)*m.densityfeed)
m.calculations = Constraint(m.z,m.t, rule = _calculations)

It tells me that TypeError: 'IndexedVar' object is not callable for m.C
itself. I think the syntax is correct but I am not able to figure out why
the variable is not callable.

I am aware that the language is slightly different than Python here, I am
just stuck and would appreciate any help here.

On Fri, Sep 9, 2016 at 9:49 PM, Alex Kleider  wrote:

> On 2016-09-09 18:13, Steven D'Aprano wrote:
>
>> Please read this article first for
>> how you can improve the chances of getting good answers to your
>> questions:
>>
>> http://sscce.org/
>>
>
> In addition to the link Seven provides above, I've also found the
> following to be worth perusing:
> http://www.catb.org/esr/faqs/smart-questions.html
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Lists+sorting

2016-01-04 Thread Pooja Bhalode
Hi,

Yes, I tried sending the mail again in plain text.
But I think I understood the difference there in using built-in sort
function and writing the code without using that.

Thank you


On Mon, Jan 4, 2016 at 12:45 PM, Joel Goldstick <joel.goldst...@gmail.com>
wrote:

> On Mon, Jan 4, 2016 at 12:27 PM, Alan Gauld <alan.ga...@btinternet.com>
> wrote:
>
> > On 04/01/16 16:56, Pooja Bhalode wrote:
> > > Hi,
> > > I wanted to check if I can write the following program in this manner
> as
> > > well.
> > >
> >
> > Can you resend in plain text please?
> > Your post lost all its formatting so its hard to read
> > or comment on.
> >
> > > def linear_merge(list1, list2):
> > > result = []
> > > while len(list1) and len(list2):
> > > if list1[0] < list2[0]:
> > > result.append(list1.pop(0))
> > > else:
> > > result.append(list2.pop(0))
> > >
> > > # Now tack on what's left
> > >
> > > result.extend(list1)
> > > result.extend(list2)
> > > return result
> >
> > Like Alan said, send in plain text.  Also, give a test case and your
> results.  Your version uses the built in sort method.  The linear merge
> doesn't use that, so the writer's are trying to teach you something about
> sorting.
>
> > ...
> >
> > --
> > Alan G
> > Author of the Learn to Program web site
> > http://www.alan-g.me.uk/
> > http://www.amazon.com/author/alan_gauld
> > Follow my photo-blog on Flickr at:
> > http://www.flickr.com/photos/alangauldphotos
> >
> >
> > ___
> > Tutor maillist  -  Tutor@python.org
> > To unsubscribe or change subscription options:
> > https://mail.python.org/mailman/listinfo/tutor
> >
>
>
>
> --
> Joel Goldstick
> http://joelgoldstick.com/stats/birthdays
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] lists+sort

2016-01-04 Thread Pooja Bhalode
Hi, I wanted to check if this program can be used to merge the lists
together and sort them. This seems to work, but i wanted to check if there
are drawbacks in writing it in this manner.


My solution:


def linear_merge(list1, list2):

for num in list2:

list1.append(num)



list1.sort()



  # +++your code here+++

return list1



Whereas, their code is a bit different, I have posted it here.


def linear_merge(list1, list2):



  result = []

  # Look at the two lists so long as both are non-empty.

  # Take whichever element [0] is smaller.

  while len(list1) and len(list2):

if list1[0] < list2[0]:

  result.append(list1.pop(0))

else:

  result.append(list2.pop(0))


  # Now tack on what's left

  result.extend(list1)

  result.extend(list2)

  return result



Can you please tell me if there is a problem in the first code?

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


[Tutor] Lists+sorting

2016-01-04 Thread Pooja Bhalode
Hi,
I wanted to check if I can write the following program in this manner as
well.

The problem is to merge the lists together and sort them.The solution they
have given is:

def linear_merge(list1, list2):


result = []

while len(list1) and len(list2):

if list1[0] < list2[0]:

result.append(list1.pop(0))

else:

result.append(list2.pop(0))


# Now tack on what's left

result.extend(list1)

result.extend(list2)

return result


So, is it correct if I write the function in this manner? This seems to
give me the correct solution though


def linear_merge(list1, list2):

for num in list2:

list1.append(num)

list1.sort()

# +++your code here+++

return list1


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