Re: [Tutor] Python-list thread: int vs. float

2017-02-12 Thread eryk sun
On Sat, Feb 11, 2017 at 8:53 PM, boB Stepp  wrote:
>
> I suspect Eryk had set a normal 's' as an identifier for the character
> code sequence that produces the non-ASCII output, but forgot to show
> us that step.  But I could be mistaken.

Sorry, I forgot to show the assignment of the string "௧꘢୩" to the variable s.

> Today I am working in Windows 7, not Linux Mint.  Of course when I
> attempted to copy and paste the non-ASCII sequence from Gmail into
> cmd.exe I got 3 rectangular boxes on the paste line, indicating
> cmd.exe could not translate those characters.

If you're running python.exe, it either inherits or allocates a
console, which is hosted by an instance of conhost.exe. At most you're
inheriting a console from cmd.exe. That's the extent of its
involvement. Think of conhost.exe as a terminal window, like GNOME
Terminal, etc. cmd.exe and powershell.exe are shells that use standard
I/O, much like Python's REPL -- or like running bash in a Unix
terminal.

The console window can handle characters in the basic multilingual
plane (BMP). Python 3.6 uses the console's wide-character (Unicode)
API, so it should have no problem reading the string "௧꘢୩" if typed or
pasted into the console. For example, if it's assigned to `s`, then
ascii(s) should show the correct \u literals:

>>> ascii(s)
"'\\u0be7\\ua622\\u0b69'"

Unfortunately, for rendering text the Windows console has limited font
support. It requires a strictly monospace font, among other criteria.
It won't switch automatically to other fonts when the current font
doesn't have a glyph for a character. It just displays an empty box
glyph. In Windows 7 a good font choice for the console window is
Consolas. It has pretty good coverage for Western languages, but not
for any of the characters in "௧꘢୩".

If you copy the empty-box glyphs from the console window to the
clipboard, it's actually copying the Unicode characters, which can be
pasted into a window that has better font support, such as notepad. So
in 3.6 this is just a superficial rendering issue that can be
addressed by using programs such as ConEmu that replace the standard
console window (it hides the console and hooks the API to write to its
own window).
___
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 Alan Gauld via Tutor
On 12/02/17 20:01, Pooja Bhalode wrote:

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

It would be helpful if you gave more details of exactly how you get stuck.
What is happening(or not) that puzzles you.
Otherwise we just have to guess at what you mean.

Anyway, here goes...

> 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()

Once again you are defining variables inside the function which
means they disappear when the function ends.

If you want to access what these hold you need to have them
outside the function.

> 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()

Again this function could(should?) be outside the function
as a global level function. By defining it inside the function
you add extra complexity to the Print() code and break up
its flow making it harder to see what is going on.

You gain nothing by having it inside the Print() since
the variables it accesses are already declared outside
Print and are thus available for Submit to access.

> 
> 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]

This is a text based mailing list so images usually
get stripped out by the server.


> 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.

Submit is not storing anything it just prints.
The only storage is in this segment of Print()

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

And since that is called immediately after the creation of the Entry I
doubt that anything gets stored. You need to put this code inside the
Submit function.
> 
> But here, I am not able to store the value associated with each entry boxes
> in the created list.

See above.

Move the Submit function outside Print() and put the
storage lines above inside Submit() and see how that goes.


-- 
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


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 
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 species:").grid(row=0, column = 1,
> > sticky=W)
> > entrynumberspecies = Entry(frame1, textvariable =
> entrynumberspeciesvar)
> > entrynumberspecies.grid(row=0, column = 2, sticky=W)
> >
> > # print entrynumberspeciesvar.get()
> > checkreac = Checkbutton(frame1, text = "Reactant species", variable =
> > varreac)
> > checkreac.grid(row = 1, column = 1, sticky = W)
> > checkreac.select()
> > Checkbutton(frame1, text = "Intermediate species", variable =
> > varint).grid(row = 2, column = 1, sticky = W)
> > Checkbutton(frame1, 

Re: [Tutor] ISSUE WITH PYTHON 3,5 API RUNTIME

2017-02-12 Thread Alan Gauld via Tutor
On 12/02/17 19:10, ViRuZ Fx . wrote:
> Hello fellow programmers of Python, Im here writing you this because, since
> I got a virus and my computer reseted to 0, 

I have no idea what reset to 0 means.
Did you reinsatall Windows and all your applications?
Did you use the Windows repair tool?

> I cant run anything, 

You mean anything at all? Not even Windows Exploirer or Notepad?
If dso its a Windows fault and nothing to do with python.

Or do you mean you can't run Python?
If so which commands have you tried? IDLE?
The command line interpreter?

> start running a program , it pops this error :

> api-ms-win-crt-runtime-l1-1-0.dll

That's not really an error but a filename. Is there any
explanatory text, such as "can't find file" or "not a command"
or somesuch?

[BTW Have you tried googling the error/filename?
You might find its a common fault with an easy fix...]

> I seriously need help

Indeed, but we can't tell at this point whether its
help with Windows or help with Python on windows.
We need more details.

-- 
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] ISSUE WITH PYTHON 3,5 API RUNTIME

2017-02-12 Thread ViRuZ Fx .
Hello fellow programmers of Python, Im here writing you this because, since
I got a virus and my computer reseted to 0, I cant run anything, when I
start running a program , it pops this error :
api-ms-win-crt-runtime-l1-1-0.dll
I seriously need help , so yep, thanks for responding me the fast as
possible, I hope you can help me .. Have a great afternoon. :)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor