Set Vertical Orientation to a LineEdit in Python qt - python

I am making a GUI using qt and trying incorporate a LineEdit with Vertical Orientation.
When using the code:
import sys
from PyQt4 import QtCore, QtGui
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(250, 250)
self.lineEdit = QtGui.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(40, 80, 120, 20))
self.lineEdit.setObjectName("lineEdit")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(_translate("Dialog", "Dialog #1", None))
class themain(QtGui.QDialog, Ui_Dialog):
def __init__(self, parent=None):
super(themain,self).__init__(parent)
self.setupUi(self)
self.lineEdit.setText('Some Text')
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
form = themain()
form.show()
sys.exit(app.exec_())
I get a simple LineEdit with Horizontal Orientation.
In essence I need something that looks like:
[Image][1]
http://users.ntua.gr/anthpro/images/dialog.png
(The image has been photoshopped to show the lineedit in vertical orientation)

Related

Barcode Scanner tabbing to next line edit

I'm using a USB-barcode scanner to set the text of a Qt lineEdit field to scan production order number, My issue is that after scanning the window is closed instead of shifting to next lineEdit_2 to scan item number. How to setup lineEdit to shift the crusor to next lineEdit_2 and be ready for the next scan.
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(290, 20, 81, 241))
self.buttonBox.setOrientation(QtCore.Qt.Vertical)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.lineEdit = QtWidgets.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(50, 50, 113, 22))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit_2 = QtWidgets.QLineEdit(Dialog)
self.lineEdit_2.setGeometry(QtCore.QRect(50, 120, 113, 22))
self.lineEdit_2.setObjectName("lineEdit_2")
self.lineEdit_3 = QtWidgets.QLineEdit(Dialog)
self.lineEdit_3.setGeometry(QtCore.QRect(50, 200, 113, 22))
self.lineEdit_3.setObjectName("lineEdit_3")
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"))
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_())
By default the buttons of a QPushButton are pressed when the enter key is clicked and the QDialog has focus, and that click causes the rejected or accepted signal to be emitted, which closes the window, and this is handled by the default and autoDefault properties, so the first thing is to override that behavior.
On the other hand, pressing the enter key does not move to the other QLineEdit, in that case you must listen to that key and use focusNextPrevChild to move the focus.
Finally the codes generated by QtDesigner should not be modified so I will assume that the code you show is in the gui.py file, and I will implement the logic in main.py:
import sys
from PyQt5 import QtCore, QtWidgets
from gui import Ui_Dialog
class Dialog(QtWidgets.QDialog, Ui_Dialog):
def __init__(self, parent=None):
super().__init__(parent)
self.setupUi(self)
self.show()
for btn in self.buttonBox.buttons():
btn.setDefault(False)
btn.setAutoDefault(False)
btn.setFocusPolicy(QtCore.Qt.NoFocus)
def keyPressEvent(self, event):
if event.key() in (QtCore.Qt.Key_Enter, QtCore.Qt.Key_Return):
self.focusNextPrevChild(True)
super().keyPressEvent(event)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
w = Dialog()
w.show()
sys.exit(app.exec_())

self.close and self.hide not working in pyqt5

