Re: [Tutor] How to add an Image in Grid mode with Python and Tkinter?

2018-07-31 Thread Matthew Polack
Thanks Alan and Peter for the comprehensive replies...that gives me some
good 'homework' to do and clarity on how to go about it.

Much appreciatedwill spend some time now getting my head around it.

Thanks so much.

- Matthew Polack

Matthew Polack | Teacher


[image: Emailbanner3.png]

Trinity Drive  |  PO Box 822

Horsham Victoria 3402

p. 03 5382 2529   m. 0402456854

e. matthew.pol...@htlc.vic.edu.au

w. www.htlc.vic.edu.au

On Tue, Jul 31, 2018 at 4:26 AM, Alan Gauld via Tutor 
wrote:

> On 30/07/18 08:24, Matthew Polack wrote:
>
> > I'm trying to simply add an image to our program to make the GUI more
> > interesting...but most of the tutorials describe using the 'Pack'
> > method not the grid method of layout...
>
> That's completely irrelevant since you can add images to widgets
> regardless of the layout manager used. In most cases you will
> want to use a PhotoImage widget to do it though.
>
> > and apparently you cannot use 'Pack' and 'Grid' in the one program...
>
> Yes you can just not in the same container.
> For example a common strategy for building forms based apps
> is to have a menubar on top with a toolbar frame packed below
> with a data frame packed below that and finally a status
> bar frame packed at the bottom.
>
> Within those frames you use the packer for the toolbar buttons,
> and for the status bar text. Then you use the grid layout
> manager to display the data entry widgets in the centre panel.
>
> So at each container(usually a Frame) level you can only have
> a single layout manager, but inside each nested container
> you can choose to use the same or a different manager.
>
> And remember there are more than just pack and grid, there
> are also place and form(in Tix) (and you can write your own
> if you are really keen!)
>
> > Can anyone explain how I could add an image to this program? Or show me
> an
> > example of a simple program that lets someone simply add an image and use
> > the grid layout in combination.
> import tkinter as tk
>
> top = tk.Tk()
> tk.Label(image = "foo.img").grid(row=0,column=0)
>
> top.mainloop)()
>
>
> Thats about as simple as it gets. But the img file must
> be in Tk compatible format.
>
> More generally, use a PhotoImage:
>
> import tkinter as tk
>
> top = tk.Tk()
> lbl = tk.Label()
> lbl.grid(row=0,column=0)  #could as easily use pack() or place()
>
> img = tk.PhotoImage(file="/path/to/myimg.gif")
> lbl['image'] = img
>
> top.mainloop)()
>
> But to get more sophisticated you really want to look
> into the PIL/Pillow library and its integration with
> Tkinter via the image class. Also look at how the Text
> and Canvas widgets deal with images because its slightly
> more complex than a simple Label or Button.
>
> --
> 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
>

-- 
**Disclaimer: *Whilst every attempt has been made to ensure that material 
contained in this email is free from computer viruses or other defects, the 
attached files are provided, and may only be used, on the basis that the 
user assumes all responsibility for use of the material transmitted. This 
email is intended only for the use of the individual or entity named above 
and may contain information that is confidential and privileged. If you are 
not the intended recipient, please note that any dissemination, 
distribution or copying of this email is strictly prohibited. If you have 
received this email in error, please notify us immediately by return email 
or telephone +61 3 5382 2529** and destroy the original message.*
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] SSL Error

2018-07-31 Thread Saket Mehrotra
Hi

I am trying to run import requests in a py file but I am getting below
error  ssl.PROTOCOL_SSLv23: OpenSSL.SSL.SSLv23_METHOD,
AttributeError: module 'ssl' has no attribute 'PROTOCOL_SSLv23'
>>>

I tried to execute below from the terminal but it still remains unresolved.

sudo easy_install --upgrade pip

I've also had to run:

sudo pip uninstall pyopenssl

sudo pip install mozdownload


Can you please help me .

Thanks & Regards
Saket Mehrotra
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] SSL Error

2018-07-31 Thread Marc Tompkins
This is a general Python tutor group; I'm not sure anybody here can help
you with the OpenSSL package (I've definitely never used it myself.)  We're
all willing to help, but this might not be the right place to ask this
question.

More to the point, though, when you ask questions on this list it's best to
just cut and paste BOTH your code and the actual error message/traceback;
from the bit that you've posted, it sounds like it might be as simple as a
typo, but we can't really tell without seeing your code.

On Mon, Jul 30, 2018 at 7:52 PM, Saket Mehrotra 
wrote:

> Hi
>
> I am trying to run import requests in a py file but I am getting below
> error  ssl.PROTOCOL_SSLv23: OpenSSL.SSL.SSLv23_METHOD,
> AttributeError: module 'ssl' has no attribute 'PROTOCOL_SSLv23'
> >>>
>
> I tried to execute below from the terminal but it still remains unresolved.
>
> sudo easy_install --upgrade pip
>
> I've also had to run:
>
> sudo pip uninstall pyopenssl
>
> sudo pip install mozdownload
>
>
> Can you please help me .
>
> Thanks & Regards
> Saket Mehrotra
> ___
> 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] SSL Error

2018-07-31 Thread Alan Gauld via Tutor
On 31/07/18 03:52, Saket Mehrotra wrote:

> error  ssl.PROTOCOL_SSLv23: OpenSSL.SSL.SSLv23_METHOD,
> AttributeError: module 'ssl' has no attribute 'PROTOCOL_SSLv23'

Are you sure you spelled the attribute correctly?

Have you tried


>>> import ssl
>>> dir(ssl)

Top see what the attribute names look like?
Is PROTOCOL_SSLv23 one of them?


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

2018-07-31 Thread Zachary Ware
On Tue, Jul 31, 2018 at 12:06 PM Alan Gauld via Tutor  wrote:
>
> On 31/07/18 03:52, Saket Mehrotra wrote:
>
> > error  ssl.PROTOCOL_SSLv23: OpenSSL.SSL.SSLv23_METHOD,
> > AttributeError: module 'ssl' has no attribute 'PROTOCOL_SSLv23'
>
> Are you sure you spelled the attribute correctly?
>
> Have you tried
>
>
> >>> import ssl
> >>> dir(ssl)
>
> Top see what the attribute names look like?
> Is PROTOCOL_SSLv23 one of them?

Also check `ssl.__file__` and make sure it is the standard library's
`ssl.py` (/usr/lib/python3.6/ssl.py or similar) and not a local file
of yours named `ssl.py`.

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


Re: [Tutor] SSL Error

2018-07-31 Thread Marc Tompkins
On Tue, Jul 31, 2018 at 10:03 AM, Alan Gauld via Tutor 
wrote:

> On 31/07/18 03:52, Saket Mehrotra wrote:
>
> > error  ssl.PROTOCOL_SSLv23: OpenSSL.SSL.SSLv23_METHOD,
> > AttributeError: module 'ssl' has no attribute 'PROTOCOL_SSLv23'
>
> Are you sure you spelled the attribute correctly?
>
> Have you tried
>
>
> >>> import ssl
> >>> dir(ssl)
>
> Top see what the attribute names look like?
> Is PROTOCOL_SSLv23 one of them?
>
> What I was getting at earlier: it isn't clear, without seeing his code,
whether he's directly asking for PROTOCOL_SSLv23, or whether it's an
internal result of a call he made.  If it's the first, then the problem is
with his code; if it's the second, it's a problem with how the package is
built on his machine.  Really can't tell without context.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] SSL Error

2018-07-31 Thread Peter Otten
Saket Mehrotra wrote:

> Hi
> 
> I am trying to run import requests in a py file but I am getting below
> error  ssl.PROTOCOL_SSLv23: OpenSSL.SSL.SSLv23_METHOD,
> AttributeError: module 'ssl' has no attribute 'PROTOCOL_SSLv23'

If you start the Python interpreter and execute

>>> import ssl
>>> ssl.__file__
'/usr/lib/python3.4/ssl.py'

does it print something suspicious? You might be hiding the standard ssl.py 
with one you created yourself:

# touch ssl.py
$ python3
Python 3.4.3 (default, Nov 28 2017, 16:41:13) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.__file__
'/home/peter/mystuff/ssl.py'

In that case just rename the offending file (if you are using Python 2 
remember to remove the corresponding ssl.pyc).


> 
> I tried to execute below from the terminal but it still remains
> unresolved.
> 
> sudo easy_install --upgrade pip
> 
> I've also had to run:
> 
> sudo pip uninstall pyopenssl
> 
> sudo pip install mozdownload
> 
> 
> Can you please help me .
> 
> Thanks & Regards
> Saket Mehrotra
> ___
> 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