[Tutor] Any 'graphical' ways of learning Python

2018-12-06 Thread Mike Barnett
I stumbled onto this mailing list when Google found a mention of PySimpleGUI in 
a thread titled: Any 'graphical' ways of learning Python.

I wanted to respond with information on PySimpleGUI and why it's ideal for 
students.

If you're teaching kids and they want to learn how to do GUIs so that their 
programs run and look like Windows programs, then the PySimpleGUI package is 
the right choice.  It runs on top of either tkinter or Qt.  With tkinter it's 
easy to also package up the program into an EXE file that they kids can give to 
friends.  There are instructions in the PySimpleGUI documentation located at 
http://www.PySimpleGUI.org.

The GitHub http://www.PySimpleGUI.com has over 130 demo programs and there is a 
Cookbook filled with Recipes that you can copy, pate and run. There is a 
section with a bunch of exercises that are part of a course that an Aussie 
teacher developed.  You'll find them posted here:
https://github.com/MikeTheWatchGuy/PySimpleGUI/tree/master/ProgrammingClassExamples

There is extensive documentation for the package http://www.PySimpleGUI.org

The experience for the first time user was designed to be a positive one, 
filled with success, with the goal of having a GUI up on the screen within FIVE 
MINUTES of starting the process of installing.

PySimpleGUI was written with students and beginners in mind.  The idea was to 
enable the creation of any GUI layout using the same full-featured GUI widgets 
that are available if you coded directly in tkinter or Qt, but done without the 
boilerplate code.  The package does all the messy work for you.  It also hides 
the concepts like callbacks that are confusing to beginners.

Take a look at a small sampling of the GUIs made.
https://github.com/MikeTheWatchGuy/PySimpleGUI/issues/1
The better ones are towards the bottom. It's a long list dating back to the 1.0 
release so the early stuff looks a little primitive.

The reviews from users have been extremely positive on Reddit and on the GitHub 
site.

Today this was posted by a user on Reddit:
I'm finding it so easy to add a quick GUI front-end to some of my Python 
scripts with PySimpleGUI. There's so much less "boilerplate" needed than with 
more traditional GUI frameworks that I find myself adding simple GUIs to 
scripts which I would just run in console mode otherwise.

There are currently two flavors of PySimpleGUI, one that uses tkinter and the 
other Qt.  The great thing about PySimpleGUI is that you can create the same 
layout that you would if you coded directly in tkinter or Qt.  All of the same 
widgets are available for use.  They are just presented in an easier to 
understand manner.  The source code created in PySimpleGUI will run on either 
tkinter or Qt platform.  The only thing you have to change is the import 
statement.

PySimpleGUI has plenty of depth of features.  The result is a powerful GIU 
framework capable of running a large variety of user interfaces including 
running in the system tray.

PySimpleGUI is actively developed and maintained.  Should you run into a 
problem, it's typically addressed the same day.

There was a clear, large gap in the GUI landscape for Python.  In order to 
write even the most primitive of GUIs, you are required to know and use skills 
that are advanced beginner / intermediate.  GUIs are often taught towards the 
end of the curriculum for this reason.

With PySimpleGUI GUIs can be taught from the beginning of the course.  Rather 
than using the command line for input/output, it's easy to use windows instead.

If you want to learn more about the overall architecture, this recent post will 
help:
https://www.reddit.com/r/Python/comments/a1mj0p/pysimplegui_under_the_hood/



@mike

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


Re: [Tutor] Any 'graphical' ways of learning Python

2018-12-06 Thread Mike Barnett
Oh, one more thing on this topic... there are tutorial videos available for 
PySimpleGUI, both basic and advanced.

Basic 5 video series:
https://www.youtube.com/playlist?list=PLl8dD0doyrvHMoJGTdMtgLuHymaqJVjzt

Additional 9 in-depth videos:
https://www.youtube.com/playlist?list=PLl8dD0doyrvHMoJGTdMtgLuHymaqJVjzt


-mike

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


Re: [Tutor] graphics library for teaching Python

2018-12-21 Thread Mike Barnett
>There are two sub-topics I'm interested in - (1) graphics, as in drawing 
>interesting pictures or art, or using diagrams for data visualization. (2) 
>Simple games, with the use of sprites.

Can you post some images of similar programs / graphics you are wanting to 
create?  It would be extremely helpful to see concrete "targets".  Then I can 
better inform you if PySimpleGUI is capable of doing what you seek.

I've recently been writing more games using PySimpleGUI to see what's missing 
in the SDK, to determine new features that will help developers.

For data visualization, there's Matplotlib and Pyplot, both integrate with 
PySimpleGUI very well.  Someone mentioned Turtle, it too integrates well by 
using a tkinter canvas.

I've been doing simple graphs by using the drawing primitives and games using 
images that I often include in the source code.  The Uno Game for example has 
all of the cards included in the .py file.

Some examples:

Bar chart:
https://gist.github.com/MikeTheWatchGuy/fd79baad627ae879bb74437427ad4ff0

Simple Matplotlib:
https://gist.github.com/MikeTheWatchGuy/33579888cd976e2ef0231869bba38bb4

Simple plotting - sine wave:
https://gist.github.com/MikeTheWatchGuy/397b681d1b3863a74936724fdfd1ea34

Scrolling bar chart:
https://user-images.githubusercontent.com/13696193/47611749-18964c80-da42-11e8-93c4-6821a6fce488.gif

Matplotlib integration:
https://user-images.githubusercontent.com/13696193/50046965-cb664c80-007a-11e9-9470-b7d1ab3fa20e.gif


Some simple games

Conway's Game of Life:
https://user-images.githubusercontent.com/13696193/50244709-9e79a880-039e-11e9-9b51-733357a87c68.gif

Uno Card Game:
https://user-images.githubusercontent.com/13696193/49945232-67952580-feba-11e8-90c8-7dc31c5f7c67.gif

Turtle:
https://user-images.githubusercontent.com/13696193/49346588-b644f300-f662-11e8-8c83-44c74aedf89f.gif

A Crossword Puzzle GUI:
https://user-images.githubusercontent.com/13696193/47968340-98ba4480-e036-11e8-9d44-8a39ac174533.jpg

Chess GUI:
https://user-images.githubusercontent.com/13696193/47380967-b6012180-d6cc-11e8-946d-a646921fb8d0.gif


These are all tkinter based examples. 

While PySimpleGUI does have a Qt port, it's not as complete when it comes to 
these graphics primitives and integration with Matplotlib.


-mike

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


Re: [Tutor] graphics library for teaching Python

2018-12-21 Thread Mike Barnett
For PySimpleGUI….
Things like “collision detection” are up to the application.  PySimpleGUI gives 
you ability to place “objects” at x,y coordinates.  The primitives allow 
images, circles, lines, rectangles, arcs, and text to be drawn and removed.  If 
one overlaps another you’re on the hook for determining that.

GUIs
PySimpleGUI rocks for doing custom GUIs.  At last count there were 28 widgets 
that you can place pretty much anywhere within a window.  These are the basic 
widgets (buttons, listbox, checkbox, radio button, etc.) as well as advanced 
Panes and Button-Menus.  It’s excellent for teaching GUIs and how to layout a 
GUI because all of the widgets are available for the developer, not a subset.

You can run sync and async event loops so doing things like polling hardware 
devices is easy.  No callbacks to worry about.
Here’s a description of the architecture
https://pysimplegui.readthedocs.io/architecture/

Determining which button was clicked is as easy as a comparison:
if button == ‘Download’:
   do_download_stuff()

Animation is a super easy to do as all you’re doing is showing images in a loop.

Here’s a program that does a simple graph of a math function that allows you to 
change the variables using a couple of sliders.  It demonstrates the “graphing” 
capability.
https://gist.github.com/MikeTheWatchGuy/8453e82fc65e24060775443e843ab80b


One big drawback for tkinter / PySimpleGUI is the inability to have an image as 
the background.  You can have an image for the background of a canvas, but of 
the entire window.  For that you’ll need to use PySimpleGUIQt.

Anyway, it’s worth a look to see if it fits some of your needs.


@mike<mailto:mike_barn...@hotmail.com>

From: Michael Mossey 
Sent: Friday, December 21, 2018 1:40 PM
To: Mike Barnett 
Cc: tutor@python.org
Subject: Re: [Tutor] graphics library for teaching Python



On Fri, Dec 21, 2018 at 9:15 AM Mike Barnett 
mailto:mike_barn...@hotmail.com>> wrote:
>There are two sub-topics I'm interested in - (1) graphics, as in drawing 
>interesting pictures or art, or using diagrams for data visualization. (2) 
>Simple games, with the use of sprites.

Can you post some images of similar programs / graphics you are wanting to 
create?  It would be extremely helpful to see concrete "targets".  Then I can 
better inform you if PySimpleGUI is capable of doing what you seek.

I think PySimpleGUI might be a great fit.

I'm getting my ideas from projects way in the past, so I can't easily find 
screenshots. But what I'm looking for is pretty easy to describe.

for graphics: "Capabilities similar to JavaScript canvas plus collision 
detection."

In other words, basic text filling/stroking, basic shape and line and Bezier 
curve filling/stroking, and then collision detection to make simple games 
easier.

for GUIs: "Basic dialogs, buttons, labels, checkboxes, and integrated canvas."

My students range a lot in age and ability. Youngest is 9th grade, ranging 
upward to professionals who are looking to learn programming as a new skill to 
use in the workplace or put on their resume.



I've recently been writing more games using PySimpleGUI to see what's missing 
in the SDK, to determine new features that will help developers.

For data visualization, there's Matplotlib and Pyplot, both integrate with 
PySimpleGUI very well.  Someone mentioned Turtle, it too integrates well by 
using a tkinter canvas.

By data visualization, I don't mean necessarily plotting. Matplotlib might be 
an awkward fit.

I'm thinking of visualizing math processes, algorithms, and so forth. Say, we 
animate a cubic curve changing shape while the coefficients change. Or we 
animate the inner workings of a tic tac toe strategy algorithm by having it 
draw a tic tac toe board with changing colors or shapes to represent positions 
or calculations in progress. I don't mean something really complicated. Just 
picture the simplest thing that makes sense.

Thanks for the other links to examples.

Mike


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


Re: [Tutor] Recommended Resurce or strategy for beginning students

2019-01-22 Thread Mike Barnett
I like the idea of starting out right away on a GUI.  I know this is completely 
backwards to what would normally be taught, but hear me out.  Kids today are 
used to GUI interfaces.  They're on their phones, their computers, their TV  
sets.  

Why not teach kids to output to a window instead of a command line?  What if 
it's just was easy, or easier, to work with a GUI as it is the command line?

To output to the command line in standard Python:
print('my string', variable1, variable2)

To output the same information to a window using PySimpleGUI:
Popup('my string', variable1, variable2)

Or, you can "print" to a debug window if that's your thing.
Print('takes the same parameters as print')

If the ultimate goal is to teach kids about how to design a GUI window, how to 
lay out a GUI using good user interface design principals, then it would be 
nice to get the GUI coding out of the way and let the focus instead be on the 
GUI itself.  This is when having a drag-and-drop Designer Tool is handy.  If 
not, then the next best thing is a simple programming interface.

PySimpleGUI was designed so that the code visually matches the window layout.  

It's capable of duplicating pretty much any layout and widget combination that 
you can create coding directly to tkinter's (or Qt's or WxPython's) interfaces. 
 PySimpleGUI simply creates and executes the "boilerplate" code that is often 
brought up when GUIs are discussed.  

A goal was to remove all of the boilerplate code and provide a programmer with 
a simple, friendly and flexible set of APIs.  You write a single line of code 
per row of widgets in your window plus a 1/2 dozen lines to implement the event 
loop.

I don't see the harm in approaching the problem from a different direction.  It 
could be wildly successful.  Or... not...  The worst that can happen is you 
screw up a classroom full of future programmers, creating a warped vision that 
GUIs can be fun and easy.


@mike

-Original Message-
From: Matthew Polack  
Sent: Tuesday, January 22, 2019 1:58 AM
To: tutor@python.org
Subject: [Tutor] Recommended Resurce or strategy for beginning students

Hi All,

In our growing school we're teaching Python programming for the first time as 
an elective subject with Year 9 and 10 students. (Had a dabble at this last 
year with 3 students in Year 11)

I'm wondering what specific resource or stategy people would recommend for 
absolute beginners?

ie. a course or program, book,...set of activities to follow that strategically 
introduces and develops key skills.

At this age level I don't think we need to be achieving 'rocket science'..but 
rather giving the students a good solid introduction.

Some of the leadership wanted me to use this programming in combination with 
building robots...I've even wondered whether this is trying to achieve too many 
things...and we're better off focused on programming itself... but am open to 
this idea too...

I've had a play with using the excellent PySimpleGUI...which is an excellent 
resource for building a GUI...but I've realised before doing too much of this 
we might need to get a grip on core fundamentals

The challenge is trying to find a way to making this 'fun' for students whilst 
also having them genuinely learn rather than just 'copying pasting'
code...achieving something that looks good...but not really understanding what 
they are doing.

So far my strategy will be:

1.) Establish some core basics(utlising some form of 'course',,,which goes 
through basics of syntax..variables...loops etc. utilising just raw 
code...(probably a simple 'Adventure Game')
2.) Build some simple programs using PySimple GUi..eg. Some quiz games etc.
(there are some great examples on Github by another teacher and also the author 
Mike of PySimpleGUI.
3.) Possibly explore robotics.

Can anyone make any recommendations on either resources or teaching/learning 
strategy/curriculum.

Thank you,
Matt


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

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

Re: [Tutor] Recommended Resurce or strategy for beginning students

2019-02-04 Thread Mike Barnett
Be cautious when using IDLE with tkinter based programs (PySimpleGUI falls into 
this category).

IDLE is written using tkinter.  You can sometimes end up with tkinter 
complaining about the mainloop running in multiple locations or freeing 
resources in the wrong thread.


@mike<mailto:mike_barn...@hotmail.com>

From: Matthew Polack 
Sent: Monday, February 4, 2019 12:15 AM
To: Sean Murphy 
Cc: Mike Barnett ; tutor@python.org
Subject: Re: [Tutor] Recommended Resurce or strategy for beginning students

Hi All,

Firstly thanks so much for all the suggestions a while back re: recommended 
method for Python...really appreciate the ideas.

We had our first lesson today (With 15 year olds) where I started with the 
basic command line..and did a simple "Hello World" type program...just to show 
how something could be run straight from notepad and command line...

We then went to IDLE and made a simple 'Maths Calculator'

All of this went quite well...but as the long session started to wind down (Is 
a double lesson on a Monday)...I did start to notice the following:

1.) One group of students (probably most)..actively problem solving..trying 
things...googling all sorts of ways of improving their code...figuring out new 
ways of doing things...will go a long way.
2.) Another smaller group started to hit the wall...and were struggling for 
internal drive...needed to be 'hand fed'

Is going to be interesting going forward how to both cater for the 'indpendent 
workers' whilst still keeping the 'unenthused unless entertained' group 
engaged! The joys of teaching...but will certainly try some of the suggestions 
mentioned...PySimpleGUI..Turtle graphics etcthey will be very helpful. 
Thanks.



Matthew Polack | Teacher



[Emailbanner3.png]


Trinity Drive  |  PO Box 822

Horsham Victoria 3402

p. 03 5382 2529   m. 0402456854

e. matthew.pol...@htlc.vic.edu.au<mailto:matthew.pol...@htlc.vic.edu.au>

w. 
www.htlc.vic.edu.au<https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.htlc.vic.edu.au%2F&data=02%7C01%7C%7C5bac6b102d1b43f778c608d68a5fb081%7C84df9e7fe9f640afb435%7C1%7C0%7C636848540919281041&sdata=wZPuSdzAKYKZ6PEFA3XoI5lu6yoWt9zY%2FChV6Tpl7xA%3D&reserved=0>



On Wed, Jan 23, 2019 at 1:21 PM Sean Murphy 
mailto:mhysnm1...@gmail.com>> wrote:
I like this concept. The only additional information I would add in relation to 
any training or educational information. You must include accessibility. As the 
laws in many countries require this to be a part of the product. So it is a 
perfect time to educate students on this important topic. A high level 
awareness is required only.
Introducing the basics. Keyboard navigation, colour contrast, ensuring the GUI 
works with a screen reader. The platforms used for GUI should do most of the 
heavy lifting.

The other aspect is you need to ensure the course is accessible to possible 
disable students for now and the future. If you are based in the Usa. Then 
there could be legal requirements for this. Not sure. Out of my scope of focus 
in the accessibility world.


A bare minimum is to understand the bare basics which are called POUR. 
Reference W3C for the explaination.

Sean

My experience is the part

> On 23 Jan 2019, at 1:17 am, Mike Barnett 
> mailto:mike_barn...@hotmail.com>> wrote:
>
> I like the idea of starting out right away on a GUI.  I know this is 
> completely backwards to what would normally be taught, but hear me out.  Kids 
> today are used to GUI interfaces.  They're on their phones, their computers, 
> their TV  sets.
>
> Why not teach kids to output to a window instead of a command line?  What if 
> it's just was easy, or easier, to work with a GUI as it is the command line?
>
> To output to the command line in standard Python:
> print('my string', variable1, variable2)
>
> To output the same information to a window using PySimpleGUI:
> Popup('my string', variable1, variable2)
>
> Or, you can "print" to a debug window if that's your thing.
> Print('takes the same parameters as print')
>
> If the ultimate goal is to teach kids about how to design a GUI window, how 
> to lay out a GUI using good user interface design principals, then it would 
> be nice to get the GUI coding out of the way and let the focus instead be on 
> the GUI itself.  This is when having a drag-and-drop Designer Tool is handy.  
> If not, then the next best thing is a simple programming interface.
>
> PySimpleGUI was designed so that the code visually matches the window layout.
>
> It's capable of duplicating pretty much any layout and widget combination 
> that you can create coding directly to tkinter's (or Qt's or WxPython's) 
> interfaces.  PySimpleGUI simply creates and executes the "

Re: [Tutor] Recommended Resurce or strategy for beginning students

2019-02-21 Thread Mike Barnett
Congratulations!!

When going through PySimpleGUI….
There are some tutorial videos if your students like to learn that way.
https://www.reddit.com/r/Python/comments/9nvdmw/tutorial_beginning_as_in_your_first_time_gui/

And be sure and check out the new PySimpleGUIWeb implementation.

https://www.reddit.com/r/Python/comments/ar3x3b/embedding_entire_python_guis_in_webpages_with/

The latest Cookbook takes advantage of this early port of PySimpleGUIWeb 
running in the repl.it environment.

It uses repl.it to show how to implement various cookbook Recipes.

The PySimpleGUI account for Repl.it is https://repl.it/@PySimpleGUI which is 
where you’ll find a number of example programs that run using PySimpleGUIWeb.

Repl.it is AMAZING!  They’re even doing AI contests on there.  Imagine doing 
Python AI programs without Python even being installed on your computer.

Now your students can program PySimpleGUI code on an iPad if they really 
wanted.  Any browser window will work with repl.it.

You can write your PySimpleGUI code one time and run it on the web, tkinter, 
Qt, or WxPython all by just changing the import statement (in theory).

The downside is that each port is a little bit further along than the others.  
Tkinter is pretty much done.  Qt is in Alpha.  Wx is Pre-Alpha.  Web is 
Engineering release.

For doing the basics, PySimpleGUIWeb does remarkably well.  I’m able to use it 
to demonstrate PySimpleGUI concepts in a way that any reader can understand and 
execute without  even needing Python installed on their computer.

It’s Remi<https://github.com/dddomodossola/remi>, by the way, that is the magic 
behind PySimpleGUIWeb.



@mike<mailto:mike_barn...@hotmail.com>

From: Matthew Polack 
Sent: Wednesday, February 20, 2019 10:35 PM
To: David ; Mike Barnett ; 
Alan Gauld 
Cc: tutor@python.org
Subject: Re: [Tutor] Recommended Resurce or strategy for beginning students

Hi All,

Just wanted to update this thread regarding a resource for beginning students. 
We are now 4 weeks into the course and have found an excellent youtube series 
that goes from absolute basics.
https://www.youtube.com/playlist?list=PLLAZ4kZ9dFpMMs5lskzBApYXn0bl7emsW<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.youtube.com%2Fplaylist%3Flist%3DPLLAZ4kZ9dFpMMs5lskzBApYXn0bl7emsW&data=02%7C01%7C%7Cb9d9a4d30a4542f68a5708d697ada125%7C84df9e7fe9f640afb435%7C1%7C0%7C636863169316775701&sdata=gCftFiMvcghFeAcNeXmeZaT426VsV2Enb5UnfbowfUw%3D&reserved=0>

The big advantage for us in a classroom context is that students can work 
through this at their own pace using an Ipad to watch videos and then a 
computer to code..

I have some students who are flying through the course and are ready for more 
advanced topics..others are working more slowly...but all of them are 
enthusiastic and engaged...and the beauty of using a series like this is they 
can just go onto the harder topics when they are ready.

After we finish this series my plan is then to go onto Mike's excellent 
PySimpleGUI 
resource...https://pysimplegui.readthedocs.io/tutorial/<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpysimplegui.readthedocs.io%2Ftutorial%2F&data=02%7C01%7C%7Cb9d9a4d30a4542f68a5708d697ada125%7C84df9e7fe9f640afb435%7C1%7C0%7C636863169316785707&sdata=3bpI7rXaMWfLh06x5wZV6wVlS8yFM5hui2cipegkLro%3D&reserved=0>

I'm sure the students will then enjoy the GUI elements of the code.

We'll also use the Turtle import option to add some graphics interactions

We then might look to use a robotics  resource which is GoPiGo 
https://www.dexterindustries.com/gopigo-in-python-tutorials/<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.dexterindustries.com%2Fgopigo-in-python-tutorials%2F&data=02%7C01%7C%7Cb9d9a4d30a4542f68a5708d697ada125%7C84df9e7fe9f640afb435%7C1%7C0%7C636863169316795718&sdata=DbcV4Auj9wYyFZGu7AcKlSWxFPiIdzhbNkW5%2BHKIOcQ%3D&reserved=0>
 which gives us a chance to explore robotics with Python.

The pleasing thing is how keen the students are to keep learning and asking 
questions

Thanks again for all your support and ideas!

Matthew Polack

On Tue, Feb 5, 2019 at 3:05 PM David 
mailto:bouncingc...@gmail.com>> wrote:
On Tue, 22 Jan 2019 at 20:30, Matthew Polack
mailto:matthew.pol...@htlc.vic.edu.au>> wrote:
>
> Hi All,
>
> In our growing school we're teaching Python programming for the first time
> as an elective subject with Year 9 and 10 students. (Had a dabble at this
> last year with 3 students in Year 11)

Hi Matthew and other readers,

I wonder if you and any others here involved in classroom/group teaching
might be interested in this recent presentation that I stumbled across:
https://media.ccc.de/v/35c3-9800-how_to_teach_programming_to_your_loved_ones<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmedi

Re: [Tutor] What does 'Bind Return Key' do?

2019-04-29 Thread Mike Barnett
You'll find it discussed in a couple of places in the PySimpleGUI documentation.

For example, this was written about it under the Button Element section of the 
docs:
--
The ENTER key :
The ENTER key is an important part of data entry for windows. There's a long 
tradition of the enter key being used to quickly submit windows. PySimpleGUI 
implements this by tying the ENTER key to the first button that closes or reads 
a window.

The Enter Key can be "bound" to a particular button so that when the key is 
pressed, it causes the window to return as if the button was clicked. This is 
done using the bind_return_key parameter in the button calls. 
If there are more than 1 button on a window, the FIRST button that is of type 
Close window or Read window is used. First is determined by scanning the 
window, top to bottom and left to right.
--

When questions like this arise on PySimpleGUI, I recommend pulling up the docs 
and pressing Control-F to do a search.



@mike

-Original Message-
From: Matthew Polack  
Sent: Sunday, April 28, 2019 4:49 AM
To: tutor@python.org
Subject: [Tutor] What does 'Bind Return Key' do?

Hi,

We're learning Python with PySimpleGUi and have used this example program...

https://github.com/PySimpleGUI/PySimpleGUI/blob/master/ProgrammingClassExamples/Win10%20versions/1d%20PSG%20(named%20input%20keys%20and%20catch%20errors).py


There is a mystery command that says:

[sg.ReadButton('Submit', bind_return_key = False)]]

If I change this 'Bind_Return_Key' value from False to True...or in fact delete 
it entirely, it appears to make do difference whatsoever to the functioning of 
the program that I can see...

Could someone explain what the purpose of this could be? I'm guessing it has to 
have a reason to be there!

Thanks!

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


Re: [Tutor] Interactive editing of variables.

2019-06-01 Thread Mike Barnett
Oh, do you need WxPython for all your GUI type work since it can be used with 
screen readers?

A GUI like you're describing in PySimpleGUI could be 15 or 20 lines of code in 
total depending on the number of these fields you have.

Do you happen to have a sketch of this screen?  Even pencil and paper would be 
helpful.

I mocked this up really quickly. It takes short cuts to give you a mock-up.  
It's possible to write little GUIs like you're talking about easily, so that 
they're not over the top but rather "useful".

Here's a mockup running in PySimpleGUI / tkinter:
https://repl.it/@PySimpleGUI/Reddit-Change-variables-GUI

My estimate wasn't too far off 18 lines of code in total.


Is this the kind of modification of variables you where talking about?  


@mike

-Original Message-
From: Sean Murphy  
Sent: Saturday, June 1, 2019 8:21 AM
To: Mike Barnett 
Cc: Alan Gauld ; tutor@python.org
Subject: Re: [Tutor] Interactive editing of variables.

Mike, thanks for this debug tool. I might have a look at it. No that’s not the 
goal I’m after. I want to have a basic l input line which is already populated 
with a value. The value is extracted from a list of strength. Each element in 
the list are unique. I want to modify the string and then re-insert it back 
into the same element as the new modified string   I’m currently look at read 
line or piegnurl  module this might do the trick. Using GUI is way over the top 
for the simple thing I’m trying to do   The model which Alan kindly suggested 
if not accessible with a screen reader. As I cannot see e.g. blind, this is a 
critical component of my programming.

Please excuse any errors because I’m using Siri to send this email.

My experience is the part 