I am new to python. I am using pyqt5 for GUI development. I have a main Window which should close and new dialog appears after clicking the pushButton. But it doesnot closes and neither show any error and opens the nextDialog. I also want to close nextDialog when OK button is clicked in nextDialog. Please help to check the issue. I am trying to develeop a new project but stuck on this issue. Codes are given below.
Main.py
from PyQt5 import QtCore, QtGui, QtWidgets
from nextDialog import Ui_Dialog
class Ui_MainWindow(QtWidgets.QMainWindow):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(370, 171)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(110, 50, 75, 23))
self.pushButton.setObjectName("pushButton")
MainWindow.setCentralWidget(self.centralwidget)
self.pushButton.clicked.connect(self.opennext)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def opennext(self):
self.Dialog = QtWidgets.QDialog()
self.ui = Ui_Dialog()
self.ui.setupUi(self.Dialog)
self.Dialog.show()
self.close() #Not working
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "Open"))
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_())
from PyQt5 import QtCore, QtGui, QtWidgets
import sys
nextDialog.py
class Ui_Dialog(QtWidgets.QMainWindow):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(346, 182)
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(110, 80, 75, 23))
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(self.exit)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def exit(self):
self.hide() #This also not working, I want either of these two to
#work
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.pushButton.setText(_translate("Dialog", "OK"))
Try it:
main.py
from PyQt5 import QtCore, QtGui, QtWidgets
from nextDialog import Ui_Dialog
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.centralwidget = QtWidgets.QWidget()
self.setCentralWidget(self.centralwidget)
self.pushButton = QtWidgets.QPushButton("Open", self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(110, 50, 75, 23))
self.pushButton.clicked.connect(self.opennext)
def opennext(self):
self.Dialog = QtWidgets.QDialog()
self.ui = Ui_Dialog()
self.ui.setupUi(self.Dialog)
self.Dialog.show()
self.close() #Not working
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
window = MainWindow()
# ui = Ui_MainWindow()
# ui.setupUi(MainWindow)
window.show()
sys.exit(app.exec_())
nextDialog.py
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(QtWidgets.QMainWindow):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(346, 182)
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(110, 80, 75, 23))
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(Dialog.close) # <---
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.pushButton.setText(_translate("Dialog", "OK"))
Hi kind of difficult to understand your code, I am using just Designer to make my GUI,
in anycase I made the first part of the puzzle work for your main.py
line 4 should read class Ui_MainWindow(object):
and to close the first window about lane 25 use MainWindow.close()
added import sys too at the beginning, here the code
main.py:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 17:43:19 2020
#author: Pietro
"""
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from nextDialog import Ui_Dialog
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(370, 171)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setGeometry(QtCore.QRect(110, 50, 75, 23))
self.pushButton.setObjectName("pushButton")
MainWindow.setCentralWidget(self.centralwidget)
self.pushButton.clicked.connect(self.opennext)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def opennext(self):
self.Dialog = QtWidgets.QDialog()
self.ui = Ui_Dialog()
self.ui.setupUi(self.Dialog)
self.Dialog.show()
MainWindow.close()
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.pushButton.setText(_translate("MainWindow", "Open"))
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
this open first window then close it when open buttton is pressed and new window appears, second part of the riddle is gonna take longer I'll try it as soon as I get some spare time
Dialog.py from answer below seems to work dont know why (dont know how main.py works too, but it is kind of more illogic to me the fact that def exit doesnt work).
nextDialog.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 18 17:43:19 2020
#author: Pietro
"""
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(QtWidgets.QMainWindow):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(346, 182)
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setGeometry(QtCore.QRect(110, 80, 75, 23))
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(Dialog.close) # as answer below dont know why def exit doesnt work
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
# def exit(self):
# print('exit' *5)
# Dialog.close()
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.pushButton.setText(_translate("Dialog", "OK"))

PyDesigner PyQt5 MouseEvent Not working setMouseTracking(True)

How to let MouseEvent working?
I try to print mouse tracking to label x,y coordinate but always fail. I already using setMouseTracking(True), generate from QtDesigner ui to py.
code Below:
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(640, 480)
Form.setMouseTracking(True)
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(270, 190, 58, 15))
self.label.setObjectName("label")
self.label.setMouseTracking(True)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.label.setText(_translate("Form", "TextLabel"))
def mouseMoveEvent(self, e):
x = e.x()
y = e.y()
text = "x: {0}, y: {1}".format(x, y)
self.label.setText(text)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
Ui_Form is not a widget, so it will not have the mouseMoveEvent method, as the PyQt docs point out you must create a class that inherits the appropriate widget, in this case QWidget, and use the interface provided by Qt Designer:
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(640, 480)
Form.setMouseTracking(True)
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(270, 190, 58, 15))
self.label.setObjectName("label")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.label.setText(_translate("Form", "TextLabel"))
class Form(QtWidgets.QWidget, Ui_Form):
def __init__(self, parent=None):
super(Form, self).__init__(parent)
self.setupUi(self)
self.setMouseTracking(True)
def mouseMoveEvent(self, e):
text = "x: {0}, y: {1}".format(e.x(), e.y())
self.label.setText(text)
self.label.adjustSize()
super(Form, self).mouseMoveEvent(e)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
w = Form()
w.show()
sys.exit(app.exec_())

