![]() |
QT Designer - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: QT Designer (/thread-37312.html) |
QT Designer - Krissstian - May-26-2022 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 RE: QT Designer - menator01 - May-26-2022 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() RE: QT Designer - Krissstian - May-26-2022 (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. Thank you! RE: QT Designer - deanhystad - May-26-2022 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-ui-file-python.html RE: QT Designer - Krissstian - May-26-2022 I used the external tool of py charm. After that I used the classic method from cmd and it worked well. Thank you. |