> On 1 Jun 2019, at 10:05 pm, Mike Barnett  wrote:
> 
> TL;DR
> There's a run-time debugger out, "imwatchingyou" that is being developed 
> daily, fast paced, that enables debugging without stopped your code or using 
> an IDE.  
> 
> I'm unsure if I'm super late to the party of if I understand the "problem" / 
> request properly. I apologize if I'm off-base.
> 
> Do you want to be able to examine and modify variables while your program is 
> running, without breaking into it with a debugger?  Is that part of it?
> 
> If so, I've been working my ass off for a couple of weeks to do just that, 
> develop a realtime "watcher" / debugger.
> 
> You'll find the project here:
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> ub.com%2FPySimpleGUI%2Fimwatchingyou&data=02%7C01%7C%7C6fb3d0274c9
> d4f43c41408d6e68b8c39%7C84df9e7fe9f640afb435%7C1%7C0%7C636
> 949884355243495&sdata=D4hun2k3Al2O2cwoSbLwBTlHZDCe17t0n8ijIBoWJUw%
> 3D&reserved=0
> 
> At this time, you must pip install imwatchingyou.  If you're concerned 
> because of the name "imwatchingyou", it's meant to be YOU are watching YOUR 
> code.  If I wanted to watch your Python code, I would have named it 
> "makefreemoneyminingbitcoininpython".
> 
> There is a nice screenshot, although things have been changing.  There are 2 
> primary windows.  The brown one in the upper right of the screen is a 
> realtime update of all of your local variables.  Then there's the large debug 
> window that allows you to do more including running the built-in REPL.
> 
> There is also a version being built into the PySimpleGUI library itself so 
> you do not have to do any imports, etc.  All PySimpleGUI will have this 
> watch/debug capability in it.
> 
> 
> 
> 
> @mike
> 
> -Original Message-
> From: mhysnm1...@gmail.com 
> Sent: Saturday, June 1, 2019 4:53 AM
> To: 'Alan Gauld' ; tutor@python.org
> Subject: Re: [Tutor] Interactive editing of variables.
> 
> As I thought. Easygui is not accessible at all with a screen reader due to 
> the underlying graphic library. Win32 could work if I could load it. Since 
> then I could use standard windows objects.
> 
> Note, I didn't see anything in the quick scan I did ion the API. 
> 
> 
> Very frustrating and disappointing. 
> -Original Message-
> From: Tutor  On Behalf 
> Of Alan Gauld via Tutor
> Sent: Saturday, 1 June 2019 4:50 PM
> To: tutor@python.org
> Subject: Re: [Tutor] Interactive editing of variables.
> 
>> On 01/06/2019 03:53, mhysnm1...@gmail.com wrote:
>> 
>> I have no clue on how to achieve what I want to do and the code I 
>> have creates an hash. As shown below:
> 
> Thats because what you want is not a standard feature of CLI apps.
> You will need to do one of the following(in order of easiness):
> 1) Use a GUI - it then becomes a trivial matter
> 2) Use a pseudo GUI like 

Re: [Tutor] Interactive editing of variables.

2019-06-01 Thread Mike Barnett
TL;DR
There's a run-time debugger out, "imwatchingyou" that is being developed daily, 
fast paced, that enables debugging without stopped your code or using an IDE.  

I'm unsure if I'm super late to the party of if I understand the "problem" / 
request properly. I apologize if I'm off-base.

Do you want to be able to examine and modify variables while your program is 
running, without breaking into it with a debugger?  Is that part of it?

If so, I've been working my ass off for a couple of weeks to do just that, 
develop a realtime "watcher" / debugger.

You'll find the project here:
https://github.com/PySimpleGUI/imwatchingyou

At this time, you must pip install imwatchingyou.  If you're concerned because 
of the name "imwatchingyou", it's meant to be YOU are watching YOUR code.  If I 
wanted to watch your Python code, I would have named it 
"makefreemoneyminingbitcoininpython".

There is a nice screenshot, although things have been changing.  There are 2 
primary windows.  The brown one in the upper right of the screen is a realtime 
update of all of your local variables.  Then there's the large debug window 
that allows you to do more including running the built-in REPL.

There is also a version being built into the PySimpleGUI library itself so you 
do not have to do any imports, etc.  All PySimpleGUI will have this watch/debug 
capability in it.




@mike

-Original Message-
From: mhysnm1...@gmail.com  
Sent: Saturday, June 1, 2019 4:53 AM
To: 'Alan Gauld' ; tutor@python.org
Subject: Re: [Tutor] Interactive editing of variables.

As I thought. Easygui is not accessible at all with a screen reader due to the 
underlying graphic library. Win32 could work if I could load it. Since then I 
could use standard windows objects.

Note, I didn't see anything in the quick scan I did ion the API. 


Very frustrating and disappointing. 
-Original Message-
From: Tutor  On Behalf Of Alan 
Gauld via Tutor
Sent: Saturday, 1 June 2019 4:50 PM
To: tutor@python.org
Subject: Re: [Tutor] Interactive editing of variables.

On 01/06/2019 03:53, mhysnm1...@gmail.com wrote:

> I have no clue on how to achieve what I want to do and the code I have 
> creates an hash. As shown below:

Thats because what you want is not a standard feature of CLI apps.
You will need to do one of the following(in order of easiness):
1) Use a GUI - it then becomes a trivial matter
2) Use a pseudo GUI like curses to provide cursor control
3) Find a module that already does what you need
   (maybe readline can be made to work?)
4) Write a function yourself using screen primitives
   that manage the cursor


> for row in description:
> text = description_rejex(row)
> if text[0] not in narration: 
> Result = input(text[0])
> narration[result] = text

The standard tools allow you to input a new value and overwrite the existing 
one. But there is no simple way to interactively modify an existing value (and 
of course you would need to convert it to/from a string for that to be
possible)

> I have had a look and cannot find an example where I can interactively 
> edit a content of a variable at the command line. I do not want to use 
> GUI at all.

A GUI makes this a trivial problem. Simply display an edit control and insert 
the current value as a string. Allow the user to modify it and when done read 
the new value back. If you don't want to use a GUI you need to provide GUI like 
controls yourself, either through an existing module or by writing one. 
Something like easygui would be eminently suitable. But even vanilla Tkinter is 
almost trivial.

The curses library will do it but that is not standard on Windows and I've 
heard varying reports of how well it works there.

The readline library allows basic editing of the commands line but I'm not sure 
how you would insert your variable into the command line initially...

For windows there are a couple of modules available that provide low level 
cursor control and character input/output, so you could use one of those to 
write such a function.

And if you search hard enough you should find that somebody, somewhere has 
already done the work for you. But I don't know where...

--
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] Multiprocessing with many input input parameters

2019-07-11 Thread Mike Barnett
If you're passing parameters as a list, then you need a "," at the end of the 
items.  Otherwise if you have something like a string as the only item, the 
list will be the string.

list_with_one_item = ['item one',]


@mike

-Original Message-
From: Shall, Sydney  
Sent: Wednesday, July 10, 2019 11:44 AM
To: tutor@python.org
Subject: [Tutor] Multiprocessing with many input input parameters

I am using MAC OS X 10.14.5 on a MAC iBook I use Python 3.7.0 from Anaconda, 
with Spyder 3.3.3

I am a relative beginner.

My program models cell reproduction. I have written a program that models this 
and it works.

Now I want to model a tissue with several types of cells. I did this by simply 
rerunning the program with different inputs (cell characteristics). But now I 
want to send and receive signals between the cells in each population. This 
requires some sort of concurrent processing with halts at appropriate points to 
pass and receive signals.

I thought to use multiprocessing. I have read the documentation and reproduced 
the models in the docs. But I cannot figure out how to feed in the data for 
multiple parameters.

I have tried using Pool and it works fine, but I can only get it to accept 1 
input parameter, although multiple data inputs with one parameter works nicely.

So, my questions are;

  1.  Is multiprocessing the suitable choice.
  2.  if yes, how does one write a function with multiple input parameters.

Thank s in advance.

Sydney

Prodessor. Sydney Shall
Department of Haematological Medicine
King's College London
123 Coldharbour Lane
London SE5 9NU
ENGLAND
E-Mail: sydney.shall
(Correspondents outside the College should add @KCL.AC.UK)
TEL: +44 (0)208 48 59 01

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


Re: [Tutor] Multiprocessing with many input input parameters

2019-07-13 Thread Mike Barnett
Right, I meant tuple, not list.

a = ('A string')
b = ('A List Member',)

print(a[0])
print(b[0])


The output for this is:
A
A List Member



@mike

-Original Message-
From: Cameron Simpson  
Sent: Friday, July 12, 2019 7:59 PM
To: Mike Barnett 
Cc: Shall, Sydney ; tutor@python.org
Subject: Re: [Tutor] Multiprocessing with many input input parameters

On 11Jul2019 15:40, Mike Barnett  wrote:
>If you're passing parameters as a list, then you need a "," at the end of the 
>items.  Otherwise if you have something like a string as the only item, the 
>list will be the string.
>
>list_with_one_item = ['item one',]

Actually, this isn't true.

This is a one element list, no trailing coma required:

  [5]

Mike has probably confused this with tuples. Because tuples are delineated with 
parentheses, there is ambiguity between a tuple's parentheses and normal "group 
these terms together" parentheses.

So:

  x = 5 + 4 * (9 + 7)

Here we just have parentheses causing the assignment "9 + 7" to occur before 
the multiplication by 4. And this is also legal:

  x = 5 + 4 * (9)

where the parentheses don't add anything special in terma of behaviour.

Here is a 2 element tuple:

  (9, 7)

How does one write a one element tuple? Like this:

  (9,)

Here the trailing comma is _required_ to syntacticly indicate that we intend a 
1 element tuple instead of a plain "9 in parentheses") as in the earlier 
assignment statement.

I'm not sure any of this is relevant to Sydney's question though.

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