[Tutor] Need help

2016-09-28 Thread niraj pandey
Hi,

I am new in python. Could you guys please help me to short this code ?

Want to write this iteration (Yellow one) using loop.

r = 0
L1 = Label(bg = 'orange', text="Flat_No", relief=RIDGE,width=30)
L1.grid(row=0,column=0)
E1 = Entry(relief=SUNKEN,width=30)
E1.grid(row=0,column=1)
L2 = Label(bg = 'orange', text="Mains Unit", relief=RIDGE,width=30)
L2.grid(row=1,column=0)
E2 = Entry(relief=SUNKEN,width=30)
E2.grid(row=1,column=1)
L3 = Label(bg = 'orange', text="DG Unit", relief=RIDGE,width=30)
L3.grid(row=2,column=0)
E3 = Entry(relief=SUNKEN,width=30)
E3.grid(row=2,column=1)
L4 = Label(bg = 'orange', text="Month", relief=RIDGE,width=30)
L4.grid(row=3,column=0)
E4 = Entry(relief=SUNKEN,width=30)
E4.grid(row=3,column=1)


MyButton1 = Button(top, text="Submit", width=10, bg='red', command=lambda:
database.data(E1.get(), E2.get(), E3.get(), E4.get()))
MyButton1.grid(row=8, column=1)

The output should be like this :

[image: Inline image 1]

Thanks
Niraj
-- 
Success occurs when opportunity and preparation meet
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need help

2016-09-28 Thread niraj pandey
Found the solution for this .

entry_option = ['Flat_No','Mains Unit','DG Unit','Month']

 r = 0
  entry = {}
  label = {}
  for item in entry_option:
  lb = Label(bg = 'orange', text=item, relief=RIDGE,width=30)
  lb.grid(row=r,column=0)
  label[item] = lb
  e = Entry(relief=SUNKEN,width=30)
  e.grid(row=r,column=1)
  entry[item] = e
  r=r+1

But now how to pass these values as an argument for this function  ?

command=lambda: database.data(E1.get(), E2.get(), E3.get(), E4.get())

Thanks
Niraj

On Wed, Sep 28, 2016 at 10:52 AM, niraj pandey 
wrote:

> Hi,
>
> I am new in python. Could you guys please help me to short this code ?
>
> Want to write this iteration (Yellow one) using loop.
>
> r = 0
> L1 = Label(bg = 'orange', text="Flat_No", relief=RIDGE,width=30)
> L1.grid(row=0,column=0)
> E1 = Entry(relief=SUNKEN,width=30)
> E1.grid(row=0,column=1)
> L2 = Label(bg = 'orange', text="Mains Unit", relief=RIDGE,width=30)
> L2.grid(row=1,column=0)
> E2 = Entry(relief=SUNKEN,width=30)
> E2.grid(row=1,column=1)
> L3 = Label(bg = 'orange', text="DG Unit", relief=RIDGE,width=30)
> L3.grid(row=2,column=0)
> E3 = Entry(relief=SUNKEN,width=30)
> E3.grid(row=2,column=1)
> L4 = Label(bg = 'orange', text="Month", relief=RIDGE,width=30)
> L4.grid(row=3,column=0)
> E4 = Entry(relief=SUNKEN,width=30)
> E4.grid(row=3,column=1)
>
>
> MyButton1 = Button(top, text="Submit", width=10, bg='red', command=lambda:
> database.data(E1.get(), E2.get(), E3.get(), E4.get()))
> MyButton1.grid(row=8, column=1)
>
> The output should be like this :
>
> [image: Inline image 1]
>
> Thanks
> Niraj
> --
> Success occurs when opportunity and preparation meet
>



-- 
Success occurs when opportunity and preparation meet
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need help

2016-09-28 Thread niraj pandey
Thanks Peter for the help.

Best Regards
Niraj



On Wed, Sep 28, 2016 at 2:47 PM, Peter Otten <__pete...@web.de> wrote:

> niraj pandey wrote:
>
> > Found the solution for this.
>
> You can further simplifiy it with enumerate()
> > entry_option = ['Flat_No','Mains Unit','DG Unit','Month']
>
> > entry = {}
> > label = {}
>   for r, item in enumerate(entry_option):
> > lb = Label(bg = 'orange', text=item, relief=RIDGE,width=30)
> > lb.grid(row=r,column=0)
> > label[item] = lb
> > e = Entry(relief=SUNKEN,width=30)
> > e.grid(row=r,column=1)
> > entry[item] = e
> >
> > But now how to pass these values as an argument for this function  ?
> >
> > command=lambda: database.data(E1.get(), E2.get(), E3.get(), E4.get())
>
> Well, you saved the Entry instances in a dict, so you can retrieve them:
>
> command=lambda: database.data(*[entry[k].get() for k in entry_option])
>
> If you use a list instead of or in addition to the dict
>
> entries = []
> for ...: # your loop from above
>...
>entries.append(e)
>
> the lambda becomes
>
> command=lambda: database.data(*[e.get() for e in entries])
>
> If you have not come across it before: the * operator unpacks the list, so
>
> args = ["a", "b"]
> f(*args)
>
> is equivalent to calling f with all items in the list,
>
> f(args[0], args[1])
>
> in the above example.
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Success occurs when opportunity and preparation meet
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need help

2016-09-28 Thread niraj pandey
Ignore this I have done it.

Thanks
Niraj

On Wed, Sep 28, 2016 at 12:30 PM, niraj pandey 
wrote:

> Found the solution for this .
>
> entry_option = ['Flat_No','Mains Unit','DG Unit','Month']
>
>  r = 0
>   entry = {}
>   label = {}
>   for item in entry_option:
>   lb = Label(bg = 'orange', text=item, relief=RIDGE,width=30)
>   lb.grid(row=r,column=0)
>   label[item] = lb
>   e = Entry(relief=SUNKEN,width=30)
>   e.grid(row=r,column=1)
>   entry[item] = e
>   r=r+1
>
> But now how to pass these values as an argument for this function  ?
>
> command=lambda: database.data(E1.get(), E2.get(), E3.get(), E4.get())
>
> Thanks
> Niraj
>
> On Wed, Sep 28, 2016 at 10:52 AM, niraj pandey  > wrote:
>
>> Hi,
>>
>> I am new in python. Could you guys please help me to short this code ?
>>
>> Want to write this iteration (Yellow one) using loop.
>>
>> r = 0
>> L1 = Label(bg = 'orange', text="Flat_No", relief=RIDGE,width=30)
>> L1.grid(row=0,column=0)
>> E1 = Entry(relief=SUNKEN,width=30)
>> E1.grid(row=0,column=1)
>> L2 = Label(bg = 'orange', text="Mains Unit", relief=RIDGE,width=30)
>> L2.grid(row=1,column=0)
>> E2 = Entry(relief=SUNKEN,width=30)
>> E2.grid(row=1,column=1)
>> L3 = Label(bg = 'orange', text="DG Unit", relief=RIDGE,width=30)
>> L3.grid(row=2,column=0)
>> E3 = Entry(relief=SUNKEN,width=30)
>> E3.grid(row=2,column=1)
>> L4 = Label(bg = 'orange', text="Month", relief=RIDGE,width=30)
>> L4.grid(row=3,column=0)
>> E4 = Entry(relief=SUNKEN,width=30)
>> E4.grid(row=3,column=1)
>>
>>
>> MyButton1 = Button(top, text="Submit", width=10, bg='red',
>> command=lambda: database.data(E1.get(), E2.get(), E3.get(), E4.get()))
>> MyButton1.grid(row=8, column=1)
>>
>> The output should be like this :
>>
>> [image: Inline image 1]
>>
>> Thanks
>> Niraj
>> --
>> Success occurs when opportunity and preparation meet
>>
>
>
>
> --
> Success occurs when opportunity and preparation meet
>



-- 
Success occurs when opportunity and preparation meet
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Need help

2016-10-03 Thread niraj pandey
Hi ,

I am new in python. Could you guys please help me here.

I want to add every lebels value here (ie fetch from DB and display in
front of every lebel or I had store every lable value in variable and
display here).


[image: Inline image 1]

So that table looks like as follow

[image: Inline image 2]

Is there any function which I can use for this (like we have entry.get to
get the value similar any function to put the value)

Thanks in advance.

Regards
Niraj

-- 
Success occurs when opportunity and preparation meet
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need help

2016-10-03 Thread niraj pandey
Hello Alan ,

I am using python 2.7.10 and using RHEL6

Thanks


On Mon, Oct 3, 2016 at 8:53 PM, Alan Gauld via Tutor 
wrote:

> On 03/10/16 10:54, niraj pandey wrote:
>
> > I want to add every lebels value here (ie fetch from DB and display in
> > front of every lebel or I had store every lable value in variable and
> > display here).
>
> You need to tell us which OS, Python version and GUI
> toolkit you are using.
>
> > [image: Inline image 1]
>
> This is a text list so images usually get stripped off.
> If absolutely necessary to send an image use a link to an
> image gallery somewhere.
>
> But at least try to explain what you are trying to show us.
>
> > Is there any function which I can use for this (like we have entry.get to
> > get the value similar any function to put the value)
>
> Assuming you are using Tkinter there is an insert() method.
> To put text at the end of the entry use
>
> import tkinter as tk
> myText = "Hello world"
> top = tk.Tk()
>
> myEntry = tk.Entry(top)
> myEntry.pack()
> myEntry.insert(tk.END,mytext)
>
> top.mainloop()
>
>
> However a common alternative is to use a StringVar and associate it with
> the Entry so that changes in the StringVar are automatically
> shown in the Entry and changes in the Entrey are reflected to the
> StringVar. Most Tkinter tutorials will show that under StringVar.
>
> Of course if you are not using Tkinter most of that will be useless!
>
>
> --
> 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
>



-- 
Success occurs when opportunity and preparation meet
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need help

2016-10-04 Thread niraj pandey
Attaching two snapshots here.

In first snapshot (1.png) I have the label windows without the values and
in second window (2.png) every label have some value.
I want to put these values in front of every label. I have already stored
these values in a variable.

Thanks
Niraj

On Mon, Oct 3, 2016 at 10:02 PM, niraj pandey 
wrote:

> Hello Alan ,
>
> I am using python 2.7.10 and using RHEL6
>
> Thanks
>
>
> On Mon, Oct 3, 2016 at 8:53 PM, Alan Gauld via Tutor 
> wrote:
>
>> On 03/10/16 10:54, niraj pandey wrote:
>>
>> > I want to add every lebels value here (ie fetch from DB and display in
>> > front of every lebel or I had store every lable value in variable and
>> > display here).
>>
>> You need to tell us which OS, Python version and GUI
>> toolkit you are using.
>>
>> > [image: Inline image 1]
>>
>> This is a text list so images usually get stripped off.
>> If absolutely necessary to send an image use a link to an
>> image gallery somewhere.
>>
>> But at least try to explain what you are trying to show us.
>>
>> > Is there any function which I can use for this (like we have entry.get
>> to
>> > get the value similar any function to put the value)
>>
>> Assuming you are using Tkinter there is an insert() method.
>> To put text at the end of the entry use
>>
>> import tkinter as tk
>> myText = "Hello world"
>> top = tk.Tk()
>>
>> myEntry = tk.Entry(top)
>> myEntry.pack()
>> myEntry.insert(tk.END,mytext)
>>
>> top.mainloop()
>>
>>
>> However a common alternative is to use a StringVar and associate it with
>> the Entry so that changes in the StringVar are automatically
>> shown in the Entry and changes in the Entrey are reflected to the
>> StringVar. Most Tkinter tutorials will show that under StringVar.
>>
>> Of course if you are not using Tkinter most of that will be useless!
>>
>>
>> --
>> 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
>>
>
>
>
> --
> Success occurs when opportunity and preparation meet
>



-- 
Success occurs when opportunity and preparation meet
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need help

2016-10-04 Thread niraj pandey
Ok I got it from the solution you provided on your previous mail.

Thanks again

Thanks
Niraj

On Tue, Oct 4, 2016 at 12:05 PM, niraj pandey 
wrote:

> Attaching two snapshots here.
>
> In first snapshot (1.png) I have the label windows without the values and
> in second window (2.png) every label have some value.
> I want to put these values in front of every label. I have already stored
> these values in a variable.
>
> Thanks
> Niraj
>
> On Mon, Oct 3, 2016 at 10:02 PM, niraj pandey 
> wrote:
>
>> Hello Alan ,
>>
>> I am using python 2.7.10 and using RHEL6
>>
>> Thanks
>>
>>
>> On Mon, Oct 3, 2016 at 8:53 PM, Alan Gauld via Tutor 
>> wrote:
>>
>>> On 03/10/16 10:54, niraj pandey wrote:
>>>
>>> > I want to add every lebels value here (ie fetch from DB and display in
>>> > front of every lebel or I had store every lable value in variable and
>>> > display here).
>>>
>>> You need to tell us which OS, Python version and GUI
>>> toolkit you are using.
>>>
>>> > [image: Inline image 1]
>>>
>>> This is a text list so images usually get stripped off.
>>> If absolutely necessary to send an image use a link to an
>>> image gallery somewhere.
>>>
>>> But at least try to explain what you are trying to show us.
>>>
>>> > Is there any function which I can use for this (like we have entry.get
>>> to
>>> > get the value similar any function to put the value)
>>>
>>> Assuming you are using Tkinter there is an insert() method.
>>> To put text at the end of the entry use
>>>
>>> import tkinter as tk
>>> myText = "Hello world"
>>> top = tk.Tk()
>>>
>>> myEntry = tk.Entry(top)
>>> myEntry.pack()
>>> myEntry.insert(tk.END,mytext)
>>>
>>> top.mainloop()
>>>
>>>
>>> However a common alternative is to use a StringVar and associate it with
>>> the Entry so that changes in the StringVar are automatically
>>> shown in the Entry and changes in the Entrey are reflected to the
>>> StringVar. Most Tkinter tutorials will show that under StringVar.
>>>
>>> Of course if you are not using Tkinter most of that will be useless!
>>>
>>>
>>> --
>>> 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
>>>
>>
>>
>>
>> --
>> Success occurs when opportunity and preparation meet
>>
>
>
>
> --
> Success occurs when opportunity and preparation meet
>



-- 
Success occurs when opportunity and preparation meet
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need help

2016-10-12 Thread niraj pandey
Hi ,

I need one more help related to printer.

Can you pls guide how to print this screen (Attached here) content in
printer ?

Thanks
Niraj

On Tue, Oct 4, 2016 at 12:21 PM, niraj pandey 
wrote:

