Re: newbie

2020-09-10 Thread edmondo . giovannozzi
You can also have a look at www.scipy.org where you can find some packages used 
for scientific programming like numpy, scipy, matplotlib.
The last one is a graphic package that may be useful to make some initial plots.


Il giorno martedì 8 settembre 2020 22:57:36 UTC+2, Don Edwards ha scritto:
> Purchased the book python-basics-2020-05-18.pdf a few days ago.
> To direct my learning I have a project in mind as per below;
> 
> Just started learning python 3.8. At 76 I will be a bit slow but
> fortunately decades ago l learnt pascal. I am not asking programming help
> just guidance toward package(s) I may need. My aim is to write a program
> that simulates croquet - 2 balls colliding with the strikers (cue) ball
> going into the hoop (pocket), not the target ball. I want to be able to
> move the balls around and draw trajectory lines to evaluate different
> positions. Is there a package for this or maybe one to draw and one to
> move? Any help much appreciated.
> 
> -- 
> Regards, Don Edwards
> I aim to live forever - or die in the attempt. So far so good!
> Perth Western Australia

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: newbie

2020-09-09 Thread Michael Torrie
On 9/8/20 7:24 PM, Grant Edwards wrote:
> On 2020-09-08, Don Edwards  wrote:
> 
>> I may need. My aim is to write a program
>> that simulates croquet - 2 balls colliding with the strikers (cue) ball
>> going into the hoop (pocket), not the target ball. I want to be able to
>> move the balls around and draw trajectory lines to evaluate different
>> positions. Is there a package for this or maybe one to draw and one to
>> move? Any help much appreciated.
> 
> Is pygame still a thing?

Yes. https://www.pygame.org/.  Should be in most Linux distributions'
repositories.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: newbie

2020-09-09 Thread Cameron Simpson
On 09Sep2020 01:24, Grant Edwards  wrote:
>On 2020-09-08, Don Edwards  wrote:
>> I may need. My aim is to write a program
>> that simulates croquet - 2 balls colliding with the strikers (cue) ball
>> going into the hoop (pocket), not the target ball. I want to be able to
>> move the balls around and draw trajectory lines to evaluate different
>> positions. Is there a package for this or maybe one to draw and one to
>> move? Any help much appreciated.
>
>Is pygame still a thing?

Looks like:

https://pypi.org/project/pygame/
https://pypi.org/project/pygame-geometry/

Don, there's a "Getting Started" page for Pygame here:

https://www.pygame.org/wiki/GettingStarted

including some platform specific notes.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: newbie

2020-09-08 Thread Grant Edwards
On 2020-09-08, Don Edwards  wrote:

> I may need. My aim is to write a program
> that simulates croquet - 2 balls colliding with the strikers (cue) ball
> going into the hoop (pocket), not the target ball. I want to be able to
> move the balls around and draw trajectory lines to evaluate different
> positions. Is there a package for this or maybe one to draw and one to
> move? Any help much appreciated.

Is pygame still a thing?

--
Grant


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: newbie

2020-09-08 Thread Cameron Simpson
On 08Sep2020 10:22, Don Edwards  wrote:
>Purchased the book python-basics-2020-05-18.pdf a few days ago.
>To direct my learning I have a project in mind as per below;

A project is an excellent way to learn something; personally I find it 
hard to learn something without something to which to apply it.

>Just started learning python 3.8. At 76 I will be a bit slow but
>fortunately decades ago l learnt pascal.

Aye; I find Python has a very similar "heft" to Pascal - nicely English 
language like "prose" syntax.

>I am not asking programming help
>just guidance toward package(s) I may need. My aim is to write a program
>that simulates croquet - 2 balls colliding with the strikers (cue) ball
>going into the hoop (pocket), not the target ball. I want to be able to
>move the balls around and draw trajectory lines to evaluate different
>positions. Is there a package for this or maybe one to draw and one to
>move? Any help much appreciated.

Python ships with a "tkinter" module which lets you define a GUI 
interface. You probably want some kind of "canvas" or "image" widget 
from within that to render your playing field diagrams/visualisations.

Someone else will have to speak to a nice geometry package for simple 3d 
renders and lines/angles etc.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


newbie

2020-09-08 Thread Don Edwards
Purchased the book python-basics-2020-05-18.pdf a few days ago.
To direct my learning I have a project in mind as per below;

Just started learning python 3.8. At 76 I will be a bit slow but
fortunately decades ago l learnt pascal. I am not asking programming help
just guidance toward package(s) I may need. My aim is to write a program
that simulates croquet - 2 balls colliding with the strikers (cue) ball
going into the hoop (pocket), not the target ball. I want to be able to
move the balls around and draw trajectory lines to evaluate different
positions. Is there a package for this or maybe one to draw and one to
move? Any help much appreciated.

-- 
Regards, Don Edwards
I aim to live forever - or die in the attempt. So far so good!
Perth Western Australia
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Modify Python code as newbie

2020-01-17 Thread MRAB

On 2020-01-18 00:34, ron.egg...@ecoation.com wrote:

Hi,

I'm semi new to Python but need to modify a program that calls the 
mqtt_client.publish()  function from aws iot.
Now, if the publish function fails, it raises an exception.  I need to change 
the code so that when an exception is raised, instead of giving up, it should 
retry.
Here's some semi pseudo code of what I came up with and what I'm particularly 
interested in is, if the exception in pub_msg() is raised, will my thread t 
keep running?
What else could/should be improved about the below snippet? I'm looking forward 
to get some inputs.

Thanks!


>
> import retrying
> import Queue as queue

Is this Python 2? In Python 3 it's called "queue".

> import threading as th
> NUM_THREADS=1
> numth=[]
> def worker():
>  while not_terminated():
>  item = q.get()
>  if item is None:
>  continue
>  do_stuff(item)
>
> def enQ(self, msg, topic):
>  if len(numth  t = th.Thread(target=worker)
>  t.start()
>  numth.append(t)
>  q.put([self,msg,topic])
>
> def do_stuff(dat):
>  self= dat[0]
>  msg = dat[1]
>  topic   = dat[2]
>  pub-msg(slef, msg, topic)

The "-" should be "_" and "slef" should be "self".

>
> def send_msg(self, msg,topic):
>  enQ(self,msg,topic)
>
> def pub_msg(self,msg,topic):
>  try:
>  if topic == "test" and \
>  something[self.xyz]:
>  return
>  except KeyError as err:
>  foo("Exception {}".format(err))

"except" block is indented too much.

If there's a key error, it'll call "foo" (whatever that is) and then 
continue.

>
>  aws_publish(self,msg,topic)
>
> @retry (wait_random_min=1000, wait_random_max=2000)
> def aws_publish(self.msg,topic):

"." instead of ",".

>  self.__mqtt_client.publish(
>  "/{}/{}".format(topic, self._uuid), msg_json, 1)
>
--
https://mail.python.org/mailman/listinfo/python-list


modify python code as newbie

2020-01-17 Thread ron . eggler
Hi,

I'm semi new to Python but need to modify a program that calls the 
mqtt_client.publish()  function from aws iot.
Now, when the publish function fails, it raises an exception.  I need to change 
the code so that when an exception is raised, instead of giving up, it should 
retry (indefinitely).
Here's some semi pseudo code of what I came up with: 
What I'm particularly interested in is, if when the exception in pub_msg() is 
raised, will my thread t keep running? 
What else could/should be improved in the below snippet? I'm looking forward to 
get some inputs.

Thanks!


import retrying
import Queue as queue
import threading as th
NUM_THREADS=1
nth=[]
def worker():
while not_terminated():
item = q.get()
if item is None:
continue
do_stuff(item)

def enQ(self, msg, topic):
if len(nthhttps://mail.python.org/mailman/listinfo/python-list


Modify Python code as newbie

2020-01-17 Thread ron . eggler
Hi,

I'm semi new to Python but need to modify a program that calls the 
mqtt_client.publish()  function from aws iot.
Now, if the publish function fails, it raises an exception.  I need to change 
the code so that when an exception is raised, instead of giving up, it should 
retry.
Here's some semi pseudo code of what I came up with and what I'm particularly 
interested in is, if the exception in pub_msg() is raised, will my thread t 
keep running? 
What else could/should be improved about the below snippet? I'm looking forward 
to get some inputs.

Thanks!


import retrying
import Queue as queue
import threading as th
NUM_THREADS=1
numth=[]
def worker():
while not_terminated():
item = q.get()
if item is None:
continue
do_stuff(item)

def enQ(self, msg, topic):
if len(numthhttps://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-28 Thread RobH

On 28/09/2019 15:59, Dennis Lee Bieber wrote:

On Fri, 27 Sep 2019 19:46:58 +0100, RobH  declaimed the
following:



Thanks for all that information, but first of all using just import
adafruit blinka did not work as it returned bas: import: command not found.



Were you in the Python3 interpreter? That error (I presume it was
"bash:...") means you typed the line at the console shell, not into a

from: can't read /var/mail/Python3from shell console


Python interpreter.

pi@raspberrypi:~$ #from shell console
pi@raspberrypi:~$ import adafruit_blinka
-bash: import: command not found
pi@raspberrypi:~$ #from Python3 interactive interpreter
pi@raspberrypi:~$ python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import adafruit_blinka
exit()

pi@raspberrypi:~$



I should say that this is on a raspberry pi zero w, if it makes any
difference.


It doesn't... All R-Pi system use a default OS of Raspbian (a Debian
modified for R-Pi specific booting and support) {caveat: if using a NOOBS
installer with active WiFi one does have the option of installing any one
of half a dozen OSes, though some are quite specific in usage: Windows IoT,
media player...}

It doesn't even matter if one is using a BeagleBone Black, since that
also runs Debian (though R-Pi has updated to "Buster" while the BBB is
still on "Stretch" [ver 10 vs ver 9]).

debian@beaglebone:~$ #from shell console
debian@beaglebone:~$ import adafruit_blinka
-bash: import: command not found
debian@beaglebone:~$ #from Python3 interactive interpreter
debian@beaglebone:~$ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux

from: can't read /var/mail/Python3from shell console


Type "help", "copyright", "credits" or "license" for more information.

import adafruit_blinka
exit()

debian@beaglebone:~$

It does matter if you try from a system that doesn't support embedded
programming -- Debian 10 running in a VirtualBox instance on a Window10
computer...

Actually -- it did do something

wulfraed@debian:~$ import adafruit_blinka
wulfraed@debian:~$
wulfraed@debian:~$ ls -l
total 11704
-rwxrwx--- 1 wulfraed vboxsf   11909039 Sep 28 10:48 adafruit_blinka
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 13 15:56 Desktop
drwxrwxrwx 3 wulfraed wulfraed 4096 Sep 13 14:20 Documents
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 13 13:53 Downloads
drwxr-xr-x 3 wulfraed wulfraed 4096 Sep 13 15:18 eclipse
drwxr-xr-x 4 wulfraed wulfraed 4096 Sep 13 15:25 eclipse-workspace
drwxrwxrwx 5 wulfraed wulfraed 4096 Sep 11 11:33 ga
drwxrwxrwx 7 wulfraed wulfraed 4096 Sep 11 13:58 Mail
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 11 10:43 Music
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 11 10:43 Pictures
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 11 10:43 Public
drwxrwxrwx 3 wulfraed wulfraed 4096 Sep 17 14:33 Scratch
drwxrwxrwx 3 wulfraed wulfraed 4096 Sep 13 15:15 temp
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 11 10:43 Templates
-rwxrwxrwx 1 wulfraed wulfraed 8984 Sep 13 13:49 testcross
-rwxrwxrwx 1 wulfraed wulfraed  124 Sep 13 13:32 testcross.cpp
drwxrwxrwx 2 wulfraed wulfraed 4096 Sep 11 10:43 Videos

It created a large file that, on examination, is an EPS image file of my
Debian desktop! "import" appears to be a command supplied as part of
"ImageMagick" conversion utility.

After removing the file, the Python3 interpreter reports

wulfraed@debian:~$ python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import adafruit_blinka

Traceback (most recent call last):
   File "", line 1, in 
ModuleNotFoundError: No module named 'adafruit_blinka'

exit()

wulfraed@debian:~$

as expected, since the AdaFruit libraries are not installed on a desktop
machine.









No I wasn't in the Python3 interpreter, and typing
Python3 gets me into, I assume.
Then typing:
import adafruit_blinka seemed to work as there were no errors.

Thanks
--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-27 Thread RobH

On 27/09/2019 15:28, Dennis Lee Bieber wrote:

On Fri, 27 Sep 2019 10:48:29 +0100, RobH  declaimed the
following:


Ok, the adafruit_character_lcd is in the same directory as yours, and so
is Blinka and Purio. It seems to be a bit of a long path to type to get
to the Adafruit_Charlcd directory, but is there a shortcut way of
getting to the said directory.



Other than to examine the source code of the library you have no need
to specify the directory... Within a Python script, a plain "import" should
work.

pi@raspberrypi:~$ python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import adafruit_blinka
import adafruit_character_lcd as acl
dir(acl)

['__doc__', '__file__', '__loader__', '__name__', '__package__',
'__path__', '__spec__']

help(acl)



Help on package adafruit_character_lcd:

NAME
 adafruit_character_lcd

PACKAGE CONTENTS
 character_lcd
 character_lcd_i2c
 character_lcd_rgb_i2c
 character_lcd_spi

FILE
 (built-in)

(END)

from adafruit_character_lcd import character_lcd as cl
help(cl)

Help on module adafruit_character_lcd.character_lcd in
adafruit_character_lcd:

NAME
 adafruit_character_lcd.character_lcd

DESCRIPTION
 `adafruit_character_lcd.character_lcd`
 

 Module for interfacing with monochromatic character LCDs

 * Author(s): Kattni Rembor, Brent Rubell, Asher Lieber,
   Tony DiCola (original python charLCD library)

 Implementation Notes
 

 **Hardware:**

 "* `Adafruit Character LCDs `_"

 **Software and Dependencies:**

 * Adafruit CircuitPython firmware:
   https://github.com/adafruit/circuitpython/releases
 * Adafruit's Bus Device library (when using I2C/SPI):
   https://github.com/adafruit/Adafruit_CircuitPython_BusDevice

CLASSES
{AND MUCH MORE}




Thanks for all that information, but first of all using just import 
adafruit blinka did not work as it returned bas: import: command not found.


I should say that this is on a raspberry pi zero w, if it makes any 
difference.

--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-27 Thread RobH

On 27/09/2019 04:51, Dennis Lee Bieber wrote:

On Thu, 26 Sep 2019 23:04:15 +0100, RobH  declaimed the
following:





As I said, I have downloaded the circuitpython chalcd files from the
link using pip3 install, but after downloading I can't find any Adafruit
folders on my pi zero. Doing a search for adafruit does not show anything.



Did you also install the adafruit-blinka library?

On a Beaglebone Black (my R-Pi is in the depth of major apt-get
update/upgrade cycle -- it feels like it's updating 50% of the OS given how
long it's been running, and that's on a 3B+ quadcore compared to the slower
single core BBB) I find blinka in

debian@beaglebone:~$ sudo find / -iname "*blinka*"
/usr/local/lib/python3.5/dist-packages/Adafruit_Blinka-2.5.0-py3.5.egg-info
/usr/local/lib/python3.5/dist-packages/adafruit_blinka
debian@beaglebone:~$

Note: I ran the installs using "sudo pip3 ..." to make things act
globally; if you ran without sudo the files might be in a hidden directory
of the "pi" account.

Okay, an incomplete search of the R-Pi, stealing cycles from the
upgrade processing)

pi@raspberrypi:~$ sudo find / -iname "*adafruit*"

/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO
/usr/local/lib/python3.7/dist-packages/adafruit_blinka
/usr/local/lib/python3.7/dist-packages/Adafruit_PlatformDetect-1.3.4.dist-info
/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO-0.2.3.dist-info
/usr/local/lib/python3.7/dist-packages/Adafruit_Blinka-2.5.1.dist-info
/usr/local/lib/python3.7/dist-packages/adafruit_platformdetect





Ok, the adafruit_character_lcd is in the same directory as yours, and so 
is Blinka and Purio. It seems to be a bit of a long path to type to get 
to the Adafruit_Charlcd directory, but is there a shortcut way of 
getting to the said directory.


Thanks

--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread DL Neil via Python-list

On 27/09/19 7:21 AM, RobH wrote:

On 26/09/2019 17:51, Dennis Lee Bieber wrote:
On Thu, 26 Sep 2019 11:58:15 +0100, RobH  declaimed 
the

following:

...


Check out this guide for info on using character LCDs with the
CircuitPython library:
https://learn.adafruit.com/character-lcds/python-circuitpython
"""

...

As I said I am a newbie with python and I did not realise that this 
would do what I wanted, doh!



We all have to start somewhere!

As it happens, I was hoping to work on a Raspberry Pi4 project, and have 
been looking at adding cameras and displays. Sadly/ironically I will be 
working on a different project which involves an nVidia Jetson Nano - so 
I'll have to look-up CUDA (apparently it is not a car, nor is it a fish 
that I'd be happy to help you eat...)


The question I wanted to ask/suggestion to make: is there a 'development 
environment' which enables development on a 'bigger PC', for later 
delivery=download to the SBC? It might make coding and unit-testing a 
bit easier (although perhaps not when specific (display) hardware enters 
the picture).


--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread RobH

On 26/09/2019 20:21, RobH wrote:

On 26/09/2019 17:51, Dennis Lee Bieber wrote:
On Thu, 26 Sep 2019 11:58:15 +0100, RobH  declaimed 
the

following:




import Adafruit_CharLCD as LCD



FYI: from Adafruit's download site:
https://github.com/adafruit/Adafruit_Python_CharLCD
"""
DEPRECATED LIBRARY. Adafruit Python CharLCD

This library has been deprecated! We are leaving this up for 
historical and

research purposes but archiving the repository.

We are now only supporting the use of our CircuitPython libraries for use
with Python.

Check out this guide for info on using character LCDs with the
CircuitPython library:
https://learn.adafruit.com/character-lcds/python-circuitpython
"""



# Print a two line message
# lcd.message('Hello\nworld!')


The example "two-line message" relies upon an embedded new-line
character.


lcd.message( "Hello" 1)


This should produce a syntax error

.message(string) only takes one argument -- a string to display. If said
string contains a newline, the library invokes a .set_cursor(col, row) to
move to the start of the next line (though line is limited to the defined
configuration maximum).

If you want to manually position text, you'll need to invoke
.set_cursor(col, row) to do that, then invoke .message(string) to provide
the text.

As mentioned, the library you are using is no longer supported by
AdaFruit. They would prefer you to install the "adafruit_blinka" library
which provides an interface to invoke CircuitPython libraries from boards
running full Python (CircuitPython runs on microcontrollers like 
AdaFruit's
Metro cards). (You'd then have to also install the CircuitPython 
libraries)


https://learn.adafruit.com/circuitpython-on-raspberrypi-linux
(also applies to BeagleBone Black, as I recall)



Thanks for that, as I didn't realise it was deprecated, and have 
downloaded the circuitpython charLCD files.


Also, I note on the site from the link for circuitpython, there is 
information and examples of how to put text on 2 lines, using the 
embedded newline character.


As I said I am a newbie with python and I did not realise that this 
would do what I wanted, doh!


# Print a two line message
# lcd.message('Hello\nworld!').

Thanks again.

As I said, I have downloaded the circuitpython chalcd files from the 
link using pip3 install, but after downloading I can't find any Adafruit 
folders on my pi zero. Doing a search for adafruit does not show anything.


You don't happen to know where it goes to do you.

Thanks
--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread RobH

On 26/09/2019 17:51, Dennis Lee Bieber wrote:

On Thu, 26 Sep 2019 11:58:15 +0100, RobH  declaimed the
following:




import Adafruit_CharLCD as LCD



FYI: from Adafruit's download site:
https://github.com/adafruit/Adafruit_Python_CharLCD
"""
DEPRECATED LIBRARY. Adafruit Python CharLCD

This library has been deprecated! We are leaving this up for historical and
research purposes but archiving the repository.

We are now only supporting the use of our CircuitPython libraries for use
with Python.

Check out this guide for info on using character LCDs with the
CircuitPython library:
https://learn.adafruit.com/character-lcds/python-circuitpython
"""



# Print a two line message
# lcd.message('Hello\nworld!')


The example "two-line message" relies upon an embedded new-line
character.


lcd.message( "Hello" 1)


This should produce a syntax error

.message(string) only takes one argument -- a string to display. If said
string contains a newline, the library invokes a .set_cursor(col, row) to
move to the start of the next line (though line is limited to the defined
configuration maximum).

If you want to manually position text, you'll need to invoke
.set_cursor(col, row) to do that, then invoke .message(string) to provide
the text.

As mentioned, the library you are using is no longer supported by
AdaFruit. They would prefer you to install the "adafruit_blinka" library
which provides an interface to invoke CircuitPython libraries from boards
running full Python (CircuitPython runs on microcontrollers like AdaFruit's
Metro cards). (You'd then have to also install the CircuitPython libraries)

https://learn.adafruit.com/circuitpython-on-raspberrypi-linux
(also applies to BeagleBone Black, as I recall)



Thanks for that, as I didn't realise it was deprecated, and have 
downloaded the circuitpython charLCD files.


Also, I note on the site from the link for circuitpython, there is 
information and examples of how to put text on 2 lines, using the 
embedded newline character.


As I said I am a newbie with python and I did not realise that this 
would do what I wanted, doh!


# Print a two line message
# lcd.message('Hello\nworld!').

Thanks again.

--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread RobH

On 26/09/2019 15:22, Chris Angelico wrote:

On Thu, Sep 26, 2019 at 9:01 PM RobH  wrote:


import Adafruit_CharLCD as LCD


# Raspberry Pi pin configuration:


Ah, it's an RPi with Adafruit. That's the same library that my brother
uses. I don't know much of the details, but in case it's helpful,
here's the code that currently runs his subscriber appreciation board:

https://github.com/stephenangelico/SubBoard/blob/master/lcd_char.py

You might be able to borrow some ideas from that.

ChrisA



Thanks and yes it is the adafruit char_lcd.py file I was using, but now 
a modded one to suit my needs.


I see that lcd_char.py is a modded version as well, and I will download 
it to see what I can use from it.


Thanks
--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread RobH

On 26/09/2019 12:55, Rhodri James wrote:

On 26/09/2019 11:58, RobH wrote:

Thanks, but was is Python REPR.


DL was referring to the interactive program you get when you type 
"python" at a Linux or Windows command prompt.  Here's an example, 
copied from my Linux box:


rhodri@scrote:~$ python
Python 2.7.15+ (default, Jul  9 2019, 16:51:35)
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import cgi
 >>> help(cgi)
[[screeds of documentation for the cgi module cut]]
 >>> [[type control-D to get out]]
rhodri@scrote:~$

(The bits in [[double square brackets]] are my comments, not something 
either I or Python typed!)



This my adaptation of non working code. Bodged from the char_lcd.py code:

   GNU nano 2.7.4  File: char_lcd.py

#!/usr/bin/python
# Example using a character LCD connected to a Raspberry Pi or 
BeagleBone Black.

import time

import Adafruit_CharLCD as LCD


Aha, that's the critical information we were lacking earlier.  I found 
the Adafruit_CharLCD library after a little googling.  It's marked as 
deprecated (the author now uses something else), but if it works for you 
you might as well keep on using it.


[[Much set-up for the Pi cut for brevity]]


# Initialize the LCD using the pins above.
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, 
lcd_d7,

    lcd_columns, lcd_rows, lcd_backlight)

# Print a two line message
# lcd.message('Hello\nworld!')
lcd.message( "Hello" 1)


It looks like lcd.message() takes a text string and displays on the LCD, 
starting at the current cursor position (I'll get back to that).  You 
optimistically added an extra argument, the line number to start at 
(you're missing a comma, but that's an easy typo to make and I assume 
you already caught it).  Unfortunately lcd.message() only takes the one 
argument, the text string.  This is where that error message comes from: 
"TypeError: message() takes exactly 2 arguments (3 given)" means that 
you gave the function more arguments than it knew what to do with.


(Why 2 and 3 instead of 1 and 2?  "lcd" itself is an argument to 
message(), telling it which lcd to send the message to if you had more 
than one.  When you look at the function definition, you'll see that it 
start with "def message(self, text):" which makes that a bit more 
explicit.  Anyway, that's beside the point.)


So how do you control where you start your message on the LCD?  It looks 
like the answer is the lcd.set_cursor() function.  The cursor is the 
point from which your printing starts.  In your text editor it's 
probably a blinking vertical line (or underscore, or blob... editors 
vary).  On your LCD display it's probably invisible, though it looks 
like there's another function to change that.


Anyway, you give set_cursor() a column number and a row number in that 
order.  I think they start from 0, so to write "Hello" to the second 
line of your display you would write:


   lcd.set_cursor(0, 1)
   lcd.message("Hello")

The gotcha here is that message() is only going to write the characters 
you tell it to, and won't overwrite anything else.  If for example you 
followed up the two lines above with:


   lcd.set_cursor(0, 1)  # Back to the start of the line
   lcd.message("Bye")

you would end up with "Byelo" displayed on the LCD.  You would need to 
put extra spaces on the end of your message to overwrite the characters 
you don't want any more, but not so many that you overwrite what you 
want to keep.  Working out how many spaces that is for any given message 
could be quite tedious.  You may well find it easier to lcd.clear() the 
whole display and rewrite everything when you want to change anything.


Anyway, I hope that helps.



Thank you, that does help me just great.
So simple as well. Actually I have worked quite a lot with Arduinos and 
the code or sketch for an lcd there is just the same to write to the 2nd 
line. I didn't think it would work for python, but it does!
Other lines like lcd.delay(1000) and lcd.begin(16,2), do not work in 
python, but I thought to try them to find out.


I am using a Raspberry Pi Zero for this little project, which now does 
what I want for now.


Thanks again.
--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread Chris Angelico
On Thu, Sep 26, 2019 at 9:01 PM RobH  wrote:
>
> import Adafruit_CharLCD as LCD
>
>
> # Raspberry Pi pin configuration:

Ah, it's an RPi with Adafruit. That's the same library that my brother
uses. I don't know much of the details, but in case it's helpful,
here's the code that currently runs his subscriber appreciation board:

https://github.com/stephenangelico/SubBoard/blob/master/lcd_char.py

You might be able to borrow some ideas from that.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread Rhodri James

On 26/09/2019 11:58, RobH wrote:

Thanks, but was is Python REPR.


DL was referring to the interactive program you get when you type 
"python" at a Linux or Windows command prompt.  Here's an example, 
copied from my Linux box:


rhodri@scrote:~$ python
Python 2.7.15+ (default, Jul  9 2019, 16:51:35)
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cgi
>>> help(cgi)
[[screeds of documentation for the cgi module cut]]
>>> [[type control-D to get out]]
rhodri@scrote:~$

(The bits in [[double square brackets]] are my comments, not something 
either I or Python typed!)



This my adaptation of non working code. Bodged from the char_lcd.py code:

   GNU nano 2.7.4  File: char_lcd.py

#!/usr/bin/python
# Example using a character LCD connected to a Raspberry Pi or 
BeagleBone Black.

import time

import Adafruit_CharLCD as LCD


Aha, that's the critical information we were lacking earlier.  I found 
the Adafruit_CharLCD library after a little googling.  It's marked as 
deprecated (the author now uses something else), but if it works for you 
you might as well keep on using it.


[[Much set-up for the Pi cut for brevity]]


# Initialize the LCD using the pins above.
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,
    lcd_columns, lcd_rows, lcd_backlight)

# Print a two line message
# lcd.message('Hello\nworld!')
lcd.message( "Hello" 1)


It looks like lcd.message() takes a text string and displays on the LCD, 
starting at the current cursor position (I'll get back to that).  You 
optimistically added an extra argument, the line number to start at 
(you're missing a comma, but that's an easy typo to make and I assume 
you already caught it).  Unfortunately lcd.message() only takes the one 
argument, the text string.  This is where that error message comes from: 
"TypeError: message() takes exactly 2 arguments (3 given)" means that 
you gave the function more arguments than it knew what to do with.


(Why 2 and 3 instead of 1 and 2?  "lcd" itself is an argument to 
message(), telling it which lcd to send the message to if you had more 
than one.  When you look at the function definition, you'll see that it 
start with "def message(self, text):" which makes that a bit more 
explicit.  Anyway, that's beside the point.)


So how do you control where you start your message on the LCD?  It looks 
like the answer is the lcd.set_cursor() function.  The cursor is the 
point from which your printing starts.  In your text editor it's 
probably a blinking vertical line (or underscore, or blob... editors 
vary).  On your LCD display it's probably invisible, though it looks 
like there's another function to change that.


Anyway, you give set_cursor() a column number and a row number in that 
order.  I think they start from 0, so to write "Hello" to the second 
line of your display you would write:


  lcd.set_cursor(0, 1)
  lcd.message("Hello")

The gotcha here is that message() is only going to write the characters 
you tell it to, and won't overwrite anything else.  If for example you 
followed up the two lines above with:


  lcd.set_cursor(0, 1)  # Back to the start of the line
  lcd.message("Bye")

you would end up with "Byelo" displayed on the LCD.  You would need to 
put extra spaces on the end of your message to overwrite the characters 
you don't want any more, but not so many that you overwrite what you 
want to keep.  Working out how many spaces that is for any given message 
could be quite tedious.  You may well find it easier to lcd.clear() the 
whole display and rewrite everything when you want to change anything.


Anyway, I hope that helps.

--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread RobH

On 26/09/2019 11:08, DL Neil wrote:

On 26/09/19 9:14 PM, RobH wrote:
I have some sample/demo python code for scrolling and outputting text 
onto a 16x2 lcd display.


I would like to put my own message or text outputting to the lcd on 2 
lines. I have tried using lcd.message('my message',1) and 
lcd.message('my message', 2), but the output says:


TypeError: message() takes exactly 2 arguments (3 given)

I have also seen this on the, stackexchange site:
lcd_string("your text " + str(yourVar), 1)

But what is str(yourVar), as I assume it means a variable.
If I could have a working example please, that would be great.



I'm wondering if "lcd_string" should be "lcd.string" (per "lcd.message") 
  - would it be better to post the actual (not) working code?


Suggest you fire-up the Python REPR:

 python3    # on a Linux terminal

then:

 import ***whatever the LCD package is called ***
 help( ***whatever...called *** )

The output from this will tell you the names of all the entities within 
the package. Within that you will be able to check for the pertinent 
class (from which lcd was derived) and see what it says about arguments 
for the message() and/or string() methods - particularly the number of 
arguments and their data-type(s).



Thanks, but was is Python REPR.
This my adaptation of non working code. Bodged from the char_lcd.py code:

  GNU nano 2.7.4 
 File: char_lcd.py 



#!/usr/bin/python
# Example using a character LCD connected to a Raspberry Pi or 
BeagleBone Black.

import time

import Adafruit_CharLCD as LCD


# Raspberry Pi pin configuration:
lcd_rs= 27  # Note this might need to be changed to 21 for older 
revision Pi's.

lcd_en= 22
lcd_d4= 25
lcd_d5= 24
lcd_d6= 23
lcd_d7= 18
lcd_backlight = 4

# BeagleBone Black configuration:
# lcd_rs= 'P8_8'
# lcd_en= 'P8_10'
# lcd_d4= 'P8_18'
# lcd_d5= 'P8_16'
# lcd_d6= 'P8_14'
# lcd_d7= 'P8_12'
# lcd_backlight = 'P8_7'

# Define LCD column and row size for 16x2 LCD.
lcd_columns = 16
lcd_rows= 2

# Alternatively specify a 20x4 LCD.
# lcd_columns = 20
# lcd_rows= 4

# Initialize the LCD using the pins above.
lcd = LCD.Adafruit_CharLCD(lcd_rs, lcd_en, lcd_d4, lcd_d5, lcd_d6, lcd_d7,
   lcd_columns, lcd_rows, lcd_backlight)

# Print a two line message
# lcd.message('Hello\nworld!')
lcd.message( "Hello" 1)


# Wait 5 seconds
time.sleep(5.0)

# Demo showing the cursor.
#lcd.clear()
# Wait 5 seconds
time.sleep(5.0)

# Demo showing the cursor.
#lcd.clear()
#lcd.show_cursor(True)
#lcd.message('Show cursor')
lcd.message("Your dental",1)
lcd.message("appointment is",2)

time.sleep(5.0)

# Demo showing the blinking cursor.
lcd.clear()

--
https://mail.python.org/mailman/listinfo/python-list


Re: NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread DL Neil via Python-list

On 26/09/19 9:14 PM, RobH wrote:
I have some sample/demo python code for scrolling and outputting text 
onto a 16x2 lcd display.


I would like to put my own message or text outputting to the lcd on 2 
lines. I have tried using lcd.message('my message',1) and 
lcd.message('my message', 2), but the output says:


TypeError: message() takes exactly 2 arguments (3 given)

I have also seen this on the, stackexchange site:
lcd_string("your text " + str(yourVar), 1)

But what is str(yourVar), as I assume it means a variable.
If I could have a working example please, that would be great.



I'm wondering if "lcd_string" should be "lcd.string" (per "lcd.message") 
 - would it be better to post the actual (not) working code?


Suggest you fire-up the Python REPR:

python3 # on a Linux terminal

then:

import ***whatever the LCD package is called ***
help( ***whatever...called *** )

The output from this will tell you the names of all the entities within 
the package. Within that you will be able to check for the pertinent 
class (from which lcd was derived) and see what it says about arguments 
for the message() and/or string() methods - particularly the number of 
arguments and their data-type(s).

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


NEWBIE: how to get text onto 2 lines on a 16x2 lcd display

2019-09-26 Thread RobH
I have some sample/demo python code for scrolling and outputting text 
onto a 16x2 lcd display.


I would like to put my own message or text outputting to the lcd on 2 
lines. I have tried using lcd.message('my message',1) and 
lcd.message('my message', 2), but the output says:


TypeError: message() takes exactly 2 arguments (3 given)

I have also seen this on the, stackexchange site:
lcd_string("your text " + str(yourVar), 1)

But what is str(yourVar), as I assume it means a variable.
If I could have a working example please, that would be great.

Thanks

--
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-26 Thread Paul St George

On 25/08/2019 02:39, Cameron Simpson wrote:

On 24Aug2019 21:52, Paul St George  wrote:

[snip]>
Aside from "map" being a poor name (it is also a builtin Python 
function), it seems that one creates one of these to control how some 
rendering process is done.


The class reference page you originally cites then specifies the meaning 
of the various attributes you might set on one of these objects.


Cheers,
Cameron Simpson 


Thanks Cameron. As this list has a low noise to signal ratio I cannot 
thank you enough here.


I could have stayed where I belong in Blender Artists, or similar, but 
those lists tend to just offer solutions and as Douglas Adams almost 
said knowledge without understanding is almost meaningless. Here I have 
gained enough understanding (perhaps not to yet make sufficient sense in 
what I say) but to transfer knowledge from solving one problem to 
possibly solving many.


Thank you for your patience and tolerance,

Dr Paul St George
--
http://www.paulstgeorge.com
http://www.devices-of-wonder.com


--
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-24 Thread Cameron Simpson

On 24Aug2019 21:52, Paul St George  wrote:

Have you not got one of these handed to you from something?

Or are you right at the outside with some "opaque" blender handle or 
something? (Disclaimer: I've never used Blender.)


Thank you once again.
If I understand your question, I am right outside. By this I mean I 
have not created anything with Python. I have made the Blender model 
with the UI and am trying to use Python to read the values for the 
settings used. This has worked for all settings except this Map Value 
Node.


Hmm. So you have a CompositorNodeMapValue instance? If that is the case 
you should be able to inspect it as previously described.


However, it looks like this is something you construct in order to do 
some task. A little web searching turns up this stackexchange post:


 
https://blender.stackexchange.com/questions/42579/render-depth-map-to-image-with-python-script/42667

and some example code from an unrelated project:

 
https://github.com/panmari/stanford-shapenet-renderer/blob/master/render_blender.py


From the stackexchange post:


   map = tree.nodes.new(type="CompositorNodeMapValue")
   # Size is chosen kind of arbitrarily, try out until you're satisfied 
   # with resulting depth map.

   map.size = [0.08]
   map.use_min = True
   map.min = [0]
   map.use_max = True
   map.max = [255]

"tree" is "bpy.context.scene.node_tree".

Aside from "map" being a poor name (it is also a builtin Python 
function), it seems that one creates one of these to control how some 
rendering process is done.


The class reference page you originally cites then specifies the meaning 
of the various attributes you might set on one of these objects.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-24 Thread Barry
Have you tried asking on a blender user mailing list for help with this problem?

It seems that someone familiar with blender and its python interface should be 
able to help get you going.

Barry

> On 24 Aug 2019, at 20:52, Paul St George  wrote:
> 
>> On 24/08/2019 01:23, Cameron Simpson wrote:
>>> On 23Aug2019 13:49, Paul St George  wrote:
>>> Context:
>>> I am using Python to interrogate the value of some thing in Blender (just 
>>> as someone else might want to use Python to look at an email in a Mail 
>>> program or an image in Photoshop).
>>> 
>>> Assumptions:
>>> So, I want to look at the attribute of an instance of a class called 
>>> CompositorNodeMapValue. The code in the Python tutorial seems to be for 
>>> creating an instance of a class, but I assume Blender (in my case) has 
>>> already created the instance that I want to interrogate.
>> That would be the expectation. And to interrogate it, you need that instance 
>> to hand in a variable.
>>> Question:
>>> If this is so, should I find the code to get a list of the instances that 
>>> have been made (maybe using inspect?) and then, when I have its name, the 
>>> attributes of the one that interests me?
>> Have you not got one of these handed to you from something?
>> Or are you right at the outside with some "opaque" blender handle or 
>> something? (Disclaimer: I've never used Blender.)
> 
> Thank you once again.
> If I understand your question, I am right outside. By this I mean I have not 
> created anything with Python. I have made the Blender model with the UI and 
> am trying to use Python to read the values for the settings used. This has 
> worked for all settings except this Map Value Node.
> 
>> You can inspect objects with the inspect module. You can also be more 
>> direct. Given an object "o", you can do an assortment of things:
> 
> Before I do any of the following, I assume I need to use something like:
> 
> import struct
> class CompositorNodeMapValue(o):
> 
> I have tried this. Nothing happens. Not even an error. It's like waiting for 
> Godot.
> 
> I am guessing I am in the wrong namespace.
> 
> I don't know whether it is relevant, but I tried plain
> dir()
> and
> dir(struct)
> 
> They each returned a list and neither list had mention of 
> CompositorNodeMapValue
> 
> If I do something like:
> o = CompositorNodeMapValue()
> I get:
> NameError: name 'CompositorNodeMapValue' is not defined
> 
>> dir(o) gets a list of its attribute names.
>> help(o) prints out the docstring, somewhat rendered.
>> o.__dict__ is usually a dict mapping attribute names to their values.
>> type(o) gets you its type, so "print(type(o))" or "print(type(o).__name__)" 
>> can be handy.
>> A crude probe function (untested):
>>  def probe(o):
>>print(o)
>>for attr, value in sorted(o.__dict__.items()):
>>  print(" ", attr, type(value).__name__, value)
>> Enjoy,
>> Cameron Simpson  (formerly c...@zip.com.au)
>> "Are we alpinists, or are we tourists" followed by "tourists! tourists!"
>>- Kobus Barnard  in rec.climbing,
>>  on things he's heard firsthand
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-24 Thread Paul St George

On 24/08/2019 01:23, Cameron Simpson wrote:

On 23Aug2019 13:49, Paul St George  wrote:

Context:
I am using Python to interrogate the value of some thing in Blender 
(just as someone else might want to use Python to look at an email in 
a Mail program or an image in Photoshop).


Assumptions:
So, I want to look at the attribute of an instance of a class called 
CompositorNodeMapValue. The code in the Python tutorial seems to be 
for creating an instance of a class, but I assume Blender (in my case) 
has already created the instance that I want to interrogate.


That would be the expectation. And to interrogate it, you need that 
instance to hand in a variable.



Question:
If this is so, should I find the code to get a list of the instances 
that have been made (maybe using inspect?) and then, when I have its 
name, the attributes of the one that interests me?


Have you not got one of these handed to you from something?

Or are you right at the outside with some "opaque" blender handle or 
something? (Disclaimer: I've never used Blender.)


Thank you once again.
If I understand your question, I am right outside. By this I mean I have 
not created anything with Python. I have made the Blender model with the 
UI and am trying to use Python to read the values for the settings used. 
This has worked for all settings except this Map Value Node.




You can inspect objects with the inspect module. You can also be more 
direct. Given an object "o", you can do an assortment of things:


Before I do any of the following, I assume I need to use something like:

import struct
class CompositorNodeMapValue(o):

I have tried this. Nothing happens. Not even an error. It's like waiting 
for Godot.


I am guessing I am in the wrong namespace.

I don't know whether it is relevant, but I tried plain
dir()
and
dir(struct)

They each returned a list and neither list had mention of 
CompositorNodeMapValue


If I do something like:
o = CompositorNodeMapValue()
I get:
NameError: name 'CompositorNodeMapValue' is not defined



dir(o) gets a list of its attribute names.

help(o) prints out the docstring, somewhat rendered.

o.__dict__ is usually a dict mapping attribute names to their values.

type(o) gets you its type, so "print(type(o))" or 
"print(type(o).__name__)" can be handy.


A crude probe function (untested):

  def probe(o):
    print(o)
    for attr, value in sorted(o.__dict__.items()):
  print(" ", attr, type(value).__name__, value)

Enjoy,
Cameron Simpson  (formerly c...@zip.com.au)

"Are we alpinists, or are we tourists" followed by "tourists! tourists!"
    - Kobus Barnard  in rec.climbing,
  on things he's heard firsthand



--
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-23 Thread Cameron Simpson

On 23Aug2019 13:49, Paul St George  wrote:

Context:
I am using Python to interrogate the value of some thing in Blender 
(just as someone else might want to use Python to look at an email in 
a Mail program or an image in Photoshop).


Assumptions:
So, I want to look at the attribute of an instance of a class called 
CompositorNodeMapValue. The code in the Python tutorial seems to be 
for creating an instance of a class, but I assume Blender (in my case) 
has already created the instance that I want to interrogate.


That would be the expectation. And to interrogate it, you need that 
instance to hand in a variable.



Question:
If this is so, should I find the code to get a list of the instances 
that have been made (maybe using inspect?) and then, when I have its 
name, the attributes of the one that interests me?


Have you not got one of these handed to you from something?

Or are you right at the outside with some "opaque" blender handle or 
something? (Disclaimer: I've never used Blender.)


You can inspect objects with the inspect module. You can also be more 
direct. Given an object "o", you can do an assortment of things:


dir(o) gets a list of its attribute names.

help(o) prints out the docstring, somewhat rendered.

o.__dict__ is usually a dict mapping attribute names to their values.

type(o) gets you its type, so "print(type(o))" or 
"print(type(o).__name__)" can be handy.


A crude probe function (untested):

 def probe(o):
   print(o)
   for attr, value in sorted(o.__dict__.items()):
 print(" ", attr, type(value).__name__, value)

Enjoy,
Cameron Simpson  (formerly c...@zip.com.au)

"Are we alpinists, or are we tourists" followed by "tourists! tourists!"
   - Kobus Barnard  in rec.climbing,
 on things he's heard firsthand
--
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-23 Thread Paul St George

On 22/08/2019 23:21, Kyle Stanley wrote:
[snip]


The tutorial that Terry was referring to was the one on docs.python.org,
here's a couple of links for the sections he was referring to:

Full section on classes: https://docs.python.org/3/tutorial/classes.html

Section on instantiating objects from classes:
https://docs.python.org/3/tutorial/classes.html#class-objects


[snip]



Aha, thank you all.
Here then, is my first problem.

Context:
I am using Python to interrogate the value of some thing in Blender 
(just as someone else might want to use Python to look at an email in a 
Mail program or an image in Photoshop).


Assumptions:
So, I want to look at the attribute of an instance of a class called 
CompositorNodeMapValue. The code in the Python tutorial seems to be for 
creating an instance of a class, but I assume Blender (in my case) has 
already created the instance that I want to interrogate.


Question:
If this is so, should I find the code to get a list of the instances 
that have been made (maybe using inspect?) and then, when I have its 
name, the attributes of the one that interests me?


Or shall I go into the garden to eat worms?

--
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-22 Thread Kyle Stanley
> You are right, but it is even worse than you think. I do not have a
tutorial so I have no examples to understand.

The tutorial that Terry was referring to was the one on docs.python.org,
here's a couple of links for the sections he was referring to:

Full section on classes: https://docs.python.org/3/tutorial/classes.html

Section on instantiating objects from classes:
https://docs.python.org/3/tutorial/classes.html#class-objects

On Thu, Aug 22, 2019 at 4:40 PM Paul St George 
wrote:

> On 22/08/2019 20:02, Terry Reedy wrote:
> > On 8/22/2019 3:34 AM, Paul St George wrote:
> >> I have the Python API for the Map Value Node here:
> >> <
> https://docs.blender.org/api/current/bpy.types.CompositorNodeMapValue.html>.
>
> >>
> >>
> >> All well and good. Now I just want to write a simple line of code such
> >> as:
> >>
> >> import bpy
> >>
> >> ...
> >>
> >>  >>>print(bpy.types.CompositorNodeMapValue.max[0])
> >>
> >> If this works, I will do something similar for max, min, offset and
> >> then size.
> >
> >  From this and your other responses, you seem to not understand some of
> > the concepts explained in the tutorial, in particular class and class
> > instance.  Perhaps you should reread the appropriate section(s), and if
> > you don't understand any of the examples, ask about them here.  We are
> > familiar with those, but not with CompositorNodeMapValue.
> >
> >
> Terry,
> You are right, but it is even worse than you think. I do not have a
> tutorial so I have no examples to understand.
>
> Reading Cameron et al, I have broken the problem down into:
> do something (probably using the word self) that _gives_ me an instance
> of CompositorNodeMapValue.
>
> Then when I done that,
> look at some of the attributes (.max, .min, .offset, .size) of the
> instance.
>
> Paul
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-22 Thread Paul St George

On 22/08/2019 20:02, Terry Reedy wrote:

On 8/22/2019 3:34 AM, Paul St George wrote:
I have the Python API for the Map Value Node here: 
. 



All well and good. Now I just want to write a simple line of code such 
as:


import bpy

...

 >>>print(bpy.types.CompositorNodeMapValue.max[0])

If this works, I will do something similar for max, min, offset and 
then size.


 From this and your other responses, you seem to not understand some of 
the concepts explained in the tutorial, in particular class and class 
instance.  Perhaps you should reread the appropriate section(s), and if 
you don't understand any of the examples, ask about them here.  We are 
familiar with those, but not with CompositorNodeMapValue.




Terry,
You are right, but it is even worse than you think. I do not have a 
tutorial so I have no examples to understand.


Reading Cameron et al, I have broken the problem down into:
do something (probably using the word self) that _gives_ me an instance 
of CompositorNodeMapValue.


Then when I done that,
look at some of the attributes (.max, .min, .offset, .size) of the instance.

Paul

--
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-22 Thread Terry Reedy

On 8/22/2019 3:34 AM, Paul St George wrote:
I have the Python API for the Map Value Node here: 
. 



All well and good. Now I just want to write a simple line of code such as:

import bpy

...

 >>>print(bpy.types.CompositorNodeMapValue.max[0])

If this works, I will do something similar for max, min, offset and then 
size.


From this and your other responses, you seem to not undertstand some of 
the concepts explained in the tutorial, in particular class and class 
instance.  Perhaps you should reread the appropriate section(s), and if 
you don't understand any of the examples, ask about them here.  We are 
familiar with those, but not with CompositorNodeMapValue.



--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-22 Thread Chris Angelico
On Thu, Aug 22, 2019 at 9:20 PM Paul St George  wrote:
>
> On 22/08/2019 11:49, Cameron Simpson wrote:
> > On 22Aug2019 09:34, Paul St George  wrote:
> >> I have the Python API for the Map Value Node here:
> >> .
> >>
> >>
> >> All well and good. Now I just want to write a simple line of code such
> >> as:
> >>
> >> import bpy
> > print(bpy.types.CompositorNodeMapValue.max[0])
> > [...]
> >> AttributeError: type object 'CompositorNodeMapValue' has no attribute
> >> 'max'
> >
> > CompositorNodeMapValue is a class. All the attributes described are for
> > instances of the class. So you need to do something that _gives_ you an
> > instance of CompositorNodeMapValue. That instance should have a .max array.
> >
> > Cheers,
> > Cameron Simpson 
>
> Gulp. Thank you. I did ask for a pointer but perhaps I need a roadmap.
>
> I have tried to do something that gives me an instance of
> CompositorNodeMapValue. I don't think I should humiliate myself further
> by sharing my attempts so could you please show me what the code should
> look like.
>

Don't think of it as humiliating yourself - you're asking for fairly
specific advice, so showing your code is the best way to get that sort
of advice. We don't bite :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-22 Thread Paul St George

On 22/08/2019 11:49, Cameron Simpson wrote:

On 22Aug2019 09:34, Paul St George  wrote:
I have the Python API for the Map Value Node here: 
. 



All well and good. Now I just want to write a simple line of code such 
as:


import bpy

print(bpy.types.CompositorNodeMapValue.max[0])

[...]
AttributeError: type object 'CompositorNodeMapValue' has no attribute 
'max'


CompositorNodeMapValue is a class. All the attributes described are for 
instances of the class. So you need to do something that _gives_ you an 
instance of CompositorNodeMapValue. That instance should have a .max array.


Cheers,
Cameron Simpson 


Gulp. Thank you. I did ask for a pointer but perhaps I need a roadmap.

I have tried to do something that gives me an instance of 
CompositorNodeMapValue. I don't think I should humiliate myself further 
by sharing my attempts so could you please show me what the code should 
look like.


--
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about Python syntax

2019-08-22 Thread Cameron Simpson

On 22Aug2019 09:34, Paul St George  wrote:

I have the Python API for the Map Value Node here: 
.

All well and good. Now I just want to write a simple line of code such as:

import bpy

print(bpy.types.CompositorNodeMapValue.max[0])

[...]
AttributeError: type object 'CompositorNodeMapValue' has no attribute 
'max'


CompositorNodeMapValue is a class. All the attributes described are for 
instances of the class. So you need to do something that _gives_ you an 
instance of CompositorNodeMapValue. That instance should have a .max 
array.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Newbie question about Python syntax

2019-08-22 Thread Paul St George
I have the Python API for the Map Value Node here: 
.


All well and good. Now I just want to write a simple line of code such as:

import bpy

...

>>>print(bpy.types.CompositorNodeMapValue.max[0])

If this works, I will do something similar for max, min, offset and then 
size.


I know my embarrassingly feeble attempt is wrong because the console 
tells me:

AttributeError: type object 'CompositorNodeMapValue' has no attribute 'max'

Could anyone (please) point me in the right direction?

Thanks,
Paul
--
https://mail.python.org/mailman/listinfo/python-list


Re: newbie question

2019-08-01 Thread Sidney Langweil
On Thursday, August 1, 2019 at 7:57:31 AM UTC-7, Calvin Spealman wrote:
> Sorry, but you can't. If you have two python modules, neither has access to
> things in the other without an import.
> 
> That's the whole point of an import.
> 
> On Thu, Aug 1, 2019 at 10:30 AM Sidney Langweil 
> wrote:
> 
> > A Python script invokes a function in another file in the same directory.
> >
> > I would like to invoke that function without the need for an import.
> >
> > I think I read that having an empty __init__.py is sufficient.  But it
> > does not seem to work for me.
> >
> > I'm sure this is obvious to many of you.  Thanks in advance for your help.
> >
> > Sid
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
> 
> 
> -- 
> 
> CALVIN SPEALMAN
> 
> SENIOR QUALITY ENGINEER
> 
> cspea...@redhat.com  M: +1.336.210.5107
> [image: https://red.ht/sig] 
> TRIED. TESTED. TRUSTED. 

Thank you.  As long as using 'import' is correct in this case, I do not mind 
inserting the extra line(s).

Side
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: newbie question

2019-08-01 Thread Calvin Spealman
Sorry, but you can't. If you have two python modules, neither has access to
things in the other without an import.

That's the whole point of an import.

On Thu, Aug 1, 2019 at 10:30 AM Sidney Langweil 
wrote:

> A Python script invokes a function in another file in the same directory.
>
> I would like to invoke that function without the need for an import.
>
> I think I read that having an empty __init__.py is sufficient.  But it
> does not seem to work for me.
>
> I'm sure this is obvious to many of you.  Thanks in advance for your help.
>
> Sid
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] 
TRIED. TESTED. TRUSTED. 
-- 
https://mail.python.org/mailman/listinfo/python-list


newbie question

2019-08-01 Thread Sidney Langweil
A Python script invokes a function in another file in the same directory.

I would like to invoke that function without the need for an import.

I think I read that having an empty __init__.py is sufficient.  But it does not 
seem to work for me.

I'm sure this is obvious to many of you.  Thanks in advance for your help.

Sid
-- 
https://mail.python.org/mailman/listinfo/python-list


tix.FileSelectBox causes crash: was A newbie question about using tix

2019-05-03 Thread David Sumbler


On Wed, 2019-05-01 at 19:11 +0100, MRAB wrote:
> On 2019-05-01 17:44, David Sumbler wrote:
>  >
>  > On Tue, 2019-04-30 at 20:46 +0100, MRAB wrote:
...
>  > > For some reason, tix widgets don't work with normal tkinter
> widgets,
>  > > so
>  > > you can't put a tix FileSelectBox on a tkinter.Tk widget.
>  > >
>  > > There is, however, a tix.Tk widget that you can use instead:
>  > >
>  > > import tkinter.tix as tix
>  > > root = tix.Tk()
>  > > f = tix.FileSelectBox(root)
>  > > f.pack()
>  >
>  > Thanks for that.
>  >
>  > When I ran the above, I got:
>  >
>  >  Traceback (most recent call last):
>  >File "/home/david/bin/GradientProfile_v2.py", line 2, in
> 
>  >  root = tix.Tk()
>  >File "/usr/lib/python3.6/tkinter/tix.py", line 214, in
> __init__
>  >  self.tk.eval('package require Tix')
>  >  _tkinter.TclError: can't find package Tix
>  >
>  > After an internet search, I tried:
>  >
>  > sudo apt install tix-dev tk-dev tk8.6-dev libxft-dev 
> libfontconfig1-dev libfreetype6-dev libpng-dev
>  >
>  > Now when I run the file the program just exits quickly, with no
>  > reported errors, but no window(s).  If I add 'root.mainloop()' at
> the
>  > end, I get an empty root window for a fraction of a second, then
> the
>  > program exits with:
>  >
>  >  Segmentation fault (core dumped)
>  >
>  > Any suggestions as to where to go from here?
>  >
> Tested on Raspbian in a terminal window:
> 
> sudo apt-get install tix
> 
> python3
> 
> import tkinter.tix as tix
> root = tix.Tk()
> f = tix.FileSelectBox(root)
> f.pack()
> 
> At this point there's a GUi window filled with a file section box.

When I enter the above lines in python 3.6.7 on my desktop computer,
running Ubuntu 18.04, the final line causes Python to crash with the
message:

 Segmentation fault (core dumped)

I also tried this in python 2.7.15rc1 with the same result.

I then tried it on my HP laptop computer, also running Ubuntu 18.04. 
Again, it produced a segmentation fault.

However, on my partner's computer, which is running Ubuntu 16.04, the
code works as it should.

It looks as if perhaps there is some bug in Ubuntu 18.04 which, so far
as my experience goes, only manifests itself when using tix in Python
(either version 2 or 3).  I have run most of the files in Mark Lutz's
Programming Python (including most of the tkinter chapters) without any
problem.

I can find no reference to a bug of this sort when doing an internet
search, so perhaps there could be some other explanation.

Does anyone else see the same crash when trying to use
tix.FileSelectionBox?

David
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie question about using tix

2019-05-01 Thread MRAB

On 2019-05-01 17:44, David Sumbler wrote:
>
> On Tue, 2019-04-30 at 20:46 +0100, MRAB wrote:
> > On 2019-04-30 16:40, David Sumbler wrote:
> > > Running Ubuntu 18.04, Python 3.6.7, tkinter 8.6
> > >
> > > I am very new to tkinter.  The simple program I am writing requires
> > > a
> > > user file to be selected before it does anything else, so I would
> > > like
> > > a file selection dialog in the main window as soon as the program
> > > launches.
> > >
> > > Tkinter only has askopenfilename(), but this produces a popup
> > > dialog.
> > > I can get something like what I want by specifying a small Tk()
> > > window
> > > and then calling askopenfilename() so that it covers the root
> > > window.
> > >
> > > It's not ideal, though.  From the documentation I thought that the
> > > tix
> > > FileSelectBox would do what I wanted, but I just can't get it to
> > > work.
> > >
> > > If I run:
> > >
> > >   from tkinter import *
> > >   from tkinter.tix import FileSelectBox
> > >   root = Tk()
> > >   f = FileSelectBox(root)
> > >
> > > I get the following:
> > >
> > >   Traceback (most recent call last):
> > > File "/home/david/bin/Gradient.py", line 4, in 
> > >   f = FileSelectBox(root)
> > > File "/usr/lib/python3.6/tkinter/tix.py", line 795, in
> > > __init__
> > >   TixWidget.__init__(self, master, 'tixFileSelectBox',
> > > ['options'], cnf, kw)
> > > File "/usr/lib/python3.6/tkinter/tix.py", line 311, in
> > > __init__
> > >   self.tk.call(widgetName, self._w, *extra)
> > >   _tkinter.TclError: invalid command name "tixFileSelectBox"
> > >
> > > I realize that assigning the value of FileSelectBox() isn't going
> > > to
> > > give me a filename: I'm just trying to get the basic syntax right
> > > at
> > > the moment.
> > >
> > > I can't figure out what is wrong though.  Have I have misunderstood
> > > how
> > > it should be called, or is there something missing from my system?
> > >
> >
> > For some reason, tix widgets don't work with normal tkinter widgets,
> > so
> > you can't put a tix FileSelectBox on a tkinter.Tk widget.
> >
> > There is, however, a tix.Tk widget that you can use instead:
> >
> > import tkinter.tix as tix
> > root = tix.Tk()
> > f = tix.FileSelectBox(root)
> > f.pack()
>
> Thanks for that.
>
> When I ran the above, I got:
>
>  Traceback (most recent call last):
>    File "/home/david/bin/GradientProfile_v2.py", line 2, in 
>  root = tix.Tk()
>    File "/usr/lib/python3.6/tkinter/tix.py", line 214, in __init__
>  self.tk.eval('package require Tix')
>  _tkinter.TclError: can't find package Tix
>
> After an internet search, I tried:
>
> sudo apt install tix-dev tk-dev tk8.6-dev libxft-dev 
libfontconfig1-dev libfreetype6-dev libpng-dev

>
> Now when I run the file the program just exits quickly, with no
> reported errors, but no window(s).  If I add 'root.mainloop()' at the
> end, I get an empty root window for a fraction of a second, then the
> program exits with:
>
>  Segmentation fault (core dumped)
>
> Any suggestions as to where to go from here?
>
Tested on Raspbian in a terminal window:

sudo apt-get install tix

python3

import tkinter.tix as tix
root = tix.Tk()
f = tix.FileSelectBox(root)
f.pack()

At this point there's a GUi window filled with a file section box.

--
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie question about using tix

2019-05-01 Thread David Sumbler


On Tue, 2019-04-30 at 20:46 +0100, MRAB wrote:
> On 2019-04-30 16:40, David Sumbler wrote:
> > Running Ubuntu 18.04, Python 3.6.7, tkinter 8.6
> > 
> > I am very new to tkinter.  The simple program I am writing requires
> > a
> > user file to be selected before it does anything else, so I would
> > like
> > a file selection dialog in the main window as soon as the program
> > launches.
> > 
> > Tkinter only has askopenfilename(), but this produces a popup
> > dialog.
> > I can get something like what I want by specifying a small Tk()
> > window
> > and then calling askopenfilename() so that it covers the root
> > window.
> > 
> > It's not ideal, though.  From the documentation I thought that the
> > tix
> > FileSelectBox would do what I wanted, but I just can't get it to
> > work.
> > 
> > If I run:
> > 
> >   from tkinter import *
> >   from tkinter.tix import FileSelectBox
> >   root = Tk()
> >   f = FileSelectBox(root)
> > 
> > I get the following:
> > 
> >   Traceback (most recent call last):
> > File "/home/david/bin/Gradient.py", line 4, in 
> >   f = FileSelectBox(root)
> > File "/usr/lib/python3.6/tkinter/tix.py", line 795, in
> > __init__
> >   TixWidget.__init__(self, master, 'tixFileSelectBox',
> > ['options'], cnf, kw)
> > File "/usr/lib/python3.6/tkinter/tix.py", line 311, in
> > __init__
> >   self.tk.call(widgetName, self._w, *extra)
> >   _tkinter.TclError: invalid command name "tixFileSelectBox"
> > 
> > I realize that assigning the value of FileSelectBox() isn't going
> > to
> > give me a filename: I'm just trying to get the basic syntax right
> > at
> > the moment.
> > 
> > I can't figure out what is wrong though.  Have I have misunderstood
> > how
> > it should be called, or is there something missing from my system?
> > 
> 
> For some reason, tix widgets don't work with normal tkinter widgets,
> so 
> you can't put a tix FileSelectBox on a tkinter.Tk widget.
> 
> There is, however, a tix.Tk widget that you can use instead:
> 
> import tkinter.tix as tix
> root = tix.Tk()
> f = tix.FileSelectBox(root)
> f.pack()

Thanks for that.

When I ran the above, I got:

 Traceback (most recent call last):
   File "/home/david/bin/GradientProfile_v2.py", line 2, in 
 root = tix.Tk()
   File "/usr/lib/python3.6/tkinter/tix.py", line 214, in __init__
 self.tk.eval('package require Tix')
 _tkinter.TclError: can't find package Tix

After an internet search, I tried:

sudo apt install tix-dev tk-dev tk8.6-dev libxft-dev libfontconfig1-dev 
libfreetype6-dev libpng-dev

Now when I run the file the program just exits quickly, with no
reported errors, but no window(s).  If I add 'root.mainloop()' at the
end, I get an empty root window for a fraction of a second, then the
program exits with:

 Segmentation fault (core dumped)

Any suggestions as to where to go from here?

David

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie question about using tix

2019-04-30 Thread MRAB

On 2019-04-30 16:40, David Sumbler wrote:

Running Ubuntu 18.04, Python 3.6.7, tkinter 8.6

I am very new to tkinter.  The simple program I am writing requires a
user file to be selected before it does anything else, so I would like
a file selection dialog in the main window as soon as the program
launches.

Tkinter only has askopenfilename(), but this produces a popup dialog.
I can get something like what I want by specifying a small Tk() window
and then calling askopenfilename() so that it covers the root window.

It's not ideal, though.  From the documentation I thought that the tix
FileSelectBox would do what I wanted, but I just can't get it to work.

If I run:

  from tkinter import *
  from tkinter.tix import FileSelectBox
  root = Tk()
  f = FileSelectBox(root)

I get the following:

  Traceback (most recent call last):
File "/home/david/bin/Gradient.py", line 4, in 
  f = FileSelectBox(root)
File "/usr/lib/python3.6/tkinter/tix.py", line 795, in __init__
  TixWidget.__init__(self, master, 'tixFileSelectBox', ['options'], 
cnf, kw)
File "/usr/lib/python3.6/tkinter/tix.py", line 311, in __init__
  self.tk.call(widgetName, self._w, *extra)
  _tkinter.TclError: invalid command name "tixFileSelectBox"

I realize that assigning the value of FileSelectBox() isn't going to
give me a filename: I'm just trying to get the basic syntax right at
the moment.

I can't figure out what is wrong though.  Have I have misunderstood how
it should be called, or is there something missing from my system?

For some reason, tix widgets don't work with normal tkinter widgets, so 
you can't put a tix FileSelectBox on a tkinter.Tk widget.


There is, however, a tix.Tk widget that you can use instead:

import tkinter.tix as tix
root = tix.Tk()
f = tix.FileSelectBox(root)
f.pack()
--
https://mail.python.org/mailman/listinfo/python-list


A newbie question about using tix

2019-04-30 Thread David Sumbler
Running Ubuntu 18.04, Python 3.6.7, tkinter 8.6

I am very new to tkinter.  The simple program I am writing requires a
user file to be selected before it does anything else, so I would like
a file selection dialog in the main window as soon as the program
launches.

Tkinter only has askopenfilename(), but this produces a popup dialog. 
I can get something like what I want by specifying a small Tk() window
and then calling askopenfilename() so that it covers the root window.

It's not ideal, though.  From the documentation I thought that the tix
FileSelectBox would do what I wanted, but I just can't get it to work.

If I run:

 from tkinter import *
 from tkinter.tix import FileSelectBox
 root = Tk()
 f = FileSelectBox(root)

I get the following:

 Traceback (most recent call last):
   File "/home/david/bin/Gradient.py", line 4, in 
 f = FileSelectBox(root)
   File "/usr/lib/python3.6/tkinter/tix.py", line 795, in __init__
 TixWidget.__init__(self, master, 'tixFileSelectBox', ['options'], cnf, 
kw)
   File "/usr/lib/python3.6/tkinter/tix.py", line 311, in __init__
 self.tk.call(widgetName, self._w, *extra)
 _tkinter.TclError: invalid command name "tixFileSelectBox"

I realize that assigning the value of FileSelectBox() isn't going to
give me a filename: I'm just trying to get the basic syntax right at
the moment.

I can't figure out what is wrong though.  Have I have misunderstood how
it should be called, or is there something missing from my system?

David


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: TKinter Newbie question

2019-01-18 Thread TUA
Thanks for your fresh pair of eyes!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: TKinter Newbie question

2019-01-17 Thread Peter Otten
TUA wrote:

> Why does the button frame in the code below not show?

> tk.Button(bf, padx = 10, relief = tk.GROOVE, text = 'Help')

You forgot to layout it with .pack().

> I intend to have it displayed in between the notebook at the top and the
> fake statusbar at the bottom.

I think for that you need to swap the sb.pack() and bf.pack() calls, or 
remove side=BOTTOM from bf.pack().


-- 
https://mail.python.org/mailman/listinfo/python-list


TKinter Newbie question

2019-01-17 Thread TUA
Why does the button frame in the code below not show?

I intend to have it displayed in between the notebook at the top and the fake 
statusbar at the bottom.

Thanks for any help!


from tkinter import ttk
import tkinter as tk

class MainForm():

def __init__(self, master):

self.master = master
self.master.title('Test')

nb = ttk.Notebook(self.master)

page_1 = ttk.Frame(nb)

nframe = ttk.LabelFrame(page_1, text='Frame', padding = 10)
tk.Label(nframe, padx = 10, pady = 5, text = 'Name').pack()
tk.Entry(nframe, width = 30).pack()
tk.Label(nframe, padx = 10, pady = 5, text = 'City').pack()
tk.Entry(nframe, width = 30).pack()
#
nframe.pack(fill="both", expand="yes", padx = 10, pady = 10)  # pad 
around the frame

nb.add(page_1, text = 'Tab #1')

nb.pack(expand = True, fill = "both")


#---
# button frame for Help button   why does it not show? 


#---
bf = ttk.Frame(self.master, relief = tk.SUNKEN)
tk.Button(bf, padx = 10, relief = tk.GROOVE, text = 'Help')
bf.pack(side = tk.BOTTOM, fill = tk.X)


#---
# fake a status bar from a label

#---
sb = tk.Label(self.master, text = ' Waiting for rain ...', bd = 1, 
anchor = tk.W, relief = tk.SUNKEN)
sb.pack(side = tk.BOTTOM, fill = tk.X)

def CloseApplication(self):
self.master.destroy()

def StartApplication():
root = tk.Tk()

MainForm(root)
root.mainloop()

if __name__ == '__main__':
StartApplication()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RE newbie question

2018-04-18 Thread Steven D'Aprano
On Wed, 18 Apr 2018 12:37:29 -0700, TUA wrote:

> My intention is to implement a max. length of 8 for an input string. The
> above works well in all other respects, but does allow for strings that
> are too long.

if len(input_string) > 8:
raise ValueError('string is too long')



-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RE newbie question

2018-04-18 Thread Albert-Jan Roskam

On Apr 18, 2018 21:42, TUA  wrote:
>
> import re
>
> compval = 'A123456_8'
> regex = '[a-zA-Z]\w{0,7}'
>
> if re.match(regex, compval):
>print('Yes')
> else:
>print('No')
>
>
> My intention is to implement a max. length of 8 for an input string. The 
> above works well in all other respects, but does allow for strings that are 
> too long.
>
> What is the proper way to fix this?

Use a $ sign at the end of the regex
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RE newbie question

2018-04-18 Thread TUA
Thanks much!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RE newbie question

2018-04-18 Thread Ian Kelly
On Wed, Apr 18, 2018 at 1:57 PM, Rob Gaddi
 wrote:
> On 04/18/2018 12:37 PM, TUA wrote:
>>
>> import re
>>
>> compval = 'A123456_8'
>> regex = '[a-zA-Z]\w{0,7}'
>>
>> if re.match(regex, compval):
>> print('Yes')
>> else:
>> print('No')
>>
>>
>> My intention is to implement a max. length of 8 for an input string. The
>> above works well in all other respects, but does allow for strings that are
>> too long.
>>
>> What is the proper way to fix this?
>>
>> Thanks for any help!
>>
>
> You could put the end marker $ on your regex so that it won't match if it's
> not the end.
>
> Or, you know, you could just check len(compval) <= 8 and not get bogged down
> in regexes.  They tend to be excellent solutions to only a very specific
> complexity of problem.

In Python 3.4+ you can also use re.fullmatch which requires a match
against the entire string.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: RE newbie question

2018-04-18 Thread Rob Gaddi

On 04/18/2018 12:37 PM, TUA wrote:

import re

compval = 'A123456_8'
regex = '[a-zA-Z]\w{0,7}'

if re.match(regex, compval):
print('Yes')
else:
print('No')


My intention is to implement a max. length of 8 for an input string. The above 
works well in all other respects, but does allow for strings that are too long.

What is the proper way to fix this?

Thanks for any help!



You could put the end marker $ on your regex so that it won't match if 
it's not the end.


Or, you know, you could just check len(compval) <= 8 and not get bogged 
down in regexes.  They tend to be excellent solutions to only a very 
specific complexity of problem.


--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
--
https://mail.python.org/mailman/listinfo/python-list


RE newbie question

2018-04-18 Thread TUA
import re

compval = 'A123456_8'
regex = '[a-zA-Z]\w{0,7}'

if re.match(regex, compval):
   print('Yes')
else:
   print('No')  


My intention is to implement a max. length of 8 for an input string. The above 
works well in all other respects, but does allow for strings that are too long.

What is the proper way to fix this?

Thanks for any help!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ARGPARSE Newbie question

2018-04-17 Thread TUA
Thanks for the pointers!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ARGPARSE Newbie question

2018-04-17 Thread paulclarke345
On Tuesday, April 17, 2018 at 7:09:45 PM UTC-5, TUA wrote:
> I'd like to create a script that handles a number of verbs with mandatory and 
> /or optional parameters like listed in the table below.
> 
> Can ARGPARSE do this and how?
> 
> Thanks for all help!
> 
> 
> 
> 
> 
> Script  VerbMandatory parameters Optional 
> parameters 
> --
> myprog.py   list---  verbose 
> 
> myprog.py   add sid(string), type (string), memory (int) comment 
> (string), autostart (bool, default=TRUE)
> 
> myprog.py   memory  sid (string), memory (integer)
> 
> myprog.py   comment sid(string), comment (string)
> 
> myprog.py   restore sid(string), srcpath (string)
> 
> myprog.py   backup  sid(string), dstpath(string) 
> 
> myprog.py   remove  sid (string)

you can use subparsers for this. The syntax goes something like this:

parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subparser_name')
list_parser = subparsers.add_parser("list", help="help for list")
list_parse.add_argument("-v", "--verbose", help="show verbose output",
  action="store_true")
add_parser = subparsers.add_parser("add", help="help for add")
add.add_argument("sid", type=str, help="help for sid")
...
etc. see the documentation on argparse for more on this.
-- 
https://mail.python.org/mailman/listinfo/python-list


ARGPARSE Newbie question

2018-04-17 Thread TUA
I'd like to create a script that handles a number of verbs with mandatory and 
/or optional parameters like listed in the table below.

Can ARGPARSE do this and how?

Thanks for all help!





Script  VerbMandatory parameters Optional 
parameters 
--
myprog.py   list---  verbose 

myprog.py   add sid(string), type (string), memory (int) comment 
(string), autostart (bool, default=TRUE)

myprog.py   memory  sid (string), memory (integer)

myprog.py   comment sid(string), comment (string)

myprog.py   restore sid(string), srcpath (string)

myprog.py   backup  sid(string), dstpath(string) 

myprog.py   remove  sid (string)
-- 
https://mail.python.org/mailman/listinfo/python-list


Newbie ARGPARSE question

2018-04-17 Thread TUA
I just discovered ARGPARSE 5 minutes ago and cannot figure this one out:

What does the Parser.add_argument() call have to look like when I need an
option 'add' that requires the mandatory parameters 'type' (string), 'size' 
(int), 'sid' (string) and must also handle the optional parameters 'comment' 
(string) and 'auto-start' (bool, defaults to TRUE).


Thanks to all helping me preserve my sanity!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] how to remove empty lines from webpage/file

2018-02-27 Thread Dan Stromberg
Perhaps replace:
lines=soup.get_text()
file.write(lines)

...with something like:
text = soup.get_text()
lines = text.split('\n')
for line in lines:
if line.strip():
file.write('%s\n' % (line, ))

(untested)


On Tue, Feb 27, 2018 at 2:50 AM,   wrote:
> Dear all,
> I try to get the numerical data from the following webpage:
> http://www.astro.oma.be/GENERAL/INFO/nzon/zon_2018.html
>
> With the following code-fragment I was already able to get a partial result:
>
> #!/usr/bin/env python
> #memo: install bs4 as follows: sudo easy_install bs4
> # -*- coding: utf-8 -*-
> #3 lines below necessary to avoid encoding problem
> import sys
> reload(sys)
> sys.setdefaultencoding('utf8')
> import urllib2
> file = open("testfile.txt","w")
> source = "http://www.astro.oma.be/GENERAL/INFO/nzon/zon_2018.html;
> page = urllib2.urlopen(source)
> from bs4 import BeautifulSoup
> soup = BeautifulSoup(page,'lxml')
> lines=soup.get_text()
> file.write(lines)
> file.close()
>
> I tried to delete the empty lines but I am totally stuck at this moment, can 
> anyone help me further?
>
> thanks in advance
> jens
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


[newbie] how to remove empty lines from webpage/file

2018-02-27 Thread jenswaelkens
Dear all,
I try to get the numerical data from the following webpage:
http://www.astro.oma.be/GENERAL/INFO/nzon/zon_2018.html

With the following code-fragment I was already able to get a partial result:

#!/usr/bin/env python
#memo: install bs4 as follows: sudo easy_install bs4 
# -*- coding: utf-8 -*-
#3 lines below necessary to avoid encoding problem
import sys
reload(sys)
sys.setdefaultencoding('utf8')
import urllib2
file = open("testfile.txt","w") 
source = "http://www.astro.oma.be/GENERAL/INFO/nzon/zon_2018.html;
page = urllib2.urlopen(source)
from bs4 import BeautifulSoup
soup = BeautifulSoup(page,'lxml')
lines=soup.get_text()
file.write(lines)
file.close()

I tried to delete the empty lines but I am totally stuck at this moment, can 
anyone help me further?

thanks in advance
jens
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie problem with urllib.request.urlopen

2017-09-26 Thread Bernie Connors
On Tuesday, September 26, 2017 at 12:32:18 PM UTC-3, Bernie Connors wrote:
> Hello,
> 
>   My first post here on C.L.P.  I have only written a few python scripts 
> in 2.7 and now I'm trying my first python 3 script.  Can you tell me why this 
> snippet won't run?
> ---
> from urllib.request import urlopen
> 
> with 
> urlopen('http://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_Parcels/MapServer/0/query?outSR=4617=JSON=PID='75385120'')
>  as conn:
> print(conn)
> ---
> Thanks,
> Bernie.

Peter Otten,

  Yes that seems to work better.  Thanks for the tips.  But I see now that 
I am getting some http errors when I try to run this code from the Microsoft 
Azure Notebooks.  Here is the URL to my Note Book:
https://notebooks.azure.com/n/n31C2DSCOr8/notebooks/URLopen%20Test.ipynb
And here is the error:
URLError: 

Does anybody know if something can be done about this with urllib? Or is 
this completely related to the firewall rules at http://geonb.snb.ca??

Thanks,
Bernie.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie problem with urllib.request.urlopen

2017-09-26 Thread Peter Otten
Bernie Connors wrote:

> On Tuesday, September 26, 2017 at 12:32:18 PM UTC-3, Bernie Connors wrote:
>> Hello,
>> 
>>   My first post here on C.L.P.  I have only written a few python
>>   scripts in 2.7 and now I'm trying my first python 3 script.  Can
>>   you tell me why this snippet won't run?
>> ---
>> from urllib.request import urlopen
>> 
>> with
>> 
urlopen('http://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_Parcels/MapServer/0/query?outSR=4617=JSON=PID='75385120'')
>> as conn:
>> print(conn)
>> ---
>> Thanks,
>> Bernie.
> 
> Thomas,
> 
>   The PID parameter at the end of my url must be enclosed in single
>   quotes, '75385120', or the API won't execute the query.  I have the

Then use " to quote the Python string:

>>> import urllib.request
>>> url = 
"http://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_Parcels/MapServer/0/query?outSR=4617=JSON=PID='75385120'"
>>> with urllib.request.urlopen(url) as conn:
... print(conn)
... data = conn.read()
... 

>>> data[:20]
b'{"displayFieldName":'

Looks good. To convert the data into a Python dict:

>>> import json
>>> d = json.loads(data.decode("utf-8"))
>>> d
{'features': [{'attributes': {'PID': '75385120'}, 'geometry': {'rings': 
[snip]

PS: For other ways to write a Python string literal have a look into the 
tutorial:

https://docs.python.org/3.6/tutorial/introduction.html#strings


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie problem with urllib.request.urlopen

2017-09-26 Thread Bernie Connors
On Tuesday, September 26, 2017 at 12:32:18 PM UTC-3, Bernie Connors wrote:
> Hello,
> 
>   My first post here on C.L.P.  I have only written a few python scripts 
> in 2.7 and now I'm trying my first python 3 script.  Can you tell me why this 
> snippet won't run?
> ---
> from urllib.request import urlopen
> 
> with 
> urlopen('http://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_Parcels/MapServer/0/query?outSR=4617=JSON=PID='75385120'')
>  as conn:
> print(conn)
> ---
> Thanks,
> Bernie.

Thomas,

  The PID parameter at the end of my url must be enclosed in single quotes, 
'75385120', or the API won't execute the query.  I have the code in a python 
notebook on Azure - 
https://notebooks.azure.com/n/n31C2DSCOr8/notebooks/URLopen%20Test.ipynb

Here are the error messages I am getting:
---
HTTPError Traceback (most recent call last)
 in ()
  1 from urllib.request import urlopen
> 2 with 
urlopen("http://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_Parcels/MapServer/0/query?outSR=4617=JSON=PID='75385120'")
 as conn:
  3 print(conn)

~/anaconda3_410/lib/python3.5/urllib/request.py in urlopen(url, data, timeout, 
cafile, capath, cadefault, context)
160 else:
161 opener = _opener
--> 162 return opener.open(url, data, timeout)
163 
164 def install_opener(opener):

~/anaconda3_410/lib/python3.5/urllib/request.py in open(self, fullurl, data, 
timeout)
469 for processor in self.process_response.get(protocol, []):
470 meth = getattr(processor, meth_name)
--> 471 response = meth(req, response)
472 
473 return response

~/anaconda3_410/lib/python3.5/urllib/request.py in http_response(self, request, 
response)
579 if not (200 <= code < 300):
580 response = self.parent.error(
--> 581 'http', request, response, code, msg, hdrs)
582 
583 return response

~/anaconda3_410/lib/python3.5/urllib/request.py in error(self, proto, *args)
507 if http_err:
508 args = (dict, 'default', 'http_error_default') + orig_args
--> 509 return self._call_chain(*args)
510 
511 # XXX probably also want an abstract factory that knows when it makes

~/anaconda3_410/lib/python3.5/urllib/request.py in _call_chain(self, chain, 
kind, meth_name, *args)
441 for handler in handlers:
442 func = getattr(handler, meth_name)
--> 443 result = func(*args)
444 if result is not None:
445 return result

~/anaconda3_410/lib/python3.5/urllib/request.py in http_error_default(self, 
req, fp, code, msg, hdrs)
587 class HTTPDefaultErrorHandler(BaseHandler):
588 def http_error_default(self, req, fp, code, msg, hdrs):
--> 589 raise HTTPError(req.full_url, code, msg, hdrs, fp)
590 
591 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 403: Forbidden
--

Thanks,
Bernie.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie problem with urllib.request.urlopen

2017-09-26 Thread MRAB

On 2017-09-26 16:31, berniejconn...@gmail.com wrote:

Hello,

   My first post here on C.L.P.  I have only written a few python scripts 
in 2.7 and now I'm trying my first python 3 script.  Can you tell me why this 
snippet won't run?
---
from urllib.request import urlopen

with 
urlopen('http://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_Parcels/MapServer/0/query?outSR=4617=JSON=PID='75385120'')
 as conn:
 print(conn)
---
Thanks,
Bernie.


Check the quotes.

The argument you're passing to urlopen is:

'http://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_Parcels/MapServer/0/query?outSR=4617=JSON=PID='75385120''

which is actually:

'http://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_Parcels/MapServer/0/query?outSR=4617=JSON=PID=' 
75385120 ''


A string, then an int, then another string.

I think you mean:

'http://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_Parcels/MapServer/0/query?outSR=4617=JSON=PID="75385120;'
--
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie problem with urllib.request.urlopen

2017-09-26 Thread Thomas Jollans
On 2017-09-26 17:31, berniejconn...@gmail.com wrote:
> Hello,
> 
>   My first post here on C.L.P.  I have only written a few python scripts 
> in 2.7 and now I'm trying my first python 3 script.  Can you tell me why this 
> snippet won't run?

What do you mean, "won't run"? Is there an error message?

> ---
> from urllib.request import urlopen
> 
> with 
> urlopen('http://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_Parcels/MapServer/0/query?outSR=4617=JSON=PID='75385120'')
>  as conn:
> print(conn)

You may have messed up some quotes there.

> ---
> Thanks,
> Bernie.
> 


-- 
Thomas Jollans
-- 
https://mail.python.org/mailman/listinfo/python-list


Newbie problem with urllib.request.urlopen

2017-09-26 Thread berniejconnors
Hello,

  My first post here on C.L.P.  I have only written a few python scripts in 
2.7 and now I'm trying my first python 3 script.  Can you tell me why this 
snippet won't run?
---
from urllib.request import urlopen

with 
urlopen('http://geonb.snb.ca/arcgis/rest/services/GeoNB_SNB_Parcels/MapServer/0/query?outSR=4617=JSON=PID='75385120'')
 as conn:
print(conn)
---
Thanks,
Bernie.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: newbie question re classes and self

2017-03-29 Thread Rick Johnson
On Tuesday, March 28, 2017 at 3:09:45 AM UTC-5, loial wrote:
> Can I pass self(or all its variables) to a class?
> Basically, how do I make all the variables defined in self
> in the calling python script available to the python class
> I want to call?

Your question, as presented, is difficult to understand, and
the phrase "variables defined in self", is quite absurd.

I'm making a wild assumption here, but perhaps you want to
"bulk-set" or "bulk-query" all the attributes of a class
instance externally? If so, depending on how the object was
defined, there are a few ways to achieve this.

However, my advanced powers of perception tell me that you
might be using Python in an incorrect manner, but i cannot
be sure until you explain this problem in more detail. So if
you can provide us a simple code example, or even psuedo
code, that would be very helpful.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: newbie question re classes and self

2017-03-28 Thread Terry Reedy

On 3/28/2017 4:09 AM, loial wrote:

Can I pass self(or all its variables) to a class?


In Python, every argument to every function is an instance of some 
class.  The function can access any attribute of the arguments it 
receives with arg.attribute.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: newbie question re classes and self

2017-03-28 Thread Peter Otten
loial wrote:

> Can I pass self(or all its variables) to a class?
> 
> Basically, how do I make all the variables defined in self in the calling
> python script available to the python class I want to call?

Inside a method you can access attributes of an instance as self.whatever:

>>> class A:
... def foo(self):
... self.bar = 42
... def baz(self):
... print(self.bar)
... 
>>> a = A()
>>> a.baz() # bar attribute not yet set
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 5, in baz
AttributeError: 'A' object has no attribute 'bar'
>>> a.foo() # sets bar
>>> a.baz() # successfully print the newly created bar attribute
42

The class itself has no access to bar. In the rare case where you want to 
share data between instances you can use a class attribute:

>>> class B:
... bar = 42
... 
>>> x = B()
>>> y = B()
>>> x.bar
42
>>> y.bar
42

If neither is what you want please give a concrete example or a more 
detailed plain-english description.

-- 
https://mail.python.org/mailman/listinfo/python-list


newbie question re classes and self

2017-03-28 Thread loial
Can I pass self(or all its variables) to a class?

Basically, how do I make all the variables defined in self in the calling 
python script available to the python class I want to call?



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie Need Help On Regex!

2016-10-10 Thread breamoreboy
On Monday, October 10, 2016 at 3:58:56 PM UTC+1, infos...@gmail.com wrote:
> Hey guys!
>  
> I am new to learning regex in python and I'm wondering how do I use regex in 
> python to store the integers(positive and negative) i want into a list!
>  
> For e.g.
>  
> This is the data in a list.
>  
> [u'\x1b[0m[\x1b[1m\x1b[0m\xbb\x1b[0m\x1b[36m]\x1b[0m (A=-5,B=5)', 
> u'\x1b[0m[\x1b[1m\x1b[0m\xbb\x1b[0m\x1b[36m]\x1b[0m (A=5,Y=5)', 
> u'\x1b[0m[\x1b[1m\x1b[10m\xbb\x1b[0m\x1b[36m]\x1b[0m : ']
>  
> How do I extract the values of A and B and store them in a variable I want 
> using regex?
>  
> Thank you and appreciate it :)

What makes you think you need a regex?  Why don't you write some code and when 
you have problems, post it here.  Then we'll give you some answers.

Kindest regards.

Mark Lawrence.
-- 
https://mail.python.org/mailman/listinfo/python-list


Newbie Need Help On Regex!

2016-10-10 Thread infosecflag
Hey guys!
 
I am new to learning regex in python and I'm wondering how do I use regex in 
python to store the integers(positive and negative) i want into a list!
 
For e.g.
 
This is the data in a list.
 
[u'\x1b[0m[\x1b[1m\x1b[0m\xbb\x1b[0m\x1b[36m]\x1b[0m (A=-5,B=5)', 
u'\x1b[0m[\x1b[1m\x1b[0m\xbb\x1b[0m\x1b[36m]\x1b[0m (A=5,Y=5)', 
u'\x1b[0m[\x1b[1m\x1b[10m\xbb\x1b[0m\x1b[36m]\x1b[0m : ']
 
How do I extract the values of A and B and store them in a variable I want 
using regex?
 
Thank you and appreciate it :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Newbie Need Help On Regex!

2016-10-10 Thread infosecflag
Hey guys!
 
I am new to learning regex in python and I'm wondering how do I use regex in 
python to store the integers(positive and negative) i want into a list!
 
For e.g.
 
This is the data in a list.
 
[u'\x1b[0m[\x1b[1m\x1b[0m\xbb\x1b[0m\x1b[36m]\x1b[0m (A=-5,B=5)', 
u'\x1b[0m[\x1b[1m\x1b[0m\xbb\x1b[0m\x1b[36m]\x1b[0m (A=5,Y=5)', 
u'\x1b[0m[\x1b[1m\x1b[10m\xbb\x1b[0m\x1b[36m]\x1b[0m : ']
 
How do I extract the values of A and B and store them in a variable I want 
using regex?
 
Thank you and appreciate it :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread Loren Wilton

Honestly, the best implementation strategy I can think of is to first
implement a Python interpreter for the actual mainframe environment.
Then invent an RPC layer that can semi-transparently bridge the two for
when you want to call a module that only exists in the Windows
environment (or call _from_ such a module back to an object/module that
only exists in the mainframe environment), whether it's because it
requires a Windows library or because you want the Windows python
interpreter to do the heavy lifting because it's faster.

Do you have C in the mainframe environment?


Essentially the answer is "no". There is a thing that calls itself a C 
compiler, but it can only compile truely trivial programs, and then only 
after a great deal of manual hacking on the source code to change the syntax 
to what this compiler likes. There is no equivalent of "make".


I'd be better off starting with a Python interpreter in JaveScript or the 
like, if I wanted to do a transliteration that would actually work. I'm 
trying to avoid this, it would be months of work.


   Loren 


--
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread mr . puneet . goyal
Let me rephrase my question in other way. 

class myClass:
def __init__(self, var):
self.var = var

myObj = myClass(abc)


# I am calling instance with function name and arguments
myObj func1 arg1 arg2 


Can i associate any function like __init__ with instance ? Means if I just use 
instance anywhere as above, it calls that function in the class and take 
everything as argument which I mentioned after instance? Something like below 

class myClass:
  def __call__(self, args):
# Then I parse the args here and call function internally 
self.func1(arg1, arg2)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread Random832
On Thu, Oct 6, 2016, at 19:27, Loren Wilton wrote:
> So I don't want to WRITE a Python interpreter for the actual mainframe
> environment. I want to use an interpreter for an existing environment
> (Windows) where there are already a lot of existing libraries. But
> since a lot of the data to be analyzed is on the mainframe
> environment, and the results would be wanted there too, I need to
> extend the Python data access to the mainframe environment.

Honestly, the best implementation strategy I can think of is to first
implement a Python interpreter for the actual mainframe environment.
Then invent an RPC layer that can semi-transparently bridge the two for
when you want to call a module that only exists in the Windows
environment (or call _from_ such a module back to an object/module that
only exists in the mainframe environment), whether it's because it
requires a Windows library or because you want the Windows python
interpreter to do the heavy lifting because it's faster.

Do you have C in the mainframe environment?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread mr . puneet . goyal
Well I jump from TCL to Python. And found that it was very convenient to use 
Procs there. So I was looking for that luxury in Python. 

I am not trying to reinvent the wheel. I was just curious to know if there is 
any possibility to create a caller function in  my way (TCL) where I can call 
python function/proc inside myProc. 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread Paul Rubin
"Loren Wilton"  writes:
> strength of Python is that there are many existing 3rd party libraries
> that do lots of useful things. Since a lot of them are distributed as
> binaries, they would not work in this mainframe environment.

Python libraries are usually available as source, either in Python or in C.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread Loren Wilton

Oops, apologies for replying to the wrong thread!

   Loren
--
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread BartC

On 06/10/2016 18:06, mr.puneet.go...@gmail.com wrote:

Hi

I just started learning python. Is there any way to call functions in different 
way ?

Rather calling obj.function(arg1, arg2) I would like to call like below

"obj function arg1 arg2"


As has been pointed out, it's difficult to tell whether a space should 
mean a "." or "(". Or, as is also possible, "=" or "+" or any other kind 
of operator.


But even sticking only with "." and "(", then something like:

  a b c d e f g

could be interpreted in a myriad different ways. Python requires that 
this is determined at 'compile' time, but information about what each 
name is (class, instance, function, attribute etc), which might help 
resolve the ambiguity, isn't available until run-time.



this function is part of a class.

class myClass:
def function(arg1, arg2):
 # do something

Is it possible to do in python ? May be not directly but using some other 
methods.


It would be hard without extra clues, or extra restrictions on what is 
possible. But even if a translator could figure out what is what, a 
human reader will have trouble.


What's the problem with typing "." and "(" anyway; keyboard problems? 
(If so then keep away from languages such as C and C++ because they have 
a /lot/ more punctuation!) Or used to a language that doesn't require 
(,) around function arguments?


--
Bartc
--
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread Loren Wilton

[Cue the decades-old story about the elaborate set of C macros that I
once saw somebody using so he could write a C program that looked like
some flavor of structured BASIC.]


I once wrote a set pf C defines so that I could compile Pascal with a C 
compiler without having to change the Pascal source code.  Fortunately that 
was about 40 years ago, and I've long since lost the source for those 
macros.


The goal here isn't to make one thing look like another that it isn't.

The goal is to "write a Python environment for a mainframe", ideally without 
having to do all of the writing to do it from scratch.


Lots of people seem to have written Python interpeters in various languages. 
I guess I could sit down and write one in Algol or NEWP and have a native 
Python environment. But what good would it do me? This machine isn't 
something at a university where the first-year hackers write their 5-line 
programs with no IO.  Everything I read says the strength of Python is that 
there are many existing 3rd party libraries that do lots of useful things. 
Since a lot of them are distributed as binaries, they would not work in this 
mainframe environment.


So I don't want to WRITE a Python interpreter for the actual mainframe 
environment. I want to use an interpreter for an existing environment 
(Windows) where there are already a lot of existing libraries. But since a 
lot of the data to be analyzed is on the mainframe environment, and the 
results would be wanted there too, I need to extend the Python data access 
to the mainframe environment.


   Loren 


--
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread Grant Edwards
On 2016-10-06, Steve D'Aprano  wrote:

> The only way to do this will be to write your own pre-processor, which will
> parse your source code, and translate it from your language to valid
> Python. That's a lot of work for very little value -- I recommend you just
> learn the Python syntax rather than trying to force it to be something it
> is not.

[Cue the decades-old story about the elaborate set of C macros that I
once saw somebody using so he could write a C program that looked like
some flavor of structured BASIC.]

-- 
Grant Edwards   grant.b.edwardsYow! Don't SANFORIZE me!!
  at   
  gmail.com

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-06 Thread mbg1708
On Wednesday, 5 October 2016 14:10:21 UTC+1, Beverly Howard  wrote:
> I'm new to Python, but have three decades of experience with FoxPro and VFP 
> plus I started programming in Basic and still comfortable with that.
> 
> I have spent some time with Python and am now fairly familiar with the syntax 
> and functions, but building a user interface has me stopped.
> 
> A primary question would be, "What are options for building a display that 
> would update displayed values without scrolling?"
> 
> My first goal is to build a program that would interface with a Raspberry Pi 
> to control a heating process.
> 
> Thanks in advance,
> Beverly Howard

I've had great results using glade and python3.

Glade provides a graphical tool for designing GUI windows.  Once the GUI is 
designed, glade writes out an XML file which can be read by either C or Python 
programs.

Reading the XML from python3 requires that you import gi.repository.  The 
python code after that is straightforward.  

(See http://python-gtk-3-tutorial.readthedocs.io/en/latest/builder.html)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread Steve D'Aprano
On Fri, 7 Oct 2016 04:06 am, mr.puneet.go...@gmail.com wrote:

> Hi
> 
> I just started learning python. Is there any way to call functions in
> different way ?
> 
> Rather calling obj.function(arg1, arg2) I would like to call like below
> 
> "obj function arg1 arg2"

No. This will be a syntax error.



> this function is part of a class.
> 
> class myClass:
> def function(arg1, arg2):
>  # do something
> 
> Is it possible to do in python ? May be not directly but using some other
> methods.

The only way to do this will be to write your own pre-processor, which will
parse your source code, and translate it from your language to valid
Python. That's a lot of work for very little value -- I recommend you just
learn the Python syntax rather than trying to force it to be something it
is not.


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread Peter Otten
mr.puneet.go...@gmail.com wrote:

> Hi
> 
> I just started learning python. Is there any way to call functions in
> different way ?
> 
> Rather calling obj.function(arg1, arg2) I would like to call like below
> 
> "obj function arg1 arg2"

How would the machine reading the above know that you didn't mean

obj(function, arg1, arg2)

or

obj.function.arg1(arg2)

?
 
> this function is part of a class.
> 
> class myClass:
> def function(arg1, arg2):
>  # do something
> 
> Is it possible to do in python ? May be not directly but using some other
> methods.

No, that would be a different language, and if someone were to implement it 
this would make you a newbie in two languages -- hardly an improvement ;)

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-06 Thread Grant Edwards
On 2016-10-06, Steve D'Aprano  wrote:
> On Thu, 6 Oct 2016 10:03 pm, BartC wrote:
>
>> I'd quite like to know too. However I've just tried a test sequence
>> ("[P1d" to move the cursor to row 1) and it didn't work. If there's
>> reason why something so basic won't work (hence the need for curses etc)
>> then that would be useful to know too. (And how does curses manage it?!)
>
> I believe that curses uses a large database of terminal types and
> associated escape sequences. So when you start it up, it determines
> what terminal type you have (that's black magic itself) and then
> works out what escape sequences you need.

Nothing magic, it just looks at the 'TERM' enviroment varible and
looks up that value in the terminfo database.

-- 
Grant Edwards   grant.b.edwardsYow! I wonder if there's
  at   anything GOOD on tonight?
  gmail.com

-- 
https://mail.python.org/mailman/listinfo/python-list


A newbie doubt on methods/functions calling

2016-10-06 Thread mr . puneet . goyal
Hi 

I just started learning python. Is there any way to call functions in different 
way ?

Rather calling obj.function(arg1, arg2) I would like to call like below 

"obj function arg1 arg2" 

this function is part of a class.

class myClass:
def function(arg1, arg2):
 # do something

Is it possible to do in python ? May be not directly but using some other 
methods. 

Regards, Puneet
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-06 Thread Grant Edwards
On 2016-10-06, BartC  wrote:

> All this advice seems to be getting out of hand, with suggestions of 
> 'curses' and 'blessings' and using GUI. I've tried 'ncurses' elsewhere 
> and it was over the top for what I wanted to do.
>
> The OP wants to runs on Pi which I think runs Linux.

It can run Linux.  Whether the OP's is or not, I don't know.

> So all they are asking is, is there a way of randomly positioning
> the cursor within the terminal window so that the next output is at
> that position.

Yes.

> Something like an escape sequence. Terminal screens have been around
> a long time, you'd think someone would have had such a requirement
> before!

Yes, they did.  They wrote the curses library.

> I'd quite like to know too. However I've just tried a test sequence
> ("[P1d" to move the cursor to row 1) and it didn't work.

That doesn't look like an ANSI terminal escape sequence to me -- but I
have no idea what terminal type you're using, so I can't tell you
whether it's right or not.

The ANSI seqeunce to move the cursor to row 1, column 1, is
'[1;1m'.  Both positions default to 1, so '[m' does the same
thing.

> If there's reason why something so basic won't work (hence the need
> for curses etc) then that would be useful to know too. (And how does
> curses manage it?!)

Curses knows how to deal with various different terminal types and it
also knows about the intracacies of the Unix tty API.

If you want to, you can just assume your terminal uses ANSI escape
sequences:

  https://en.wikipedia.org/wiki/ANSI_escape_code

That will mostly work on most terminals you run into these days.

If you want to go one step further, you can use the terminfo library
to deal with different terminal types, but I have no idea how to use
it without ncurses.  If people care about their programs working with
different terminal types, they use ncurses.

-- 
Grant Edwards   grant.b.edwardsYow! !  Up ahead!  It's a
  at   DONUT HUT!!
  gmail.com

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-06 Thread Steve D'Aprano
On Thu, 6 Oct 2016 10:03 pm, BartC wrote:

> I'd quite like to know too. However I've just tried a test sequence
> ("[P1d" to move the cursor to row 1) and it didn't work. If there's
> reason why something so basic won't work (hence the need for curses etc)
> then that would be useful to know too. (And how does curses manage it?!)

I believe that curses uses a large database of terminal types and associated
escape sequences. So when you start it up, it determines what terminal type
you have (that's black magic itself) and then works out what escape
sequences you need.





-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-06 Thread BartC

On 06/10/2016 13:38, Peter Otten wrote:

BartC wrote:



All this advice seems to be getting out of hand, with suggestions of
'curses' and 'blessings' and using GUI. I've tried 'ncurses' elsewhere
and it was over the top for what I wanted to do.

The OP wants to runs on Pi which I think runs Linux.

So all they are asking is, is there a way of randomly positioning the
cursor within the terminal window so that the next output is at that
position. Something like an escape sequence. Terminal screens have been
around a long time, you'd think someone would have had such a
requirement before!

I'd quite like to know too. However I've just tried a test sequence
("[P1d" to move the cursor to row 1) and it didn't work. If there's
reason why something so basic won't work (hence the need for curses etc)
then that would be useful to know too. (And how does curses manage it?!)


Perhaps you picked the wrong escape sequence? I tried ;H
taken from , and it
seems to work (the test system is not a Pi though):


Hey, that worked!

(Maybe I'll finally be able to port my editor and IDE to Linux after all.)

Maybe that can help the OP too. These sequences can trivially be wrapped 
with easy-to-use functions such as setpos(row,column). (Ideally there 
needs to be a way to get terminal size in rows and columns too.)


--
Bartc
--
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-06 Thread jmp

On 10/05/2016 11:33 PM, Chris Angelico wrote:

On Thu, Oct 6, 2016 at 8:19 AM, Beverly Howard  wrote:

Thanks for the responses... appreciated.


print("value value data data data", end="\r") <<


That makes sense, but it also seems to suggest that there is no other way to 
position the cursor prior to printing.

For example, if that line is halfway down the screen, is there any way to 
position the cursor two lines above it?

fwiw, I am open to creating functions if there are positioning options, both to 
meet the need, but, more importantly, to learn.


What I showed you was the very simplest way of doing things. If you
want to move the cursor around, I would recommend the 'curses'
library:

https://docs.python.org/3/library/curses.html
https://docs.python.org/3/howto/curses.html

There are other ways, too; with more info on what you're trying to
accomplish, we could better advise. It might be that a GUI will serve
you well, particularly if you have several pieces of information that
you want to update.

ChrisA


Since someone mentioned curses, I'll add that I've used npyscreen (built 
on top of ncurses), successfully, creating small guis with very few code 
lines.

If you like oldschool gui, it's a must.

http://npyscreen.readthedocs.io/introduction.html

jm

--
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-06 Thread Tim Golden
On 06/10/2016 13:38, Peter Otten wrote:
> BartC wrote:
>> All this advice seems to be getting out of hand, with suggestions of
>> 'curses' and 'blessings' and using GUI. I've tried 'ncurses' elsewhere
>> and it was over the top for what I wanted to do.
>>
>> The OP wants to runs on Pi which I think runs Linux.
>>
>> So all they are asking is, is there a way of randomly positioning the
>> cursor within the terminal window so that the next output is at that
>> position. Something like an escape sequence. Terminal screens have been
>> around a long time, you'd think someone would have had such a
>> requirement before!
>>
>> I'd quite like to know too. However I've just tried a test sequence
>> ("[P1d" to move the cursor to row 1) and it didn't work. If there's
>> reason why something so basic won't work (hence the need for curses etc)
>> then that would be useful to know too. (And how does curses manage it?!)
> 
> Perhaps you picked the wrong escape sequence? I tried ;H 
> taken from , and it 
> seems to work (the test system is not a Pi though):
> 

For lightweight stuff like this, colorama is useful (basically wraps the
ANSI sequences):


https://pypi.python.org/pypi/colorama

TJG

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-06 Thread Peter Otten
BartC wrote:

> On 05/10/2016 23:12, Akira Li wrote:
>> Beverly Howard  writes:
>>
>>> ...snip...
>>> A primary question would be, "What are options for building a display
>>> that would update displayed values without scrolling?"
>>
>> To rewrite only the last character, you could use '\b':
>>
>>   import os
>>   import itertools
>>   import time
>>   for c in map(str.encode, itertools.cycle('\-/|')):
>>   os.write(1, b'\b'+c)
>>   time.sleep(.3)
>>
>> To rewrite only the last line, you could use '\r':
>>
>>   for i in range(1, 101):
>>   time.sleep(.1)
>>   print('\r{:4.0%}'.format(i/100), flush=True, end='')
>>
>> To control the full screen in the terminal e.g., to change the position,
>> you could use *blessings* module [1]:
>>
>>   from blessings import Terminal  # $ pip install blessings
>>
>>   line = 'Line in the middle of the terminal.'
>>   term = Terminal()
>>   with term.hidden_cursor(), term.fullscreen():
>>   x = (term.width - len(line)) // 2
>>   y = (term.height - 1) // 2
>>   with term.location(x, y):
>>   print(term.bold_white_on_black(line))
>>
>>   with term.location(0, term.height - 1):
>>   input('press  to exit..')
>>
>> For interactive command-line applications from a simple prompt to full
>> screen terminal applications, you could use *prompt_toolkit* module [2].
>>
>>> My first goal is to build a program that would interface with a
>>> Raspberry Pi to control a heating process.
>>>
>>
>> For flexibility, you could split your program into a server and a client
>> that controls it (text, GUI, web).
> 
> All this advice seems to be getting out of hand, with suggestions of
> 'curses' and 'blessings' and using GUI. I've tried 'ncurses' elsewhere
> and it was over the top for what I wanted to do.
> 
> The OP wants to runs on Pi which I think runs Linux.
> 
> So all they are asking is, is there a way of randomly positioning the
> cursor within the terminal window so that the next output is at that
> position. Something like an escape sequence. Terminal screens have been
> around a long time, you'd think someone would have had such a
> requirement before!
> 
> I'd quite like to know too. However I've just tried a test sequence
> ("[P1d" to move the cursor to row 1) and it didn't work. If there's
> reason why something so basic won't work (hence the need for curses etc)
> then that would be useful to know too. (And how does curses manage it?!)

Perhaps you picked the wrong escape sequence? I tried ;H 
taken from , and it 
seems to work (the test system is not a Pi though):

$ python3
Python 3.4.3 (default, Sep 14 2016, 12:36:27) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> for i in range(20, 10, -1):
... print("\033[{0};5HHello from line {0}".format(i), end="")
... 



Hello from line 11>>> 
Hello from line 12
Hello from line 13
Hello from line 14
Hello from line 15
Hello from line 16
Hello from line 17
Hello from line 18
Hello from line 19
Hello from line 20


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-06 Thread BartC

On 05/10/2016 23:12, Akira Li wrote:

Beverly Howard  writes:


...snip...
A primary question would be, "What are options for building a display
that would update displayed values without scrolling?"


To rewrite only the last character, you could use '\b':

  import os
  import itertools
  import time
  for c in map(str.encode, itertools.cycle('\-/|')):
  os.write(1, b'\b'+c)
  time.sleep(.3)

To rewrite only the last line, you could use '\r':

  for i in range(1, 101):
  time.sleep(.1)
  print('\r{:4.0%}'.format(i/100), flush=True, end='')

To control the full screen in the terminal e.g., to change the position,
you could use *blessings* module [1]:

  from blessings import Terminal  # $ pip install blessings

  line = 'Line in the middle of the terminal.'
  term = Terminal()
  with term.hidden_cursor(), term.fullscreen():
  x = (term.width - len(line)) // 2
  y = (term.height - 1) // 2
  with term.location(x, y):
  print(term.bold_white_on_black(line))

  with term.location(0, term.height - 1):
  input('press  to exit..')

For interactive command-line applications from a simple prompt to full
screen terminal applications, you could use *prompt_toolkit* module [2].


My first goal is to build a program that would interface with a
Raspberry Pi to control a heating process.



For flexibility, you could split your program into a server and a client
that controls it (text, GUI, web).


All this advice seems to be getting out of hand, with suggestions of 
'curses' and 'blessings' and using GUI. I've tried 'ncurses' elsewhere 
and it was over the top for what I wanted to do.


The OP wants to runs on Pi which I think runs Linux.

So all they are asking is, is there a way of randomly positioning the 
cursor within the terminal window so that the next output is at that 
position. Something like an escape sequence. Terminal screens have been 
around a long time, you'd think someone would have had such a 
requirement before!


I'd quite like to know too. However I've just tried a test sequence 
("[P1d" to move the cursor to row 1) and it didn't work. If there's 
reason why something so basic won't work (hence the need for curses etc) 
then that would be useful to know too. (And how does curses manage it?!)


--
Bartc
--
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-06 Thread alister
On Wed, 05 Oct 2016 14:33:43 -0700, Beverly Howard wrote:

>>> if it is a pi controlling the system I would tend towards controlling
>>> it
> from a web page via the network. to keep it updating would require AJAX
> style programming of the web page. <<
> 
> Thanks.  I am interested in eventually doing that, but it seems that
> learning how to do it on a local console first would be to my
> advantage... especially during initial testing stages.
> 
> fwiw, this project is to transfer (actually re-create) a basic program
> that I wrote for a Tandy Model 100 portable back in the early 80's to
> control ceramic kilns which get to over 2,000 degrees F.
> 
> Worked perfectly until a few years ago when there were no longer any
> Tandy Model 100s available at any cost ;-)  (In case anyone is
> interested in fossilized projects, see
> http://bevhoward.com/kiln/KilnCtrl.htm)
> 
> Thanks again for the response and pointers,
> Beverly Howard

you may also want to look at the pi newsgroup as well comp.sys.raspberry-
pi for any non python queries (& I am sure they would be interested in 
the python ones as well)



-- 
Two brothers, Mort and Bill, like to sail.  While Bill has a great
deal of experience, he certainly isn't the rigger Mort is.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Beverly Howard
Thanks guys...

I'm getting overwhelmed with good info, so, I am going to disappear
for a while and will comeback with questions when I get far enough to
ask them.

Again, thanks!

Beverly Howard
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Akira Li
Beverly Howard  writes:

>...snip...
> A primary question would be, "What are options for building a display
> that would update displayed values without scrolling?"

To rewrite only the last character, you could use '\b':

  import os
  import itertools
  import time
  for c in map(str.encode, itertools.cycle('\-/|')):
  os.write(1, b'\b'+c)
  time.sleep(.3)

To rewrite only the last line, you could use '\r':

  for i in range(1, 101):
  time.sleep(.1)
  print('\r{:4.0%}'.format(i/100), flush=True, end='')

To control the full screen in the terminal e.g., to change the position,
you could use *blessings* module [1]:

  from blessings import Terminal  # $ pip install blessings

  line = 'Line in the middle of the terminal.'
  term = Terminal()
  with term.hidden_cursor(), term.fullscreen():
  x = (term.width - len(line)) // 2
  y = (term.height - 1) // 2
  with term.location(x, y):
  print(term.bold_white_on_black(line))
  
  with term.location(0, term.height - 1):
  input('press  to exit..')
  
For interactive command-line applications from a simple prompt to full
screen terminal applications, you could use *prompt_toolkit* module [2].

> My first goal is to build a program that would interface with a
> Raspberry Pi to control a heating process.
>

For flexibility, you could split your program into a server and a client
that controls it (text, GUI, web).

To control the Raspberry Pi from your mobile device, you could try Kivy
[3] or just create something quick in Pythonista 3 on iOS [4].  To create
a GUI on desktop, you could try Tkinter, Gtk, Qt frameworks [5,6].

For the web part on the server, you could try *flask*, *bottle* modules
[7], to return json data to a client using http protocol:

  from bottle import route # $ pip install bottle

  @route('/data')
  def data():
  return dict(data=[1,2,3])

On the (text/GUI) client in Python:

  import requests # $ pip install requests

  data = requests.get('https://your.server.example.com/data').json()

Or in the browser using jQuery [8]:

  $.getJSON('https://your.server.example.com/data', function(data) {
  //use data here
  });

To make the interaction more responsive, you could use WebSocket protocol e.g., 
via
Flask-SocketIO on the server [9].

[1]: https://pypi.python.org/pypi/blessings/
[2]: https://python-prompt-toolkit.readthedocs.io/
[3]: https://kivy.org
[4]: http://omz-software.com/pythonista/
[5]: http://www.tkdocs.com/tutorial/onepage.html
[6]: http://doc.qt.io/qt-4.8/gallery-gtk.html
[7]: http://bottlepy.org/docs/stable/
[8]: http://api.jquery.com/jquery.getjson/
[9]: https://flask-socketio.readthedocs.io

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Brendan Abel
You should look into using PyQt or PySide.  They are python bindings for
the very popular Qt GUI framework.



On Wed, Oct 5, 2016 at 2:33 PM, Beverly Howard  wrote:

> >> if it is a pi controlling the system I would tend towards controlling it
> from a web page via the network. to keep it updating would require AJAX
> style programming of the web page. <<
>
> Thanks.  I am interested in eventually doing that, but it seems that
> learning how to do it on a local console first would be to my advantage...
> especially during initial testing stages.
>
> fwiw, this project is to transfer (actually re-create) a basic program
> that I wrote for a Tandy Model 100 portable back in the early 80's to
> control ceramic kilns which get to over 2,000 degrees F.
>
> Worked perfectly until a few years ago when there were no longer any Tandy
> Model 100s available at any cost ;-)  (In case anyone is interested in
> fossilized projects, see http://bevhoward.com/kiln/KilnCtrl.htm)
>
> Thanks again for the response and pointers,
> Beverly Howard
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Beverly Howard
I _think_ I see what I need... 

window.move(new_y, new_x)
Move cursor to (new_y, new_x)

...even if not, I now know it's there somewhere.

Thanks for the specific links... they are very valuable.

Beverly Howard
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Beverly Howard
>> I would recommend the 'curses' library: <<

Great!  Thanks!

I'll be back... I'm sure.

Beverly Howard

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Beverly Howard
>> if it is a pi controlling the system I would tend towards controlling it
from a web page via the network. to keep it updating would require AJAX
style programming of the web page. <<

Thanks.  I am interested in eventually doing that, but it seems that learning 
how to do it on a local console first would be to my advantage... especially 
during initial testing stages.

fwiw, this project is to transfer (actually re-create) a basic program that I 
wrote for a Tandy Model 100 portable back in the early 80's to control ceramic 
kilns which get to over 2,000 degrees F.

Worked perfectly until a few years ago when there were no longer any Tandy 
Model 100s available at any cost ;-)  (In case anyone is interested in 
fossilized projects, see http://bevhoward.com/kiln/KilnCtrl.htm)

Thanks again for the response and pointers,
Beverly Howard

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: User Interface Suggestions? (newbie)

2016-10-05 Thread Chris Angelico
On Thu, Oct 6, 2016 at 8:19 AM, Beverly Howard  wrote:
> Thanks for the responses... appreciated.
>
>>> print("value value data data data", end="\r") <<
>
> That makes sense, but it also seems to suggest that there is no other way to 
> position the cursor prior to printing.
>
> For example, if that line is halfway down the screen, is there any way to 
> position the cursor two lines above it?
>
> fwiw, I am open to creating functions if there are positioning options, both 
> to meet the need, but, more importantly, to learn.

What I showed you was the very simplest way of doing things. If you
want to move the cursor around, I would recommend the 'curses'
library:

https://docs.python.org/3/library/curses.html
https://docs.python.org/3/howto/curses.html

There are other ways, too; with more info on what you're trying to
accomplish, we could better advise. It might be that a GUI will serve
you well, particularly if you have several pieces of information that
you want to update.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   5   6   7   8   9   10   >