Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QT Designer
#1
Hi,
First of all I'm new in Python.
I have made with QT Designer a gui for my project an convert it into .py with external tool from PyCharm.
The begining of code is this:

from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(819, 379)
        font = QtGui.QFont()
        font.setPointSize(6)
        MainWindow.setFont(font)
        MainWindow.setStyleSheet("background-color: rgb(106, 127, 0);")
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
How can I view the actually GUI window? because when I run the code in the console I get only this:

C:\Users\kriss\PycharmProjects\Proiect1\venv\Scripts\python.exe C:/Users/kriss/PycharmProjects/Proiect1/getdata.py

Process finished with exit code 0
Reply
#2
I've not ever used designer. Always felt that it adds unneeded code. Didn't like pycharm much but, there are lots of people who do. Anyway here is a quick example to get you started.

from PyQt6.QtWidgets import (QMainWindow, QApplication, QWidget, QLabel)
from PyQt6.QtCore import Qt

class Window(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle('Hello Main Window')
        self.resize(819, 379)
        self.setStyleSheet('background-color:rgb(106, 127, 0);')

        label = QLabel('Some text here')
        label.setStyleSheet('color: lime; font-size: 28px; font-family: times;')
        label.setAlignment(Qt.AlignmentFlag.AlignCenter)

        self.setCentralWidget(label)


app = QApplication([])
window = Window()
window.show()
app.exec()
Gribouillis likes this post
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
(May-26-2022, 07:04 AM)menator01 Wrote: I've not ever used designer. Always felt that it adds unneeded code. Didn't like pycharm much but, there are lots of people who do. Anyway here is a quick example to get you started.

from PyQt6.QtWidgets import (QMainWindow, QApplication, QWidget, QLabel)
from PyQt6.QtCore import Qt

class Window(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle('Hello Main Window')
        self.resize(819, 379)
        self.setStyleSheet('background-color:rgb(106, 127, 0);')

        label = QLabel('Some text here')
        label.setStyleSheet('color: lime; font-size: 28px; font-family: times;')
        label.setAlignment(Qt.AlignmentFlag.AlignCenter)

        self.setCentralWidget(label)


app = QApplication([])
window = Window()
window.show()
app.exec()

Thank you!
Reply
#4
What tool did you use to convert the designer form to Python? I am going to assume you used uic.

It appears that the converter expects you to make a QMainWindow object and pass that as an argument to setupUI. This is an article that discusses how you use the generated file to create a window.

https://doc.qt.io/qt-5/designer-using-a-...ython.html
Reply
#5
I used the external tool of py charm. After that I used the classic method from cmd and it worked well. Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Qt Designer : help document viewer error. davediamond 2 1,602 Apr-14-2022, 10:38 AM
Last Post: davediamond
  GUI programming PyQt 5 + Qt Designer flash77 9 2,744 Mar-19-2022, 10:31 AM
Last Post: flash77
  [PyQt] QT5 Designer Drawing greenhorn1 1 2,569 Dec-30-2021, 05:12 PM
Last Post: deanhystad
  Installed Designer - Helpf Files for "assistant" are missing Valmont 0 2,008 Mar-22-2021, 11:09 AM
Last Post: Valmont
  Using a GUI Designer vs. hard coding 357mag 9 6,099 Feb-21-2021, 06:43 PM
Last Post: kkaur
  Attempting to use Qt Designer. thewolf 17 6,149 Feb-17-2021, 12:03 AM
Last Post: thewolf
  [PyGUI] help code python QT Designer yan_mhb 0 1,924 Aug-12-2020, 09:32 AM
Last Post: yan_mhb
  [Kivy] Kivy Designer Module Error SARAVANAN_M 0 3,874 Nov-20-2019, 09:57 AM
Last Post: SARAVANAN_M
  [PyQt] Send data between windows Pyqt5 and Qt Designer kkonrad002 8 10,202 Sep-05-2019, 02:25 PM
Last Post: Denni
  [PyQt] Qt Designer - Making a Font with a border jimmyvegas29 4 7,557 Feb-19-2019, 11:08 PM
Last Post: jimmyvegas29

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020