Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QT GUI : Qt Designer integration #6791

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

R-ohit-B-isht
Copy link
Contributor

Description

Integrates the gr-qtgui flowgraph’s Qt GUI widget component Qt Designer to design the UI components.
wiki page : https://wiki.gnuradio.org/index.php?title=QT_Designer_Integration

Related Issue

Which blocks/areas does this affect?

flow_graph.py.mako
top_block.py
param.py
Actions.py
Application.py
Bars.py

Testing Done

yes

Checklist

@R-ohit-B-isht R-ohit-B-isht force-pushed the Qt-designer-integration branch 3 times, most recently from 292240a to c84a7ab Compare August 16, 2023 19:51
@R-ohit-B-isht R-ohit-B-isht changed the title qt integration gr-qtgui Qt Designer integration Aug 16, 2023
@R-ohit-B-isht R-ohit-B-isht changed the title gr-qtgui Qt Designer integration QT GUI: Qt Designer integration Aug 16, 2023
@R-ohit-B-isht R-ohit-B-isht changed the title QT GUI: Qt Designer integration QT GUI : Qt Designer integration Aug 16, 2023
Signed-off-by: Rohit Bisht <74498290+R-ohit-B-isht@users.noreply.github.com>
@cafeclimber
Copy link
Contributor

Hey Rohit, I think improving the way widgets are laid out would be welcomed by many. Ultimately, my question is since we already have PyQtGraph as a dependency, would it make sense to leverage their Dock widgets in addition to something like supporting .ui files? I'm picturing everything wrapped in a DockWidget so the user can drag/drop/resize widgets at runtime. That might make more sense for something like plots, but curious to hear your thoughts

self.top_layout = Qt.QVBoxLayout(self.top_widget)
self.top_grid_layout = Qt.QGridLayout()
self.top_layout.addLayout(self.top_grid_layout)
file_path = os.fspath(Path(__file__).resolve().parent / "${class_name}.ui")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just stick with using Path everywhere. This could be

file_path = (Path(__file__).resolve().parent / "${class_name}.ui").absolute()

Then later just use Path methods like if file_path.exists()

self.{layout}.setRowStretch(r, 1)
for c in range({col}, {col_end}):
self.{layout}.setColumnStretch(c, 1)
if not os.path.exists(file_path):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more modern to use f-strings instead of .format() (I know much of the rest of the codebase uses .format(), but I think we should work to use modern Python techniques where possible!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seconding that; a lot of the Python you find in-tree is from a Python 2.7-heritage (as that was all we had in GNU Radio 3.7), and we instantly bumped the requirement to Python 3.6 when we released GNU Radio 3.8, exactly because we wanted f-strings!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I've been trying to work through linter errors/warnings from rough and have found a lot of 2.7-migrated-to-3.1+ style code :P

@@ -28,6 +28,10 @@
from packaging.version import Version as StrictVersion
from PyQt5 import Qt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen this in some other places, but think it's caused some issues at least for me. I believe it's more idiomatic to import e.g. widgets from QtWidgets. I was always under the impression the Qt namespace was more for constants and enums like Qt.AlignLeft etc. When I run the test_examples test, I get loads of AttributeErrors about QPushButton not being a part of PyQt5.Qt

@willcode willcode marked this pull request as draft November 26, 2023 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants