This question already has answers here:
How to connect Python and QML with PySide2?
(1 answer)
How Can I Update a Qml Object's Property from my Python file?
(3 answers)
Closed 1 year ago.
I am looking for the best way to communicate from QML to Python and then back to python again.
I am struggling to find the 'correct' way to do this as many resources briefly explain the topic but in different ways and seem to require large amounts of boiler plate code.
For context I am currently using PySide2.
This is the kind of workflow that I am looking to use this in:
QML on button click send input to python --> receive in python --> do some processing on this input --> pass back to QML.
Please provide the best way to do this and with as much explanation as possible, thanks!
Related
This question already has answers here:
How do I run a Python script from C#?
(8 answers)
Run a python script from unity, to use its output (text file) in my game later
(4 answers)
Closed 1 year ago.
I want to make a Unity game that gives data to a subprogram written in Python and this subprogram gives back an answer, that is then processed in the C# game.
I don't really know how to approach this.
Can I run python code from C# somehow or do I let two separate programs running, that exchange data somehow?
Both programs also need access to the same database.
You can make a python server using flask or fastAPI and then access it from C#. I am not sure how to get that done with C#(I dont know C# :( ), but there must be some libraries to call servers. Also, you could save the database on the cloud such as mongoDB.
This question already has answers here:
QtDesigner changes will be lost after redesign User Interface
(2 answers)
Closed 2 years ago.
I recently learn about Pyqt5 and have some confusion about it. I have finished designing my GUI using Designer and I convert it using the pyuic5 command to start writing function for it, lets say it generate a mainwindow.py. So my question is, is it a best practice to directly write a code on mainwindow.py or should I create a new python file that import it? I want to avoid problem of fixing this in the future. Thank you
It is generally better to import it and extend it, since you can iterate design process and generate new file when design changes.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Monitoring files/directories with python
I am making an API server that allows hot-deploying of code. And yes, there are dozens of questions about re-importing modules. I just want to monitor a directory, and when a change is detected, perform an action.
path_to_monitor="c:\\app\\package"
def action():
do_something()
dm=dir_monitor(path_to_monitor,action)
dm.start()
I need a solution that is mature and cross-platform.
You can use a Python thread which uses os.listdir() to list files. If you want to monitor other file properties than the file name, os.stat might help you.
This question already has answers here:
What's the best way to generate a UML diagram from Python source code? [closed]
(9 answers)
Closed 8 years ago.
I have a Python program and I would like to generate an UML diagram from from.
Which programs can do that?
edit: I would like to have an option of editing the generated diagram
I'm not sure what kind of quality you want your diagrams to be, but there is a tool called PyNSource that is still maintained (last update August) and does what you are after. You can find it here. I should clarify that this program is for Windows.
Here you can find a list of UML-Python tools. If you need to edit the diagram, then probably you should start by taking a look at PyUML
And there's Stani's Python Editor (SPE) which draws simple UML diagrams on-the-fly.
My tool Pynsource will reverse engineer Python 3 / Python 2 source code into UML class diagrams. You can drag to re-arrange the classes on the screen or let the auto-layout do it.
You can edit/add/delete classes and associations - yellow comment notes are supported. It can even generate ASCII UML to paste into your code.
There's an open source community edition, as well as a pro version if you want zoom functionality.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Python: single instance of program
What is the best way to insure that only 1 copy of a python script is running? I am having trouble with python zombies. I tired creating a write lock using open("lock","w"), but python doesn't notify me if the file already has a write lock, it just seems to wait.
Try:
import os
os.open("lock", os.O_CREAT|os.O_EXCL)
The documentation for os.open and its flags.
Your question is similar to this one: What is the best way to open a file for exclusive access in Python?. The answers given there should help you with your issue.
(Use the flag combination portalocker.LOCK_EX!|portalocker.LOCK_NB to return quickly. If the file is locked by another process, your script should get an exception.)