Re: Simple webserver

2023-10-24 Thread pozz via Python-list
Il 19/10/2023 00:09, Janis Papanagnou ha scritto: I am pondering about writing a client/server software with websockets as communication protocol. The clients will run in browser as Javascript programs and the server may be in any (any sensible) programming language running standalone to be

Multithreading? How?

2023-04-28 Thread pozz
I need to develop a Python application that is a sort of gateway between to networks: a "serial bus" network (think of a serial port or a USB connection) and a MQTT connection (in my case, it's AWS IoT service). On the bus, a proprietary protocol is implemented. From the bus, the app knows

Re: Python threading and sharing variables

2017-07-05 Thread pozz
Il 05/07/2017 09:56, pozz ha scritto: > [...] It seems it works, but I'm not sure it is the correct way to share the variable self.cnt. It is only written in the long thread and only read in the main thread. Could a single Python instruction be interrupted (in this case, self.cnt = i)? Sho

Python threading and sharing variables

2017-07-05 Thread pozz
I'd like to launch *and control* a long thread. I want to print the progress of the long thread in the main thread. It's a GUI script, here it's a console script only to simplify. import threading import time class MyClass: def start(self): self.max = 5 self.pause = 1

Re: [gettext] How to change language at run-time

2017-06-15 Thread pozz
Il 15/06/2017 15:22, Peter Otten ha scritto: pozz wrote: I know I can load multiple gettext.translation: it = gettext.translation('test', localedir="locale", languages=["it"]) es = gettext.translation('test', localedir="locale", languages=["es&quo

[gettext] How to change language at run-time

2017-06-15 Thread pozz
I know I can load multiple gettext.translation: it = gettext.translation('test', localedir="locale", languages=["it"]) es = gettext.translation('test', localedir="locale", languages=["es"]) and install one translation at run-time when I want at a later time (when the user selects a new

Re: How to use two threads (GUI and backend)

2016-10-27 Thread pozz
Il 27/10/2016 13:33, jmp ha scritto: On 10/27/2016 12:22 PM, pozz wrote: Anyway I don't like this approach, because the main (and single) thread should check in_waiting every X milliseconds. If X is too high, I could wait for the answer even if it is already ready in the input buffer. If X

Re: How to use two threads (GUI and backend)

2016-10-27 Thread pozz
Il 26/10/2016 16:18, jmp ha scritto: On 10/26/2016 02:45 PM, pozz wrote: Il 26/10/2016 13:16, jmp ha scritto: [...] I suggest you write a GUI that make synchronouscalls to a remote application, if possible. If the remote app is in python, you have access to remote protocols already written

Re: How to use two threads (GUI and backend)

2016-10-26 Thread pozz
Il 26/10/2016 13:16, jmp ha scritto: [...] I suggest you write a GUI that make synchronouscalls to a remote application, if possible. If the remote app is in python, you have access to remote protocols already written for you, Pyro is one of them, you can skip the low level communication

Re: How to use two threads (GUI and backend)

2016-10-26 Thread pozz
Il 26/10/2016 13:27, Antoon Pardon ha scritto: Op 26-10-16 om 12:22 schreef pozz: Il 26/10/2016 09:13, pozz ha scritto: [...] When the user press Start button (the pressed handler is in the GUI class): self.comm_active = True threading.Thread(target=self.comm_thread).start() The backend

Re: How to use two threads (GUI and backend)

2016-10-26 Thread pozz
Il 26/10/2016 09:13, pozz ha scritto: > [...] When the user press Start button (the pressed handler is in the GUI class): self.comm_active = True threading.Thread(target=self.comm_thread).start() The backend thread is: def comm_thread(self): while self.comm_act

Re: How to use two threads (GUI and backend)

2016-10-26 Thread pozz
Il 26/10/2016 09:13, pozz ha scritto: > [...] What is the best approach to use in my scenario (GUI and backend communication)? I just found this[1] page, where the thread approach is explained with the following code: --- import threading import time from gi.repository import G

How to use two threads (GUI and backend)

2016-10-26 Thread pozz
I'm designing a GUI application in Python (with pyGObject, so GTK). The application communicates with a remote device (connected through RS232, but it could be on Internet) to retrieve its status and set/get its configuration. When the user press "Start" button, the application starts

Converting the keys of a dictionary from numeric to string

2016-10-19 Thread pozz
I have a dictionary where the keys are numbers: mydict = { 1: 1000, 2: 1500, 3: 100 } I would like to convert keys from number to string representation: mydict = { "apples": 1000, "nuts": 1500, "tables": 100 } Of course, somewhere I have the association between key-numbers and key-strings,

Re: [FAQ] "Best" GUI toolkit for python

2016-10-18 Thread pozz
Il 18/10/2016 18:41, Demosthenes Koptsis ha scritto: > My favorite GUIs are PyQt and wxPython. > > I prefer PyQt than PySide because PySide seem to me like an abandoned > project. > > Also i prefer PyQt than wxPython because i can design the forms in > QtDesigner easily. > > wxPython and

Re: [FAQ] "Best" GUI toolkit for python

2016-10-18 Thread pozz
Il 18/10/2016 16:56, Michael Torrie ha scritto: On 10/18/2016 02:33 AM, Mark Summerfield wrote: When I started out I used Qt Designer to produce .ui files (XML) and then used the Qt uic tool to convert this to C++ (although you can convert to Python using pyuic). I then studied the code and

Re: [FAQ] "Best" GUI toolkit for python

2016-10-18 Thread pozz
Il 18/10/2016 09:42, Mark Summerfield ha scritto: PySide/PyQt On Windows I use Python 3.4 + PySide 1.2.4 (Qt 4.8). I have found this very reliable and use it for both my personal projects and for my commercial products. I don't use a GUI design tool but you could use Qt Designer to visually

Re: [FAQ] "Best" GUI toolkit for python

2016-10-18 Thread pozz
Il 18/10/2016 03:25, Paul Rubin ha scritto: If you're just getting started and you're not trying to make something super slick, I'd suggest Tkinter. It's easy to learn and use, you can bang stuff together with it pretty fast, it's included with various Python distributions so you avoid

Re: [FAQ] "Best" GUI toolkit for python

2016-10-18 Thread pozz
Il 18/10/2016 02:57, Wildman ha scritto: On Tue, 18 Oct 2016 00:58:42 +0200, pozz wrote: I'm sorry, I know it is a FAQ..., but I couldn't find a good answer. I'm learning python and I'd like to start creating GUI applications, mainly for Windows OS. In the past, I wrote many applications

[FAQ] "Best" GUI toolkit for python

2016-10-17 Thread pozz
I'm sorry, I know it is a FAQ..., but I couldn't find a good answer. I'm learning python and I'd like to start creating GUI applications, mainly for Windows OS. In the past, I wrote many applications in Visual Basic 4: it was very fast and you could create simple but effective GUIs in Windows

Without compilation, how to find bugs?

2016-10-13 Thread pozz
I come from the C language, that is a compiled and strongly typed language. I learned many good tricks to write good code in C: choose a coding style, turn on as many warnings as possible, explicitly declare static variables and functions (when needed), explicitly declare const variables (if

pyserial and threads

2015-09-17 Thread pozz
I'm trying to create a simple program in Python that opens N serial ports (through pyserial) and forward every byte received on one of those ports to the other ports. At startup I open the ports and create and start a thread to manage the receiving. When a byte is received, I call the

Re: pyserial and threads

2015-09-17 Thread pozz
Il 17/09/2015 15:04, Dennis Lee Bieber ha scritto: On Thu, 17 Sep 2015 12:00:08 + (UTC), alister declaimed the following: I can see the data being transmitted snowballing & running away in a +ve feedback loop very easily. Especially if a few of

Re: pyserial and threads

2015-09-17 Thread pozz
Il 17/09/2015 14:00, alister ha scritto: I would like to know more about how many serial ports are connected One real serial port and two virtual serial ports, created by com0com (it's a free virtual serial port for Windows). what the equipment they are connected to does and expects.

Re: pyserial and threads

2015-09-17 Thread pozz
Il 17/09/2015 11:42, Chris Angelico ha scritto: On Thu, Sep 17, 2015 at 7:28 PM, pozz <pozzu...@gmail.com> wrote: At startup I open the ports and create and start a thread to manage the receiving. When a byte is received, I call the .write() method for all the other ports. It

Re: [Newbie] How to wait for asyncronous input

2012-08-11 Thread pozz
Il 11/08/2012 01:12, Dennis Lee Bieber ha scritto: What you apparently missed is that serial.read() BLOCKs until data is available (unless the port was opened with a read timeout set). [...] serial.read() may, there for, be using select() behind the scenes. Hmm..., so I could

[Newbie] How to wait for asyncronous input

2012-08-10 Thread pozz
I'm new to Python and I'm trying to code something to learn the language details. I'm in trouble with asyncronous events, like asyncronous inputs (from serial port, from socket and so on). Let's consider a simple monitor of the traffic on a serial port. I'm using pyserial and I looked at