> Ok I got it from the solution you provided on your previous mail.
>
> Thanks again
>
> Thanks
> Niraj
>
> On Tue, Oct 4, 2016 at 12:05 PM, niraj pandey 
> wrote:
>
>> Attaching two snapshots here.
>>
>> In first snapshot (1.png) I have the label windows without the values and
>> in second window (2.png) every label have some value.
>> I want to put these values in front of every label. I have already stored
>> these values in a variable.
>>
>> Thanks
>> Niraj
>>
>> On Mon, Oct 3, 2016 at 10:02 PM, niraj pandey > > wrote:
>>
>>> Hello Alan ,
>>>
>>> I am using python 2.7.10 and using RHEL6
>>>
>>> Thanks
>>>
>>>
>>> On Mon, Oct 3, 2016 at 8:53 PM, Alan Gauld via Tutor 
>>> wrote:
>>>
>>>> On 03/10/16 10:54, niraj pandey wrote:
>>>>
>>>> > I want to add every lebels value here (ie fetch from DB and display in
>>>> > front of every lebel or I had store every lable value in variable and
>>>> > display here).
>>>>
>>>> You need to tell us which OS, Python version and GUI
>>>> toolkit you are using.
>>>>
>>>> > [image: Inline image 1]
>>>>
>>>> This is a text list so images usually get stripped off.
>>>> If absolutely necessary to send an image use a link to an
>>>> image gallery somewhere.
>>>>
>>>> But at least try to explain what you are trying to show us.
>>>>
>>>> > Is there any function which I can use for this (like we have
>>>> entry.get to
>>>> > get the value similar any function to put the value)
>>>>
>>>> Assuming you are using Tkinter there is an insert() method.
>>>> To put text at the end of the entry use
>>>>
>>>> import tkinter as tk
>>>> myText = "Hello world"
>>>> top = tk.Tk()
>>>>
>>>> myEntry = tk.Entry(top)
>>>> myEntry.pack()
>>>> myEntry.insert(tk.END,mytext)
>>>>
>>>> top.mainloop()
>>>>
>>>>
>>>> However a common alternative is to use a StringVar and associate it with
>>>> the Entry so that changes in the StringVar are automatically
>>>> shown in the Entry and changes in the Entrey are reflected to the
>>>> StringVar. Most Tkinter tutorials will show that under StringVar.
>>>>
>>>> Of course if you are not using Tkinter most of that will be useless!
>>>>
>>>>
>>>> --
>>>> 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
>>>>
>>>
>>>
>>>
>>> --
>>> Success occurs when opportunity and preparation meet
>>>
>>
>>
>>
>> --
>> Success occurs when opportunity and preparation meet
>>
>
>
>
> --
> Success occurs when opportunity and preparation meet
>



-- 
Success occurs when opportunity and preparation meet
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python 3.5.2 Installaton Question

2016-10-21 Thread niraj pandey
Hi ,

In Linux I have multiple version of python on separate location and so far
I do not see any issue .
So I think you can also install multiple version of python on your window
system as well. You may just need to provide separate installation
directory path to install it on another location without overwrite the
previous version.

Thanks
Niraj

On Fri, Oct 21, 2016 at 7:38 AM, Viraja Chandrashekhar Khatu 
wrote:

> Hello,
>
>
> I have a quick question about installing Python 3.5.2 on my Windows 7
> laptop.
>
>
> I already have Python 2.7.1 installed on my laptop. However, I now wish to
> switch to Python 3.5.2, which is the latest release. My question is:
>
>
> Do I have to completely uninstall Python 2.7.1 and then install Python
> 3.5.2? Or can I still install Python 3.5.2 keeping Python 2.7.1 untouched
> on my laptop? Even if the second option would work, what is recommended to
> be done so that both versions do not show any kind of interference while
> programming in Python?
>
>
> Kindly confirm at your earliest.
>
>
> Thanks and Regards
>
>
> Viraja Khatu
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Success occurs when opportunity and preparation meet
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Alternative to for/while loop

2016-10-25 Thread niraj pandey
Try this.

my_string = '0,1,2,3'
my_lst=my_string.split(",")
leng = len(my_lst)
b=sum(my_lst)
avg=float(b/leng)
print avg



On Tue, Oct 25, 2016 at 7:08 AM, Bryon Adams 
wrote:

> Hello,
> I'm very new to python so please forgive what may be a beginner
> question. The book I'm working through hasn't covered using flow control
> yet so I'm thinking there should be a way to do this without the for loop I
> used, but I'm at a loss here. So far the book has covered: lists, strings,
> numerical types (float, integer, etc), methods, tuples, importing modules,
> boolean logic, and mathematical operators.
> The problem asks to receive an arbitrary list of numbers separated by
> commas and then find the average. If someone could point me in the right
> direction I'd appreciate it. I'm using Python3.5.1 on Fedora 24 Linux,
> though the book uses Python2.x.
>
>   My code:
> nums = input('Enter some numbers separated by commas: ')
> nums = [float(i) for i in nums.split(', ')]
> print((sum(nums)) / len(nums))
>
> Regards,
>   Bryon
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Success occurs when opportunity and preparation meet
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor