Integrating CMD Module with PYQT - python

I am developing a texteditor using PYQT, the text editor is used for processing a DSL, one that I am making up. Now I would really like to have the ability to click on on an ICON, say a console icon in my gui toolbar that will launch a console, from the console I could run my custom commands that allow me to do things like manipulate my SQLITE database directly.
I am somewhat familiar with the CMD Module which allows me to create simple commands that do the things that I want, but how can I integrate my gui texteditor and a CMD module console?
A similar idea can be found in
Integration of Python console into a GUI C++ application
only difference is that I don't want a full python interpreter,and i'm not using C++
Any suggestions

After much searching I found
http://obswww.unige.ch/~revaz/git/old.glups-4.0/glups/pycutext.py
This module implements a QT4 python interpreter widget.
It is inspired bu PyCute : http://gerard.vermeulen.free.fr
I cannot take credit for the solution, but it effectively redirects all python stdin,stdout and even stderr to the pyQt Widget. Its exactly what I was looking for.

Related

How to embed shell in my Python curses application?

I am creating a TUI application using Python and curses. And I want to embed/integrate the shell, like you have in VS Code, etc. How can I do this?
I don't just want to capture input and execute it using bash, I want the real shell. E.g. in VS Code you see the real shell prompt (as defined in bashrc) and also you can run a whole application (e.g. vim) from inside the VS code terminal.
I have looked at pty module: not sure if it can help here. I want to basically have a library function like invoke_shell() to which I just pass a reference to a curses window (inside of which I want to show the shell). I do not need to interact with the shell in any other way, except to: (1) close it, (2) capture a keystroke for my application to move focus away from the shell window to another curses window in my application (and move focus back to it when I need it). Is there any such library?
Any help is greatly appreciated! Thanks in advance.

python application which has gui as well as console for user interaction

I am looking to create a python application in linux which should have a GUI interface as well as console for inputs . Console name what user want.
shell> python my_application.py OR executable
my_app> (opens gui too)
Can someone please help me get this or any link where I can learn this.
Thanks
Look into learning tkinter (easier) for making GUIs or PyQt5 (better). Then, I'd use argparse to specify if you want to launch the GUI.

How can I make a Python shell-like GUI using Tkinter?

I need to make a program that uses as its interface a shell window, like the one the python IDLE uses, this window has to be made. What widgets can I use to perform this. I've heard that the Python IDLE was made using tkinter, if that`s the case, then what widget did they used.
Pd. I've tried using the 'text' widget, but it doesn't freezes commands that have already been processed. Is there a way to freeze the commands that have already been processed,but keep text entry activated.
You should take a look at PyQt. Specifically the QTextEdit. They also have the QScintilla library that does code highlighting and formatting.
If you're not opposed to using other peoples' code, Blur Studio has open sourced much of their code, and they have a widget that is pretty similar. Once you install the blurdev library, it's at blurdev.gui.windows.loggerwindow

Python editor that can connect to remote environment?

I set up an interactive python environment in an application. I can input commands and they will execute inside it, having access to the variables that live there.
The problem is that I coded a half-assed editor that allows only that. It doesn't have command history, code completion etc, because I didn't code a full IDE. However, I would like to be able to write code in that environment with a fancy editor.
The way I think it can work out is that an editor will have an interface/protocol for remote python sessions, and I will just have to implement a server in my application (instead of the simple editor) and be able to connect and run code.
I can implement any interface or protocol that I have to, but I can't find an IDE that has such a protocol defined (or an easy way to plug an extension that will serve as the client side).
Essentially, I want a python editor that has an option to call a function x whenever a command (can be multiline) finished typing, and another function y when an autocomplete request occurs.
I checked out some editors but couldn't find such a feature. Does anyone know of such a thing? It actually doesn't have to be a python editor, just support the hooks that i need.
Thanks!
Did you try integrating PyCrust into your application? See this SO question
Embedding a Python shell inside a Python program
rpyc sounds like something which could be useful to you. rpyc added support for IronPython in their latest release. PyScripter supports rpyc. Maybe this is the combo you are looking for?

Creating an Python/py2app application that simply opens a terminal on launch?

I've written a nice Python application that is basically an HTTP proxy for SMS modems, and I'd like to make it a double-clickable application on Macs. So far I've been including a .commmand file which is double-clickable, which basically consists of
cd `dirname $0`
(sleep 8;open http://127.0.0.1:8080/)&
mac/slingshotsms.app/Contents/MacOS/slingshotsms
How can I make the main .app executable call a different place / or what's the easiest way to make an application that is basically a wrapper for a terminal utility and only displays its output? Currently double-clicking on the application will use the open utility on Macs - I want to emulate the behavior of double-clicking on Contents/MacOS/slingshotsms when double-clicking on the application icon. any tips?
If you're looking for 'easy', try just giving your python script a .command suffix, and make sure it's executable. For example:
#!/usr/bin/env python
# file: hello.command
print 'hello world'
If you're looking for 'polished', then you probably want to learn about Launch Services, PyObjC, Interface Builder, NIB files, app wrappers, and all sorts of Mac OS X-specific technology details. But, note that PyObjC is nearly impossible to use for anything non-trivial without already knowing, more or less, how to do the same task using the Objective-C Cocoa APIs. PyObjC is a fairly thin wrapper around those APIs, and you have to know the Cocoa idioms / design patterns to understand how the moving parts fit together.
If you don't actually need a terminal, but instead just want an app wrapper around a script, have a look at Platypus
Write an AppleScript application that launches Terminal and runs your Python script (which will be inside the application's bundle).

Categories

Resources