I have created two Windows in QT designer. The first one has two pushButtons, each one calls the Dialog window. I am just starting to write the code for this but I could not go further when I tested the pushbutton on the dialog window. I have just connected to a function which calls print ("test."), Just to see the PB works, but it doesn't work.what I am missing?
See the main code below:
from PyQt5 import QtWidgets
from Main_VIEW import Ui_MainWindow # this is the main window
from Dialog_sa import Ui_Dialog # dialog window
from Test4 import currentAccount,savingAccount # this has all functions and calculations
import sys
class ApplicationWindow(QtWidgets.QMainWindow,Ui_MainWindow,Ui_Dialog,QtWidgets.QDialog):
def __init__(self):
super(ApplicationWindow, self).__init__()
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
#self.diag_ui = Ui_Dialog()
#self.diag_ui.setupUi(self)
self.ui.pb_ca.clicked.connect(self.open_dialog_ca)
def open_dialog_ca(self):
#global dialog
dialog = QtWidgets.QDialog()
dialog.ui = Ui_Dialog()
dialog.ui.setupUi(dialog)
dialog.exec_()
dialog.show()
account = currentAccount()
dialog.value_str = dialog.ui.le_b.text()
dialog.ui.pb_d.clicked.connect(self.print_sel) # this is the line of code that doesn't work
def print_sel(self):
print("this app")
def main():
app = QtWidgets.QApplication(sys.argv)
application = ApplicationWindow()
application.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
this is Dialog_sa
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'Dialog_sa.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(301, 142)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(-70, 110, 341, 32))
font = QtGui.QFont()
font.setFamily("Calibri Light")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.buttonBox.setFont(font)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.le_b = QtWidgets.QLineEdit(Dialog)
self.le_b.setGeometry(QtCore.QRect(50, 40, 131, 61))
font = QtGui.QFont()
font.setFamily("Calibri Light")
font.setPointSize(18)
self.le_b.setFont(font)
self.le_b.setObjectName("le_b")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(50, 20, 47, 13))
font = QtGui.QFont()
font.setFamily("Calibri")
font.setPointSize(11)
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName("label")
self.pb_w = QtWidgets.QPushButton(Dialog)
self.pb_w.setGeometry(QtCore.QRect(190, 80, 75, 23))
font = QtGui.QFont()
font.setFamily("Calibri Light")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.pb_w.setFont(font)
self.pb_w.setObjectName("pb_w")
self.pb_d = QtWidgets.QPushButton(Dialog)
self.pb_d.setGeometry(QtCore.QRect(190, 40, 75, 23))
font = QtGui.QFont()
font.setFamily("Calibri Light")
font.setPointSize(10)
font.setBold(False)
font.setWeight(50)
self.pb_d.setFont(font)
self.pb_d.setObjectName("pb_d")
self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept)
self.buttonBox.rejected.connect(Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "Balance"))
self.pb_w.setText(_translate("Dialog", "Withdraw"))
self.pb_d.setText(_translate("Dialog", "Deposit"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
This is MAIN_VIEW
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'Main_VIEW.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(259, 147)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pb_ca = QtWidgets.QPushButton(self.centralwidget)
self.pb_ca.setGeometry(QtCore.QRect(50, 10, 171, 41))
font = QtGui.QFont()
font.setFamily("Calibri Light")
font.setPointSize(14)
font.setBold(False)
font.setWeight(50)
self.pb_ca.setFont(font)
self.pb_ca.setObjectName("pb_ca")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(50, 60, 171, 41))
font = QtGui.QFont()
font.setFamily("Calibri Light")
font.setPointSize(14)
font.setBold(False)
font.setWeight(50)
self.pushButton_2.setFont(font)
self.pushButton_2.setObjectName("pushButton_2")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 259, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pb_ca.setText(_translate("MainWindow", "Current Account"))
self.pushButton_2.setText(_translate("MainWindow", "Saving Account"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
Related
I'm making a GUI with PyQt5.
I'm very very new to it. I need help.
First i have a stacked widget that I can use to switch between pages.
Right now im trying to make a setings page.
Settings Page
I know that putting stacked widgets for changing like "window"/page in pyqt5 might not be the best but ignore if you want to (if its bad give me a suggestion please).
Right now I want to check if the Dark Mode checkbox is enabled.
I have a MainWindow.py and I have a gui.py which is the one that I transformed from a .ui to .py (pyuic5 cmd).
In MainWindow.py I'm handling all of the gui's "commands/buttons".
gui.py is the file with all of the gui imported from qt designer.
I also have settings.config which is the files where I try to save the settings.
BTW my main idea was to write when the check box was clicked to save the thing to the .config file (which it does) and then check from MainWindow.py if the text == 'Dark Mode: True'
The Big Question How do I make it so the checkbox can be checked from another file (MainWindow.py)?
Also, if not should I change how the gui is handled and stuff.
Heres my code BTW:
The MainWindow.py Script:
import sys
import PyQt5
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QMainWindow
from gui import Ui_MainWindow
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import *
class MainWindow:
def __init__(self):
self.main_win = QMainWindow()
self.ui = Ui_MainWindow()
self.ui.setupUi(self.main_win)
self.main_win.setWindowTitle("GUI App")
self.ui.stackedWidget.setCurrentWidget(self.ui.start)
# Start Screen
self.ui.startButton.clicked.connect(self.showHomeScreen)
self.ui.settingsButton.clicked.connect(self.showSettingsScreen)
# Settings Screen
self.ui.backStartButton.clicked.connect(self.showStartScreen)
self.ui.darkModeEnabled.clicked.connect(self.checkDarkMode)
# Home Screen
self.ui.backToStartHome.clicked.connect(self.showStartScreen)
def showHomeScreen(self):
self.ui.stackedWidget.setCurrentWidget(self.ui.home)
# Start Screen Funcions
def showStartScreen(self):
self.ui.stackedWidget.setCurrentWidget(self.ui.start)
# Settings Functions
def showSettingsScreen(self):
self.ui.stackedWidget.setCurrentWidget(self.ui.settings)
def checkDarkMode(self):
if self.ui.darkModeEnabled.isChecked() == True:
self.f = open('settings.config', 'w')
self.f.write("Darkmode: True")
self.f.close()
if self.ui.darkModeEnabled.isChecked() == False:
self.f = open('settings.config', 'w')
self.f.write("Darkmode: False")
self.f.close()
for line in open('settings.config', 'r'):
if line == 'Darkmode: True':
self.ui.darkModeEnabled.setChecked(True)
print('Darkmode is on!')
elif line == 'Darkmode: False':
self.ui.darkModeEnabled.setChecked(False)
print('Darkmode is off!')
def show(self):
self.main_win.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
main_win = MainWindow()
main_win.show()
sys.exit(app.exec_())
The gui.py script:
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(597, 319)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.stackedWidget = QtWidgets.QStackedWidget(self.centralwidget)
self.stackedWidget.setGeometry(QtCore.QRect(-21, -11, 651, 321))
self.stackedWidget.setObjectName("stackedWidget")
self.start = QtWidgets.QWidget()
self.start.setObjectName("start")
self.label = QtWidgets.QLabel(self.start)
self.label.setGeometry(QtCore.QRect(130, 30, 351, 81))
font = QtGui.QFont()
font.setFamily("MS Gothic")
font.setPointSize(48)
self.label.setFont(font)
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setObjectName("label")
self.startButton = QtWidgets.QPushButton(self.start)
self.startButton.setGeometry(QtCore.QRect(150, 180, 131, 51))
self.startButton.setObjectName("startButton")
self.settingsButton = QtWidgets.QPushButton(self.start)
self.settingsButton.setGeometry(QtCore.QRect(310, 180, 131, 51))
self.settingsButton.setObjectName("settingsButton")
self.stackedWidget.addWidget(self.start)
self.home = QtWidgets.QWidget()
self.home.setObjectName("home")
self.label_2 = QtWidgets.QLabel(self.home)
self.label_2.setGeometry(QtCore.QRect(160, 30, 351, 81))
font = QtGui.QFont()
font.setFamily("MS Gothic")
font.setPointSize(48)
self.label_2.setFont(font)
self.label_2.setAlignment(QtCore.Qt.AlignCenter)
self.label_2.setObjectName("label_2")
self.backToStartHome = QtWidgets.QPushButton(self.home)
self.backToStartHome.setGeometry(QtCore.QRect(34, 42, 91, 51))
self.backToStartHome.setObjectName("backToStartHome")
self.stackedWidget.addWidget(self.home)
self.settings = QtWidgets.QWidget()
self.settings.setObjectName("settings")
self.label_3 = QtWidgets.QLabel(self.settings)
self.label_3.setGeometry(QtCore.QRect(130, 0, 431, 111))
font = QtGui.QFont()
font.setFamily("MS Gothic")
font.setPointSize(48)
self.label_3.setFont(font)
self.label_3.setAlignment(QtCore.Qt.AlignCenter)
self.label_3.setObjectName("label_3")
self.backStartButton = QtWidgets.QPushButton(self.settings)
self.backStartButton.setGeometry(QtCore.QRect(30, 40, 91, 31))
self.backStartButton.setObjectName("backStartButton")
self.darkModeEnabled = QtWidgets.QCheckBox(self.settings)
self.darkModeEnabled.setGeometry(QtCore.QRect(30, 130, 111, 21))
font = QtGui.QFont()
font.setFamily("MS Reference Sans Serif")
font.setPointSize(12)
self.darkModeEnabled.setFont(font)
self.darkModeEnabled.setObjectName("darkModeEnabled")
self.stackedWidget.addWidget(self.settings)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 597, 21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label.setText(_translate("MainWindow", "Start Page"))
self.startButton.setText(_translate("MainWindow", "Start"))
self.settingsButton.setText(_translate("MainWindow", "Settings"))
self.label_2.setText(_translate("MainWindow", "Home Page"))
self.backToStartHome.setText(_translate("MainWindow", "Back to Start"))
self.label_3.setText(_translate("MainWindow", "Settings Page"))
self.backStartButton.setText(_translate("MainWindow", "Back to Start"))
self.darkModeEnabled.setText(_translate("MainWindow", "Dark Mode"))
If you read all of this and know how to fix this please help.
And if you didn't but just know please help.
Thank You
I have two windows, first window is 'FirstWindow' and second is 'Calendar'. first window has one push button (pbSelectDate) and one label (lbDate). calendar window has calendar (CalendarBox) and one push button (pbSelect).
when i click select (pbSelectDate) from first window, calendar window pops up. I select the date and press select button (pbSelect) in the calendar window. i want to print the selected date to the label (lbDate) in the first window.
thanks in advance. :)
this is the first window script.
from PyQt5 import QtCore, QtGui, QtWidgets
from Calendar import Ui_CalendarWindow
class Ui_FirstWindow(object):
def Open_Calendar(self):
self.window = QtWidgets.QMainWindow()
self.ui = Ui_CalendarWindow()
self.ui.setupUi(self.window)
self.window.show()
def setupUi(self, FirstWindow):
FirstWindow.setObjectName("FirstWindow")
FirstWindow.resize(654, 242)
self.centralwidget = QtWidgets.QWidget(FirstWindow)
self.centralwidget.setObjectName("centralwidget")
self.lbDate = QtWidgets.QLabel(self.centralwidget)
self.lbDate.setGeometry(QtCore.QRect(330, 70, 281, 131))
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(True)
font.setWeight(75)
self.lbDate.setFont(font)
self.lbDate.setLayoutDirection(QtCore.Qt.LeftToRight)
self.lbDate.setObjectName("lbDate")
self.pbSelectDate = QtWidgets.QPushButton(self.centralwidget)
self.pbSelectDate.setGeometry(QtCore.QRect(80, 100, 191, 61))
self.pbSelectDate.setObjectName("pbSelectDate")
self.pbSelectDate.clicked.connect(self.Open_Calendar)
FirstWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(FirstWindow)
self.statusbar.setObjectName("statusbar")
FirstWindow.setStatusBar(self.statusbar)
self.retranslateUi(FirstWindow)
QtCore.QMetaObject.connectSlotsByName(FirstWindow)
def retranslateUi(self, FirstWindow):
_translate = QtCore.QCoreApplication.translate
FirstWindow.setWindowTitle(_translate("FirstWindow", "MainWindow"))
self.lbDate.setText(_translate("FirstWindow", "Sep"))
self.pbSelectDate.setText(_translate("FirstWindow", "Select Date"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
FirstWindow = QtWidgets.QMainWindow()
ui = Ui_FirstWindow()
ui.setupUi(FirstWindow)
FirstWindow.show()
sys.exit(app.exec_())
this is the Calendar window script..
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_CalendarWindow(object):
def PickedDate(self,var):
self.selecteddate = self.CalendarBox.selectedDate()
#print(self.selecteddate.toString('MMM')+'-'+self.selecteddate.toString('yyyy'))
def setupUi(self, CalendarWindow):
CalendarWindow.setObjectName("CalendarWindow")
CalendarWindow.resize(512, 458)
self.centralwidget = QtWidgets.QWidget(CalendarWindow)
self.centralwidget.setObjectName("centralwidget")
self.CalendarBox = QtWidgets.QCalendarWidget(self.centralwidget)
self.CalendarBox.setGeometry(QtCore.QRect(20, 20, 464, 289))
self.CalendarBox.setObjectName("CalendarBox")
self.pbSelect = QtWidgets.QPushButton(self.centralwidget)
self.pbSelect.setGeometry(QtCore.QRect(160, 330, 181, 60))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.pbSelect.setFont(font)
self.pbSelect.setObjectName("pbSelect")
self.pbSelect.clicked.connect(self.PickedDate)
CalendarWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(CalendarWindow)
self.statusbar.setObjectName("statusbar")
CalendarWindow.setStatusBar(self.statusbar)
self.retranslateUi(CalendarWindow)
QtCore.QMetaObject.connectSlotsByName(CalendarWindow)
def retranslateUi(self, CalendarWindow):
_translate = QtCore.QCoreApplication.translate
CalendarWindow.setWindowTitle(_translate("CalendarWindow", "MainWindow"))
self.pbSelect.setText(_translate("CalendarWindow", "Select"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
CalendarWindow = QtWidgets.QMainWindow()
ui = Ui_CalendarWindow()
ui.setupUi(CalendarWindow)
CalendarWindow.show()
sys.exit(app.exec_())
Do not modify the code generated by Qt Designer but create another class that inherits from the appropriate widget and use the initial class to fill it.
QLabel.setText(const QString )
Setting the text clears any previous content.
from PyQt5 import QtCore, QtGui, QtWidgets
#from Calendar import Ui_CalendarWindow
class Ui_CalendarWindow(object):
def setupUi(self, CalendarWindow):
CalendarWindow.setObjectName("CalendarWindow")
CalendarWindow.resize(512, 458)
self.centralwidget = QtWidgets.QWidget(CalendarWindow)
self.centralwidget.setObjectName("centralwidget")
self.CalendarBox = QtWidgets.QCalendarWidget(self.centralwidget)
self.CalendarBox.setGeometry(QtCore.QRect(20, 20, 464, 289))
self.CalendarBox.setObjectName("CalendarBox")
self.pbSelect = QtWidgets.QPushButton(self.centralwidget)
self.pbSelect.setGeometry(QtCore.QRect(160, 330, 181, 60))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.pbSelect.setFont(font)
self.pbSelect.setObjectName("pbSelect")
# self.pbSelect.clicked.connect(self.PickedDate)
CalendarWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(CalendarWindow)
self.statusbar.setObjectName("statusbar")
CalendarWindow.setStatusBar(self.statusbar)
self.retranslateUi(CalendarWindow)
QtCore.QMetaObject.connectSlotsByName(CalendarWindow)
def retranslateUi(self, CalendarWindow):
_translate = QtCore.QCoreApplication.translate
CalendarWindow.setWindowTitle(_translate("CalendarWindow", "MainWindow"))
self.pbSelect.setText(_translate("CalendarWindow", "Select"))
class Ui_FirstWindow(object):
def setupUi(self, FirstWindow):
FirstWindow.setObjectName("FirstWindow")
FirstWindow.resize(654, 242)
self.centralwidget = QtWidgets.QWidget(FirstWindow)
self.centralwidget.setObjectName("centralwidget")
self.lbDate = QtWidgets.QLabel(self.centralwidget)
self.lbDate.setGeometry(QtCore.QRect(330, 70, 281, 131))
font = QtGui.QFont()
font.setPointSize(16)
font.setBold(True)
font.setWeight(75)
self.lbDate.setFont(font)
self.lbDate.setLayoutDirection(QtCore.Qt.LeftToRight)
self.lbDate.setObjectName("lbDate")
self.pbSelectDate = QtWidgets.QPushButton(self.centralwidget)
self.pbSelectDate.setGeometry(QtCore.QRect(80, 100, 191, 61))
self.pbSelectDate.setObjectName("pbSelectDate")
# self.pbSelectDate.clicked.connect(self.Open_Calendar)
FirstWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(FirstWindow)
self.statusbar.setObjectName("statusbar")
FirstWindow.setStatusBar(self.statusbar)
self.retranslateUi(FirstWindow)
QtCore.QMetaObject.connectSlotsByName(FirstWindow)
def retranslateUi(self, FirstWindow):
_translate = QtCore.QCoreApplication.translate
FirstWindow.setWindowTitle(_translate("FirstWindow", "MainWindow"))
self.lbDate.setText(_translate("FirstWindow", "Sep"))
self.pbSelectDate.setText(_translate("FirstWindow", "Select Date"))
class CalendarWindow(QtWidgets.QMainWindow, Ui_CalendarWindow): # +
def __init__(self):
super(CalendarWindow, self).__init__()
self.setupUi(self)
class FirstWindow(QtWidgets.QMainWindow, Ui_FirstWindow): # +
def __init__(self):
super(FirstWindow, self).__init__()
self.setupUi(self)
self.pbSelectDate.clicked.connect(self.Open_Calendar)
def Open_Calendar(self):
self.window = CalendarWindow()
self.window.setupUi(self.window)
self.window.show()
self.window.pbSelect.clicked.connect(self.PickedDate)
def PickedDate(self): # , var
self.selecteddate = self.window.CalendarBox.selectedDate()
# print(self.selecteddate.toString('MMM')+'-'+self.selecteddate.toString('yyyy'))
self.lbDate.setText(self.selecteddate.toString('ddd-MMM-yyyy')) # <---
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
w = FirstWindow()
w.show()
sys.exit(app.exec_())
This question already has answers here:
Close and Open new Window PYQT5
(2 answers)
Closed 3 years ago.
I am currently trying to get a button press in one qt window to open a second window which is in another python file. My layout code was generated by converting a ui made in Qt designer to python.
My select feature code:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'movie_design.ui'
#
# Created by: PyQt5 UI code generator 5.14.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
import add_entry
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(597, 522)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(160, 40, 291, 51))
font = QtGui.QFont()
font.setPointSize(14)
font.setBold(False)
font.setUnderline(True)
font.setWeight(50)
font.setStrikeOut(False)
font.setKerning(True)
self.label.setFont(font)
self.label.setLineWidth(1)
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setObjectName("label")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(170, 110, 261, 91))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButton.setFont(font)
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(170, 230, 261, 91))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButton_2.setFont(font)
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_3.setGeometry(QtCore.QRect(170, 350, 261, 91))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButton_3.setFont(font)
self.pushButton_3.setObjectName("pushButton_3")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 597, 26))
self.menubar.setObjectName("menubar")
self.menuMenu = QtWidgets.QMenu(self.menubar)
self.menuMenu.setObjectName("menuMenu")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.menubar.addAction(self.menuMenu.menuAction())
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
self.pushButton_2.clicked.connect(self.add)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label.setText(_translate("MainWindow", "Movie Database Program"))
self.pushButton.setText(_translate("MainWindow", "Delete Record"))
self.pushButton_2.setText(_translate("MainWindow", "Add Record"))
self.pushButton_3.setText(_translate("MainWindow", "Search Records"))
self.menuMenu.setTitle(_translate("MainWindow", "Menu"))
def add(self):
add_entry.add_entry()
def main():
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
app.exec_()
if __name__ == "__main__":
main()
As you can see, I have created a button that when pressed calls the function in the program "add_entry.py"
Add entry.py code:
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'add_entry.ui'
#
# Created by: PyQt5 UI code generator 5.14.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(555, 418)
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(10, 30, 533, 28))
font = QtGui.QFont()
font.setPointSize(14)
self.label.setFont(font)
self.label.setTextFormat(QtCore.Qt.AutoText)
self.label.setScaledContents(False)
self.label.setAlignment(QtCore.Qt.AlignCenter)
self.label.setObjectName("label")
self.formLayoutWidget = QtWidgets.QWidget(Dialog)
self.formLayoutWidget.setGeometry(QtCore.QRect(30, 70, 501, 321))
self.formLayoutWidget.setObjectName("formLayoutWidget")
self.formLayout = QtWidgets.QFormLayout(self.formLayoutWidget)
self.formLayout.setContentsMargins(0, 0, 0, 0)
self.formLayout.setObjectName("formLayout")
self.label_2 = QtWidgets.QLabel(self.formLayoutWidget)
font = QtGui.QFont()
font.setPointSize(12)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label_2)
self.MovieTitle = QtWidgets.QLineEdit(self.formLayoutWidget)
self.MovieTitle.setObjectName("MovieTitle")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.MovieTitle)
self.label_3 = QtWidgets.QLabel(self.formLayoutWidget)
font = QtGui.QFont()
font.setPointSize(12)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_3)
self.MovieStudio = QtWidgets.QLineEdit(self.formLayoutWidget)
self.MovieStudio.setObjectName("MovieStudio")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.MovieStudio)
self.label_4 = QtWidgets.QLabel(self.formLayoutWidget)
font = QtGui.QFont()
font.setPointSize(12)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_4)
self.dateEdit = QtWidgets.QDateEdit(self.formLayoutWidget)
self.dateEdit.setObjectName("dateEdit")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.dateEdit)
self.label_5 = QtWidgets.QLabel(self.formLayoutWidget)
font = QtGui.QFont()
font.setPointSize(12)
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.label_5)
self.ProductionCost = QtWidgets.QSpinBox(self.formLayoutWidget)
self.ProductionCost.setMaximum(1000000000)
self.ProductionCost.setObjectName("ProductionCost")
self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.ProductionCost)
self.label_6 = QtWidgets.QLabel(self.formLayoutWidget)
font = QtGui.QFont()
font.setPointSize(12)
self.label_6.setFont(font)
self.label_6.setObjectName("label_6")
self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.label_6)
self.BoxOfficeRevenue = QtWidgets.QSpinBox(self.formLayoutWidget)
self.BoxOfficeRevenue.setMaximum(1000000000)
self.BoxOfficeRevenue.setObjectName("BoxOfficeRevenue")
self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.BoxOfficeRevenue)
self.label_7 = QtWidgets.QLabel(self.formLayoutWidget)
font = QtGui.QFont()
font.setPointSize(12)
self.label_7.setFont(font)
self.label_7.setObjectName("label_7")
self.formLayout.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.label_7)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.No = QtWidgets.QRadioButton(self.formLayoutWidget)
font = QtGui.QFont()
font.setPointSize(10)
self.No.setFont(font)
self.No.setObjectName("No")
self.horizontalLayout.addWidget(self.No)
self.Yes = QtWidgets.QRadioButton(self.formLayoutWidget)
font = QtGui.QFont()
font.setPointSize(10)
self.Yes.setFont(font)
self.Yes.setObjectName("Yes")
self.horizontalLayout.addWidget(self.Yes)
self.formLayout.setLayout(5, QtWidgets.QFormLayout.FieldRole, self.horizontalLayout)
self.label_8 = QtWidgets.QLabel(self.formLayoutWidget)
font = QtGui.QFont()
font.setPointSize(12)
self.label_8.setFont(font)
self.label_8.setObjectName("label_8")
self.formLayout.setWidget(6, QtWidgets.QFormLayout.LabelRole, self.label_8)
self.classificationBox = QtWidgets.QComboBox(self.formLayoutWidget)
font = QtGui.QFont()
font.setPointSize(10)
self.classificationBox.setFont(font)
self.classificationBox.setObjectName("classificationBox")
self.classificationBox.addItem("")
self.classificationBox.addItem("")
self.classificationBox.addItem("")
self.classificationBox.addItem("")
self.classificationBox.addItem("")
self.formLayout.setWidget(6, QtWidgets.QFormLayout.FieldRole, self.classificationBox)
self.pushButton = QtWidgets.QPushButton(self.formLayoutWidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
self.pushButton.setSizePolicy(sizePolicy)
self.pushButton.setObjectName("pushButton")
self.formLayout.setWidget(7, QtWidgets.QFormLayout.SpanningRole, self.pushButton)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.label.setText(_translate("Dialog", "<html><head/><body><p><span style=\" font-size:12pt; text-decoration: underline;\">Add Entry</span></p></body></html>"))
self.label_2.setText(_translate("Dialog", "Movie Title"))
self.label_3.setText(_translate("Dialog", "Movie Studio"))
self.label_4.setText(_translate("Dialog", "Release Date"))
self.label_5.setText(_translate("Dialog", "Production Cost (m$)"))
self.label_6.setText(_translate("Dialog", "Box Office Revenue (m$)"))
self.label_7.setText(_translate("Dialog", "Have you seen this movie?"))
self.No.setText(_translate("Dialog", "Yes"))
self.Yes.setText(_translate("Dialog", "No"))
self.label_8.setText(_translate("Dialog", "Classification (Age Rating)"))
self.classificationBox.setItemText(0, _translate("Dialog", "U"))
self.classificationBox.setItemText(1, _translate("Dialog", "PG"))
self.classificationBox.setItemText(2, _translate("Dialog", "12"))
self.classificationBox.setItemText(3, _translate("Dialog", "15"))
self.classificationBox.setItemText(4, _translate("Dialog", "18"))
self.pushButton.setText(_translate("Dialog", "Add Entry"))
def add_entry():
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
app.exec_()
if __name__ == "__main__":
add_entry()
The issue is that the when the button is pressed, the program crashes, telling me that "Event loop already running". How do I fix this?
Qt, like many GUI frameworks, is based on an event loop which is started with app.exec_() and then waits for events to react to (both from the user or the system).
For each Qt program there should always be a single and only QApplication instance running its event loop.
With your implementation, each time you press the button, you're trying to create and launch a new QApplication, and Qt will not allow you for the reason above.
Nonetheless, the problem with your code is somewhere else, as you are using the generated UI code in the wrong way: those files should never be used as a basis to create your program code (in fact, you should always leave them as they are).
I suggest you to carefully read the official documentation about using Designer to understand how to use those files.
Regenerate the UI files with pyuic, and then create a new script that will probably contain something similar to this:
from PyQt5 import QtWidgets
from ui_mainwindow import Ui_MainWindow
from ui_dialog import Ui_Dialog
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.pushButton_2.clicked.connect(self.add)
def add(self):
dialog = Dialog(self)
dialog.exec_()
class Dialog(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setupUi(self)
if __name__ == '__main__':
import sys
app = QtWidgets.QApplication(sys.argv)
mainWindow = MainWindow()
mainWindow.show()
sys.exit(app.exec_())
In this example I used the third method (multiple inheritance approach) explained in the documentation given above.
I don't know how to take input of user in one textbox and show output in other textbox.
I tried but it's not working.
from PyQt5 import QtCore, QtGui, QtWidgets
import os
def click(self):
self.pushButton.click()
print("hello")
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(664, 389)
MainWindow.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
MainWindow.setLayoutDirection(QtCore.Qt.LeftToRight)
MainWindow.setAutoFillBackground(False)
MainWindow.setStyleSheet("background-image: url(:/background/White-Marble-Background-product-Photography-backdrops-Newborn-Photo-props-baby-shower-PhotoCall-pictures-newborn-propsXt-6735.jpg_640x640.webp);")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(20, 20, 621, 51))
font = QtGui.QFont()
font.setFamily("Yu Gothic UI Semibold")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.lineEdit.setFont(font)
self.lineEdit.setAutoFillBackground(False)
self.lineEdit.setObjectName("lineEdit")
inp_val = self.lineEdit.text()
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(240, 290, 151, 41))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.pushButton.setFont(font)
self.pushButton.setStyleSheet("background-color: rgb(240, 184, 160);")
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(click(self))
self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
self.textEdit.setGeometry(QtCore.QRect(20, 90, 621, 191))
font = QtGui.QFont()
font.setFamily("Yu Gothic UI Semibold")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.textEdit.setFont(font)
self.textEdit.setCursorWidth(2)
self.textEdit.setObjectName("textEdit")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Rahul"))
self.pushButton.setText(_translate("MainWindow", "Run"))
self.lineEdit.setPlaceholderText(_translate("MainWindow", "Type Your Text Here....."))
self.textEdit.setPlaceholderText(_translate("MainWindow", "Your Output....."))
import test2_rc
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
How do I input in lineedit and show output in textedit?
Try it:
from PyQt5 import QtCore, QtGui, QtWidgets
# ? import os
#def click(self):
# self.pushButton.click()
# print("hello")
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(664, 389)
MainWindow.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
MainWindow.setLayoutDirection(QtCore.Qt.LeftToRight)
MainWindow.setAutoFillBackground(False)
MainWindow.setStyleSheet("background-image: url(:/background/White-Marble-Background-product-Photography-backdrops-Newborn-Photo-props-baby-shower-PhotoCall-pictures-newborn-propsXt-6735.jpg_640x640.webp);")
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
self.lineEdit.setGeometry(QtCore.QRect(20, 20, 621, 51))
font = QtGui.QFont()
font.setFamily("Yu Gothic UI Semibold")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.lineEdit.setFont(font)
self.lineEdit.setAutoFillBackground(False)
self.lineEdit.setObjectName("lineEdit")
inp_val = self.lineEdit.text()
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(240, 290, 151, 41))
font = QtGui.QFont()
font.setFamily("Rubik")
font.setPointSize(12)
font.setBold(True)
font.setWeight(75)
self.pushButton.setFont(font)
self.pushButton.setStyleSheet("background-color: rgb(240, 184, 160);")
self.pushButton.setObjectName("pushButton")
# self.pushButton.clicked.connect(click(self))
self.pushButton.clicked.connect(self.onClick)
self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
self.textEdit.setGeometry(QtCore.QRect(20, 90, 621, 191))
font = QtGui.QFont()
font.setFamily("Yu Gothic UI Semibold")
font.setPointSize(14)
font.setBold(True)
font.setWeight(75)
self.textEdit.setFont(font)
self.textEdit.setCursorWidth(2)
self.textEdit.setObjectName("textEdit")
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def onClick(self):
# self.pushButton.click()
print("hello")
self.textEdit.append(self.lineEdit.text()) # <---
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "Rahul"))
self.pushButton.setText(_translate("MainWindow", "Run"))
self.lineEdit.setPlaceholderText(_translate("MainWindow", "Type Your Text Here....."))
self.textEdit.setPlaceholderText(_translate("MainWindow", "Your Output....."))
# ? import test2_rc
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
Use setPlainText:
def click(self):
inputtext = self.lineEdit.text()
self.textEdit.setPlainText(inputtext)
Also you need to put function click inside class Ui_MainWindow, like this:
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
#your code
def click(self):
inputtext = self.lineEdit.text()
self.textEdit.setPlainText(inputtext)
Also call function click like:
self.pushButton.clicked.connect(self.click)
I created two windows
First window
from PyQt5 import QtCore, QtGui, QtWidgets
from dial import Ui_dial
from chat import Ui_Chat
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(764, 719)
font = QtGui.QFont()
font.setKerning(False)
Form.setFont(font)
Form.setStyleSheet()
self.call_button = QtWidgets.QPushButton(Form)
self.call_button.setGeometry(QtCore.QRect(320, 500, 111, 71))
font = QtGui.QFont()
font.setFamily("Times New Roman")
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.call_button.setFont(font)
self.call_button.setStyleSheet("")
self.call_button.setText("")
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/images/Images/call.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.call_button.setIcon(icon2)
self.call_button.setIconSize(QtCore.QSize(58, 58))
self.call_button.setCheckable(True)
self.call_button.setAutoExclusive(True)
self.call_button.setObjectName("call_button")
self.call_button.setShortcut(QtGui.QKeySequence(QtCore.Qt.Key_Space))
self.call_button.clicked.connect(self.dialwindow)
self.ilabel = QtWidgets.QLabel(Form)
self.ilabel.setGeometry(QtCore.QRect(210, 60, 331, 191))
font = QtGui.QFont()
font.setFamily("Sylfaen")
font.setPointSize(18)
self.ilabel.setFont(font)
self.ilabel.setStyleSheet("background-image: url(:/images/Images/label_back1.jpg);")
self.ilabel.setObjectName("ilabel")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
import icons_rc
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QDialog()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
Second Window
from PyQt5 import QtCore, QtGui, QtWidgets
import dial_rc
class Ui_dial(object):
def setupUi(self, dial):
dial.setObjectName("dial")
dial.resize(739, 712)
dial.setStyleSheet()
self.dialpage_label = QtWidgets.QLabel(dial)
self.dialpage_label.setGeometry(QtCore.QRect(240, 120, 301, 511))
self.dialpage_label.setObjectName("dialpage_label")
self.callend_button = QtWidgets.QPushButton(dial)
self.callend_button.setGeometry(QtCore.QRect(340, 520, 91, 71))
self.callend_button.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/images/Images/end.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.callend_button.setIcon(icon)
self.callend_button.setIconSize(QtCore.QSize(45, 45))
self.callend_button.setObjectName("callend_button")
self.callend_button.clicked.connect(self.endcall)
def retranslateUi(self, dial):
_translate = QtCore.QCoreApplication.translate
dial.setWindowTitle(_translate("dial", "Dialog"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
dial = QtWidgets.QDialog()
ui = Ui_dial()
ui.setupUi(dial)
dial.show()
sys.exit(app.exec_())
How to show this different windows in single window?when click on button new window is open ,so i want show when i click on the button that second window open in same screen.so i need expertise on this problem
First modify your python script so that the class inherits from QtWidgets.QMainWindow
by
class Ui_Form(QtWidgets.Qdialog):
Then write an init function so that your class can be instantiated, i.e an object can be created. Once that is done, you can chuck out the QtWidgets.QDialog() object, the one that goes by the name dial in your script, being passed to your setupUI(). Then replace this object being passed with self.
Overall your code will look like this.
class Ui_dial(QtWidgets.Qdialog):
def __init__(self):
super().__init__()//inheriting from the object.
def setupUi(self, dial):
self.setObjectName("dial")
self.resize(739, 712)
self.setStyleSheet()
self.dialpage_label = QtWidgets.QLabel(dial)
self.dialpage_label.setGeometry(QtCore.QRect(240, 120, 301, 511))
self.dialpage_label.setObjectName("dialpage_label")
self.callend_button = QtWidgets.QPushButton(dial)
self.callend_button.setGeometry(QtCore.QRect(340, 520, 91, 71))
self.callend_button.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/images/Images/end.png"),
def retranslateUi(self):
_translate = QtCore.QCoreApplication.translate
self.setWindowTitle(_translate("dial", "Dialog"))
Do the same for your other script and then make objects of these classes and call them as,
First_window = Ui_Form()
First_window.show()
Second_window = Ui_dial()
Second_window.show()
You might need to use resize() to adjust the two windows and to accommodate them according to your needs.