Programming with Python. Part 2. Replacing console interactions by mouse-click events

emerging-mind.org
eJournal ISSN 2567-6466
info@emerging-mind.org

Gerd Doeben-Henisch
gerd@doeben-henisch.de

PDF

SW-ZIP
CONTENT

1 Problem to be Solved 1
2 How to Program 2
2.1 Continuation with Timer instead of Console Interaction; Quit . 2
2.2 Inserting an Actor by Mouse-Click . . . . . . . . . . . . . . . 3
2.3 Putting Things Together . . . . . . . . . . . . . . . . . . . . . 6

OVERVIEW

Taking the proposal from Part 1 for an environment-actor demo
and enhance it with replacing all console interactions with mouse-click
events
In this part 2 (see the attached PDF for Details) the last version ‚gdh-win10.py‘ will be improved by replacing all console interactions by mouse-clicks or by time-delay functions. There are also some minor improvements of the files environment.py and acctor.py.

How to Continue?

Continue with Part 3

Programming with Python. Part 1. A simple Actor-Environment Demo

emerging-mind.org eJournal ISSN 2567-6466
(info@emerging-mind.org)
Gerd Doeben-Henisch
gerd@doeben-henisch.de
October 14, 2017

PDF

SOFTWARE AS ZIP-FOLDER

Contents
1 Introduction 2
2 Python Context 2
2.1 Python Language Source . . . . . . . . . . . . . . . . . . . . 2
2.2 Simple Graphics Library . . . . . . . . . . . . . . . . . . . . . 3
2.3 Python Console . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.4 Integrated Programming Environment . . . . . . . . . . . . . 4
2.4.1 PyCharm . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4.2 WinPython (With spyder and numpy) . . . . . . . . . . 6
3 Problem to be Solved 6
4 Programming with Python 8
4.1 Testing an Environment . . . . . . . . . . . . . . . . . . . . . 8
4.1.1 A First Window . . . . . . . . . . . . . . . . . . . . . . 8
4.1.2 Rectangles, Lines, Circles, Text-Labels . . . . . . . . 9
4.1.3 Producing a Grid . . . . . . . . . . . . . . . . . . . . . 10
4.1.4 Grid with Vertical Lines . . . . . . . . . . . . . . . . . 12
4.1.5 Grid with Vertical and Horizontal Lines . . . . . . . . . 14
4.1.6 Introduce Helper Functions . . . . . . . . . . . . . . . 15
4.2 Introducing Objects . . . . . . . . . . . . . . . . . . . . . . . . 17
4.3 Introducing Actors . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3.1 First Requirements for an Actor . . . . . . . . . . . . . 22
4.3.2 First Considerations How to Program . . . . . . . . . 23
4.3.3 Let an Actor Move: Environment . . . . . . . . . . . . 27
4.3.4 Let an Actor Move: Actor Self . . . . . . . . . . . . . . 37
4.3.5 The Final Main Procedure . . . . . . . . . . . . . . . 41
4.3.6 Final Helper Functions for the Environment . . . . . . 45
4.3.7 Final Helpfer Funtions for Actors . . . . . . . . . . . . 50
5 Close Up 54

BASIC IDEA

What you see here is the content of the attached PDF.  The text is somehow a protocoll of an experiment to learn the programming language python from scratch. No pre-knowledge, no tools, no teachers! If you are in the same situation and you like to learn python since long, here you can enter and follow the steps.

STARTING WITH A REAL PROBLEM

Many years I opposed to learn python because in my view the language is really disgusting from the point of view of mathematics. But, one has to accept, that python has made its way in many areas including technology, science, and the arts. And because I needed urgently an acepptable software environment for all my theories and experiments there is sometimes the day of decision: you have to start or you can’t show many things.

There is another point: meanwhile I identified as main framework for our theories (which we are discussing on uffmm.org) the combination of ubuntu + ros (robot operating system) + tensoflow. Here python is the main langauge besides C/C++. Furthermore  I detected many applications for our art projects, which are also strongly supported by python. Thus the motivation became stronger than my disgust about this quirky style of thinking.

In the attached PDF you can see how I battled through the python-jungle in 3 days producing a first outcome.

After these 3 days I would say, yes, python is a worthful tool to work with. I am convinced that we can solve most of our problems with it.

Therefore it is highly probable that you will find here more documents with python programs in the future. The idea is indeed to set up a local learning environment (LLE) which is small, flexible, portable,  and very powerful. It should enable really intelligent machines to help people, not to substitute people. The future will belong to new men-machine couplings.

CONTINUE with Part 2