We have a large library and utility tools written in Python 2.7. And we need to create a GUI application that uses these python library and tools. So I'm looking for a solution that can easily interact between the GUI app and our python code base.
Requirements:
cross-platform: Linux, Windows;
these programming languages are preferred: C++, C#, Python.
Performance is not very essential. The key is to quickly develop the
GUI application;
I know that PyQt can be a good choice but what concerned me is - if we are to develop the GUI in Qt C++, interact with Python may not as easy as the other way round, i.e. python code can easily use Qt library because of PyQt but C++ code does not have something similar. When we have controls made in Qt C++, it would not be straightforward to use them in python.
Any suggestions? Thanks.
Related
I wanna know, Is it possible to create GUI in python without using tkinter?
Tk isn't technically making the GUI, it's delegating to a C library; and that's exactly what you can do too. For simplicity however, it's pretty much standard to use TkInter, or some other framework (i recommend PySimpleGUI) that takes care of the Tk interaction for you
easygui is the easiest GUI python that I have used. Designs are prebuilt for you already. Examples of easygui can. be found here https://pypi.org/project/easygui/
You can also use Flask where the frontend will be the web browser.
Tcl/Tk is an external library although it comes as part of the standard python install and it is an external library. you can use other framework to do that .
Fundamentally, Python can’t talk to any GUI system without an external module. Since the most fundamental GUI libraries on any platform are usually C-based, that requires, at minimum, importing a library like ctypes which itself is minimal and allows you to load system GUI libraries (in dlls or delis, depending on your platform).It is possible, in theory at least, to drive a GUI solely from ctypes, but it’s not very practical .
So, I have been wanting to make my own GUI library for Python 3. And I couldn't find anything anywhere on where to start. So I decided to ask the question here.
Goal:
Be able to make Python Libraries without using other libraries.
Edit:
So, If I was to make a Library in C for Python. How would I go about doing that.
Tkinter is a python wrapper around tcl/tk's GUI toolkit , similar to how PySide/PyQt and wxPython are wrappers around the Qt and Wx C++ GUI toolkits.
If you wanted to build your own from scratch you would have to make use of existing operating system APIs and/or use something cross platform like OpenGL. For a good example of the latter you can look into Kivy, which is built on OpenGL
Different operating systems have different API's for doing GUI's. So how you have to do it very much depends on the operating system. I think one of the reasons that Python uses Tkinter is because it was already ported to different operating systems.
GUI API's are typically provided as shared libraries, often written in or compatible with C.
If you want to use those from Python, you will have to write a Python wrapper for them. For example using ctypes. Doing that requires a significant understanding of (1) Python, (2) ctypes and (3) the GUI API in question. If more than one of these technologies is new to you, I would not recommend taking on such a project.
I know in PythonQt I can access MOC'd QObject based classes in Python code and that python code can be executed from C++. Is it possible to do something similar using PyQt or is it intended to be used only to write Qt in Python?
I understand SIP is used to expose C/C++ code to Python but that doesn't seem to be as elegant as using the meta-object system.
I have never used PythonQt, but after a brief skim of the features, it seems that, in terms of conceptual emphasis, it really should have been called QtPython.
PyQt started life as a tool for prototyping Qt C++ applications in python. As a consequence, it was originally a very thin wrapper around the Qt library, which made it almost trivial to port Qt code from python to C++ and vice versa. And it still is quite easy to do this. But since PyQt4, the emphasis has shifted strongly towards making it easier to write Qt applications in Python; and with PyQt5, it has moved even further in that direction.
So PyQt is now intended purely for writing Qt applications in python (and the same goes for PySide). It does not provide any facility for executing python code within C++ (other than indirectly via virtual functions). If you need to expose third-party Qt classes to python, you would need to wrap them using Sip.
As for the meta-object system: PyQt does wrap QMetaObject and so forth, but there is not enough information in your question to know whether that would be of any use to you.
I'm new with python programming and GUI. I search on internet about GUI programming and see that there are a lot of ways to do this. I see that easiest way for GUI in python might be tkinter(which is included in Python, and it's just GUI library not GUI builder)? I also read a lot about GLADE+PyGTK(and XML format), what is there so special(glade is GUI builder)?
Can anyone make some "personal opinion" about this choices?
I have python code, I need to make simple GUI(2 button's-open-close-read-write,and some "print" work) and then make some .exe file (is there best choice py2exe=?). Is there a lot of changes in code to make GUI?
Many thanks
If your GUI is really that simple, you should go with the built-in tkinter.
There's a Hello, Tkinter tutorial that you can follow, it's pretty straightforward. Concerning the creation of executables, py2exe should work without problems in most cases (though I haven't tried with tkinter). Another way to create an executable is to add a special parameter to your "setup.py" file:
setup(...,
entry_points = {"gui_scripts" : ['name-of-executable = name_of_package.launcher:main']})
This would, for example, create an executable that can be run by typing "name-of-executable" into a terminal (even on Windows if Python's "scripts" path is in the PATH ^^). It runs the function "main" in the module called "name_of_package". That way, you don't have to use py2exe but can create a Windows installer, or a Debian package, for instance.
For more complex projects, I can absolutely recommend PyGTK with Glade as interface designer. It requires several Python packages to be installed, plus a GTK+ installation (which is not always that easy on Windows). The API is awesome, well-documented and Glade is very easy to use, once you get used to the layouting concepts of GTK. But my opinion is kind of biased because I've done multiple projects in PyGTK. wxWidgets or PyQT are good alternatives. For example, bazaar explorer is written using QT.
I really like PyQt bindings for Qt library.
What is PyQt?
Qt itself is a very nice framework - rich, powerfull, elegant (for my taste, at least). And PyQt does a very nice job of exposing that functionality to a scripting environment.
Plus, there is a very nice book about PyQt development - Rapid GUI Programming with Python and Qt - working through it helped me a lot.
I've been using WxPython and I've tried Tk, but it seems that, while both are good and I'll likely use them for other projects, neither of those appear to be capable of accomplishing the things that I want for my current project (which is fine, they're good at what they do).
Basically what I'm looking for is something that will allow me to make rich graphical GUIs. My specific goal is a window that will draw bitmap buttons, resize the parent window automatically to fit them, and possibly animate the resize with a slide effect and have the buttons fade in. Also being able to have my own window border style instead of the inbuilt one is important to me.
This particular project will be Windows only, so non-portable libraries are fine in this case, though portable ones would be great too.
If I missed how this can be done in either WxPython or Tk, I'm all ears.
PySide: http://www.pyside.org/
The PySide project provides
LGPL-licensed Python bindings for the
Qt cross-platform application and UI
framework. PySide Qt bindings allow
both free open source and proprietary
software development and ultimately
aim to support all of the platforms as
Qt itself.
The Windows version of PySide is quite new and may be considered as a beta version. PySide is API compatible with PyQt.
How about PyQt?
http://www.riverbankcomputing.co.uk/software/pyqt/intro
Just sharing my opinion: Kivy.
Innovative open-source library. Supports both 2.x and 3.x versions of Python.
Kivy - Open source Python library for rapid development of applications
that make use of innovative user interfaces, such as multi-touch apps.
Kivy is based on OpenGL ES 2 and includes native multi-touch for each platform and Android/iOS. It’s an event-driven framework based around a main loop, and is thus also suitable for game development.
Try Pyglet. Its a library for python that makes using OpenGL very easy. You can draw pretty good 2d interfaces using Quads.
I can't tell you what is best because that is subjective but I can give you another option: PyGTK
PyGTK lets you to easily create programs with a graphical user interface using the Python programming language. The underlying GTK+ library provides all kind of visual elements and utilities for it and, if needed, you can develop full featured applications for the GNOME Desktop.
PyGTK applications are truly multiplatform and they're able to run, unmodified, on Linux, Windows, MacOS X and other platforms.