I am working on a module for 3D slicer. A chunk of the template code is pasted below. It is using qt for GUI. I need to add my own GUI here, But I am not able to find how to add toolbar here. I am not able to find any documentation regarding this. Whenever I google I get PyQt4, is that different from this ? So, my question is please explain the diference between qt and PyQt4 and how can I add toolbar here ?
def __init__(self, widgetClass=None):
self.parent = qt.QFrame()
self.parent.setLayout( qt.QVBoxLayout() )
# TODO: should have way to pop up python interactor
self.buttons = qt.QFrame()
self.buttons.setLayout( qt.QHBoxLayout() )
self.parent.layout().addWidget(self.buttons)
self.addDataButton = qt.QPushButton("Add Data")
self.buttons.layout().addWidget(self.addDataButton)
self.addDataButton.connect("clicked()",slicer.app.ioManager().openAddDataDialog)
self.loadSceneButton = qt.QPushButton("Load Scene")
self.buttons.layout().addWidget(self.loadSceneButton)
self.loadSceneButton.connect("clicked()",slicer.app.ioManager().openLoadSceneDialog)
import statement
import vtk, qt, ctk, slicer
I think the form/GUI is created by tool. You can have a look at this
You can add your PyQt4 code in this, that should work fine.
If the import statement is qt, 2 solution : it use an alias (it would be weird) or it use a pyqt wrapper which allow to use PySide2, PyQt5, PySide and PyQt4 the same base code.
Maybe this one : https://github.com/mottosso/Qt.py
maybe another ... If you have a requirement.txt you should be able to know
please explain the diference between qt and PyQt4
Qt is cross-platform application framework, using C++ extensions.
In order to use it in python you need a wrapper and this is what PyQt, PySide and the rest are.
Check your application documentation and probably you will find if it uses PyQt4,5, PySide or something else.
Related
I am currently working on a GUI application using PyQt5 and QtDesigner. As I have to make it multi-platform (at least Ubuntu and W10) I will use the "Fusion" style to make it look similar on both platforms.
I was wondering if one could simply set the QApplication style directly in QtDesigner ? I know that a simple <<.setStyle("Fusion")>> will do the trick in the code, but does it exist within QtDesigner so the lines can be automatically generated ?
I'm trying to learn QtDesigner and how much it can be pushed before going into the code.
No, it is not possible to set the style through Qt Designer.
What Qt Designer does allow is to display the GUI with different styles if you select Form-> Preview -> ...
How I can write an OpenGl application using Enthought Framework? I created a TasksApplication and I am stuck on this tutorial, I don't know what I can use instead PythonEditor there. I need to create something where I will be able to render.
UPDATE:
I changed the code to
def create(self, parent):
widget = GLWidget(parent)
self.control = widget
Where GlWidget is implemented like in this example.
And I have a runtime crash. But I am able to run the GL script from the example above.
UPDATE2:
Log file
UPDATE4:
Code was updated according to #Robert Kern suggestions. Now it works.
Min Example
MinExample 7z
The control trait of a TaskPane is just the Qt widget object that you are using. In the example that you link, we happen to be getting it from another PyFace widget that wraps a Qt widget in a similar fashion, so we just grab the control attribute from it. You should just directly use a QGLWidget as the control of your pane. Please consult the Qt documentation for how to use it. You can use PyOpenGL in the paintGL(), etc. methods to do the actual rendering.
I am trying to write a custom widget for the Qt Designer using only Python. I was following a couple of tutorials I found online but none of them were working or anything close to what I would call to be a minimum working example.
So my questions are:
What steps are involved to make a a custom widget appear in the Widget Box of Qt Designer?
If you can spare the time: Please provide a minimum working example (like a widget with a label in it saying "A truly minimal working Qt custom widget example").
Or is it maybe not possible at all to include a custom widget using only python?
There are very few examples available on how to make a custom widget in pyqt. I wrote this article with a working example: Making a Custom Widget in PyQt
Here is the answer to your question #3: How do I use promote to in Qt Designer in pyqt4?
I am using PySide and it works the same way. This method works directly with your Python custom widget code. You do not need to write any separate plugin code.
After you have promoted your custom widget, you can right click on it and add your signals with "Change signals/slots..."
I would recommend putting all you widgets in a YourCostumWidgetsPack.UI file, and then when you load this file in Qt Designer, in addition to the UI you are working. It will load all your custom widget information.
I found this article to be your answer: https://doc.qt.io/archives/qq/qq26-pyqtdesigner.html
But, I haven't been able to install it in Qt Designer though :D
Are there any good PyQt4 custom widgets like at Qt-Apps.org?
I would like to start making PyQt custom widgets but online resources that I find don't seem to be clear
For example, Trolltech's and Zetcode's don't seem to be related in any way at all.
Thanks for any input :)
There should be PyQt examples of all C++ Qt examples in your PyQt4 distribution. I have them here: /usr/share/doc/python-qt4-doc/examples. Theye are quite good for the start. When you understand them, it should also be fairly easy for you to port some C++ examples to PyQt code or turn C++ custom widgets to C++.
online resources about PyQt aren't really that rampant, so any information/projects would be welcomed. Don't hesitate to post links to your upcoming widgets or anything else.
I would be really glad to work on that with you as i'm learning more about pyqt as well.
Are you looking for tutorials on making custom PyQt widgets, or looking for a library of them?
I've been developing a library of reusable custom widgets if that's what you're looking for - at somepoint will be getting to the tutorials, but they aren't there yet.
Check out projexsoftware.com, specifically the ProjexUI framework:
http://dev.projexsoftware.com/projects/projexui
http://docs.projexsoftware.com/sdk-reference/projexui-sdk
In looking at it, I'll need to get some images up there...but there's a Calendar widget, Gantt Chart, View plugin system, Node view, Chart widgets, along with a number of extensions to the base Qt widget classes.
Also the easiest way to see the majority of the widgets is in the Qt Designer - so if you have it setup to work with PyQt plugins, wherever you install the projexui library you can add the /path/to/projexui/designer/build to your PYQTDESIGNERPATH and it'll load designer with our plugins.
print "hellp world" :)
i want to ask you if exist a function or class hwo can show the html code like the browser's jobe
thx
There is QtWebKit Module within Qt. It incorporates webkit rendering engine. Whereas you can get access to Qt classes using python binding, you can use Qt official manual as help. Qt designer is also included into pyqt - you can try using it to design your application's GUI (I'm almost sure you'll be able to find web browser component or similar there).
As for using html tags to decorate labels and other components showing text, you can refer to this question.