Qt Designer PyQt5 overwrite CloseEvent child window don't work

I have three windows designed in QtDesigner. The main window calls the two childs windows using buttons. If I close the main window the childs windows also close, I did this by overwriting the closeEvent in the main window. I need to implement some stuff in the closeEvent of the child window so I overwritten the closeEvent of the child class but it does nothing. Please help.
Class of the main window made in Qt Designer
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_ventanaPrincipal(object):
def setupUi(self, ventanaPrincipal):
ventanaPrincipal.setObjectName("ventanaPrincipal")
ventanaPrincipal.resize(267, 238)
self.centralWidget = QtWidgets.QWidget(ventanaPrincipal)
self.centralWidget.setObjectName("centralWidget")
self.buttonVentana1 = QtWidgets.QPushButton(self.centralWidget)
self.buttonVentana1.setGeometry(QtCore.QRect(60, 30, 141, 25))
self.buttonVentana1.setObjectName("buttonVentana1")
self.buttonVentana2 = QtWidgets.QPushButton(self.centralWidget)
self.buttonVentana2.setGeometry(QtCore.QRect(60, 80, 141, 25))
self.buttonVentana2.setObjectName("buttonVentana2")
ventanaPrincipal.setCentralWidget(self.centralWidget)
self.menuBar = QtWidgets.QMenuBar(ventanaPrincipal)
self.menuBar.setGeometry(QtCore.QRect(0, 0, 267, 22))
self.menuBar.setObjectName("menuBar")
ventanaPrincipal.setMenuBar(self.menuBar)
self.mainToolBar = QtWidgets.QToolBar(ventanaPrincipal)
self.mainToolBar.setObjectName("mainToolBar")
ventanaPrincipal.addToolBar(QtCore.Qt.TopToolBarArea, self.mainToolBar)
self.statusBar = QtWidgets.QStatusBar(ventanaPrincipal)
self.statusBar.setObjectName("statusBar")
ventanaPrincipal.setStatusBar(self.statusBar)
self.retranslateUi(ventanaPrincipal)
QtCore.QMetaObject.connectSlotsByName(ventanaPrincipal)
def retranslateUi(self, ventanaPrincipal):
_translate = QtCore.QCoreApplication.translate
ventanaPrincipal.setWindowTitle(_translate("ventanaPrincipal", "ventanaPrincipal"))
self.buttonVentana1.setText(_translate("ventanaPrincipal", "Ventana 1"))
self.buttonVentana2.setText(_translate("ventanaPrincipal", "Ventana 2"))
Class of first child window
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_subVen1(object):
def setupUi(self, subVen1):
subVen1.setObjectName("subVen1")
subVen1.resize(320, 347)
self.label = QtWidgets.QLabel(subVen1)
self.label.setGeometry(QtCore.QRect(40, 20, 141, 17))
self.label.setObjectName("label")
self.listWidget = QtWidgets.QListWidget(subVen1)
self.listWidget.setGeometry(QtCore.QRect(20, 60, 256, 192))
self.listWidget.setObjectName("listWidget")
self.retranslateUi(subVen1)
QtCore.QMetaObject.connectSlotsByName(subVen1)
def retranslateUi(self, subVen1):
_translate = QtCore.QCoreApplication.translate
subVen1.setWindowTitle(_translate("subVen1", "Form"))
self.label.setText(_translate("subVen1", "MIAU MIAU"))
Class of second child window
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_subVen2(object):
def setupUi(self, subVen2):
subVen2.setObjectName("subVen2")
subVen2.resize(320, 304)
self.listView = QtWidgets.QListView(subVen2)
self.listView.setGeometry(QtCore.QRect(40, 60, 256, 192))
self.listView.setObjectName("listView")
self.label = QtWidgets.QLabel(subVen2)
self.label.setGeometry(QtCore.QRect(80, 20, 121, 17))
self.label.setObjectName("label")
self.retranslateUi(subVen2)
QtCore.QMetaObject.connectSlotsByName(subVen2)
def retranslateUi(self, subVen2):
_translate = QtCore.QCoreApplication.translate
subVen2.setWindowTitle(_translate("subVen2", "Form"))
self.label.setText(_translate("subVen2", "Guau Guau"))
File that calls the other three.
import sys
#import classes-----------------------
from HMIs.ventanaprincipal import Ui_ventanaPrincipal, QtWidgets
from HMIs.subventana1 import Ui_subVen1
from HMIs.subventana2 import Ui_subVen2
# hijaSub1 inherits the first child window class made by the QtDesigner
#override child closeEvent
class hijaSub1(Ui_subVen1):
def closeEvent(self, event):
print("X is clicked")
class multiVen(QtWidgets.QMainWindow):
def __init__(self,parent=None):
QtWidgets.QWidget.__init__(self,parent=None)
self.ui =Ui_ventanaPrincipal()
self.ui.setupUi(self)
self.subV1=QtWidgets.QWidget()
self.subV2=QtWidgets.QWidget()
#Conect signals whith slots--------------------
self.ui.buttonVentana1.clicked.connect(self.muestraVentana1)
self.ui.buttonVentana2.clicked.connect(self.muestraVentana2)
# slots-----------------------------------------
def muestraVentana1(self):
self.wid1=hijaSub1()
self.wid1.setupUi(self.subV1)
self.subV1.show()
def muestraVentana2(self):
self.wid2=Ui_subVen2()
self.wid2.setupUi(self.subV2)
self.subV2.show()
#Close all windows whith X button of main window
#override main closeEvent
def closeEvent(self, event):
self.subV1.close()
self.subV2.close()
event.accept()
if __name__=="__main__":
app=0
app=QtWidgets.QApplication(sys.argv)
myapp=multiVen()
myapp.show()
sys.exit(app.exec_())
The closeEvent method has the classes that inherit from QWidget, in which case the daughter classes Sub1, Ui_subVen1, Ui_subVen2 inherit from object, not from QWidget.
If you want to implement closeEvent in windows, create a class that uses the window view (Ui_xxx) and inherits from QWidget.
class hijaSub1(QtWidgets.QWidget, Ui_subVen1):
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent=parent)
self.setupUi(self)
def closeEvent(self, event):
print("X is clicked: hijaSub1")
class hijaSub2(QtWidgets.QWidget, Ui_subVen2):
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent=parent)
self.setupUi(self)
def closeEvent(self, event):
print("X is clicked: hijaSub2")
class multiVen(QtWidgets.QMainWindow):
def __init__(self,parent=None):
QtWidgets.QWidget.__init__(self,parent=None)
self.ui =Ui_ventanaPrincipal()
self.ui.setupUi(self)
self.subV1=hijaSub1()
self.subV2=hijaSub2()
#Conect signals whith slots--------------------
self.ui.buttonVentana1.clicked.connect(self.muestraVentana1)
self.ui.buttonVentana2.clicked.connect(self.muestraVentana2)
# slots-----------------------------------------
def muestraVentana1(self):
self.subV1.show()
def muestraVentana2(self):
self.subV2.show()
#Close all windows whith X button of main window
#override main closeEvent
def closeEvent(self, event):
self.subV1.close()
self.subV2.close()
event.accept()
if __name__=="__main__":
import sys
app=0
app=QtWidgets.QApplication(sys.argv)
myapp=multiVen()
myapp.show()
sys.exit(app.exec_())

how to call another window in pyqt4 python?

how to call another window in pytq4?
For example i have two separate form. I want to show the second form when i click a button in the login form.
EDITED:
for example i have this dialog for my login.
when the user click a button the main.py would appear and this dialog will be close.
LOGIN.py
from PyQt4 import QtCore, QtGui
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(379, 184)
self.buttonBox = QtGui.QDialogButtonBox(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(20, 130, 341, 32))
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.retranslateUi(Dialog)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"), Dialog.accept)
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"), Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Dialog = QtGui.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
MAIN.py
from PyQt4 import QtCore, QtGui
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(595, 315)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
I had a similar situation and this is what I've done. Does not feel like the ideal solution but it worked for me.
import Main
self.main = Main.Form(user, loginWindow=self)
self.hide()
self.main.show()
# You can do self.close() here OR
# loginWindow.close() from Main.py
self.close()
Main.py
class Form(QWidget):
def __init__(self, user, parent=None, loginWindow=None):
super(Form, self).__init__(parent)
# etc...

Categories

Resources