Create python console in my GUI application [closed] - python

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a GUI application and want it to be able to create a console with python interpreter in it. I want to redirect STDOUT and STDERR to it and export the namespace of my application there.
What's the simplest way to do that?

You might want to look at the source code for IDLE which contains this functionality and is released as part of CPython. Specifically, PyShell.py looks to be relevant. You could probably just import idlelib.PyShell as a module and use its functionality.

Related

How can I create a program that runs commands as soon as I copy something to clipboard [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 months ago.
Improve this question
I want to write a program that will run a few lines on any piece of data or string upon copying to clipboard, is there a way to do this? I cant find much information about it.
I found https://pyperclip.readthedocs.io/en/latest/index.html
It has the pyperclip.waitForPaste() function, which should do exactly what you want. I had issues trying it with Linux Fedora, but it should be no problem on most Systems.

Since information of the hardware sees installed in python? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Can I know this information across python?, for example, the name of the card graphic, processor, audio, mother board ....
There isn't anything in Python itself. You can detect what OS you're on via the platform module. Otherwise
See also:
How can I return system information in Python?
If you're on Windows, you can probably use PyWin32 to get some of this information. See the following recipe to get an idea of some of the stuff you can get:
http://code.activestate.com/recipes/511491-getting-system-information-under-windows/
I also wrote a little about this regarding getting Windows system information here:
http://www.blog.pythonlibrary.org/2010/01/27/getting-windows-system-information-with-python/
You might be able to use HAL:
http://www.daniweb.com/software-development/python/threads/300786/how-to-get-graphics-card-details-in-python
I have also found the psutil project very helpful. I also came across PyCPU, although I'm unsure what its status is.
For Linux (and probably Mac), you'll probably have to use system commands called via Python's subprocess module and parse the result(s).

Python Regex: get everything except for string [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have the following sentence:
Graft Concepts has partnered with\u00a0several sites\u00a0to offer customization options for backplates, so customers will be able to design their own with\u00a0
I'd like to get rid of all instances of "\u00a0", whether or not they are connected to other words, e.g. "with\u00a0several"
How would I do this using regex with python? I've tried experimenting with re.compile() and re.findall(), but I couldn't get this working?
Thanks.
You can just use .replace:
s = s.replace('\\u00a0', ' ')
This works under Python 2:
import re
st='''Graft Concepts has partnered with\u00a0several sites\u00a0to offer customization options for backplates, so customers will be able to design their own with\u00a0'''
st=re.sub(ur'\\u00a0','',st,re.UNICODE)
And this under Python 3:
st=re.sub(u'\\u00a0','',st,re.UNICODE)

fuser alternative? i want to know all processes accessing a file [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I asked a question about the fuser command yesterday here. It seems gedit (and other text editors, and perhaps even other processes) act a bit differently in the way they interact with files, so they don't show up on when calling fuser even though they have opened a file.
I would like to monitor a file for ANY process which accesses it, whether it keeps it open or not. Is there an alternative command / software which I might be able to use for this purpose please? This can include from languages such as python as well.
Thanks for reading.
If a file is not open then it's not being accessed. If what you want is to keep track of who opens what, then you need to setup an auditing tool like auditd.

How to record from IP camera in Python [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have an IP camera transmitting an H.264 stream. I would like to store this stream using Python (I need this for a service which I'm writing in Django) into a file on my server. I've tried VLC but I was not able to record the file with sound.
Any suggestions how this could be done ?

Categories