QSpinbox in QWizardPage gets initial focus even if its focus-policy is set to NoFocus - pyqt5

I create a QSpinBox in a QWizardPage. It get focus at the start of the wizardpage even when I set the focusPolicy to Qt.Nofocus.
What I set in Qt creator is:
But When the wizardpage start, I got:
Then, if I press Tab for several times, the focus will move between Finish and Cancel as expected.
I am using PyQt 5.15.6 on Windows 10. My python codes consists of a WizardPage.py file generated by pyuic5 and a test_wizard.py file.
WizardPage.py file :
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'wizardpage.ui'
#
# Created by: PyQt5 UI code generator 5.15.6
#
# 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_WizardPage(object):
def setupUi(self, WizardPage):
WizardPage.setObjectName("WizardPage")
WizardPage.resize(400, 300)
self.spinBox = QtWidgets.QSpinBox(WizardPage)
self.spinBox.setGeometry(QtCore.QRect(40, 50, 42, 22))
self.spinBox.setFocusPolicy(QtCore.Qt.NoFocus)
self.spinBox.setObjectName("spinBox")
self.retranslateUi(WizardPage)
QtCore.QMetaObject.connectSlotsByName(WizardPage)
def retranslateUi(self, WizardPage):
_translate = QtCore.QCoreApplication.translate
WizardPage.setWindowTitle(_translate("WizardPage", "WizardPage"))
test_wizard.py file:
from PyQt5 import QtCore, QtGui, QtWidgets
from WizardPage import *
from PyQt5.Qt import *
from PyQt5.QtCore import *
import sys
class test_wizard_page(QtWidgets.QWizardPage, Ui_WizardPage):
def __init__(self, parent):
super().__init__(parent)
self.setupUi(self)
class MyWizard(QtWidgets.QWizard):
def __init__(self):
super().__init__()
self.test_wizard_page = test_wizard_page(self)
# self.test_wizard_page.setE
self.addPage(self.test_wizard_page)
if __name__ == "__main__":
app = QApplication(sys.argv)
wizard = MyWizard()
wizard.show()
sys.exit(app.exec_())
And .ui file I create using the Qt Creator:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WizardPage</class>
<widget class="QWizardPage" name="WizardPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>WizardPage</string>
</property>
<widget class="QSpinBox" name="spinBox">
<property name="geometry">
<rect>
<x>40</x>
<y>50</y>
<width>42</width>
<height>22</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
This question may be related to my question. I also tried to reproduce their problem but fails with PyQt I currently uses. Is my question also a bug of Qt? And how can deal with this?

I can reproduce the behaviour, and it is still present in PyQt6. A work-around is to set the focus-policy on the line-edit of the spin-box (it isn't necessary to set it on spin-box as well). If you also want to restore the normal focus behaviour, it can be done using a single-shot timer:
class test_wizard_page(QtWidgets.QWizardPage, Ui_WizardPage):
def __init__(self, parent):
super().__init__(parent)
self.setupUi(self)
for spinbox in self.findChildren(QtWidgets.QSpinBox):
edit = spinbox.lineEdit()
policy = edit.focusPolicy()
edit.setFocusPolicy(QtCore.Qt.NoFocus)
QtCore.QTimer.singleShot(
0, lambda edit=edit, policy=policy:
edit.setFocusPolicy(policy))

Related

Qpushbutton in custom QlistWidgetItem doesn't respond when running on embedded device

I'm quite new to pyqt5 and applications on embedded devices, and was hoping someone may have any tips or suggestions on the problems I'm facing.
I am working with a pyqt5 appliaction where the widget contains a QListWidget and two buttons. I have made a seperate widget that I use as a customized QListWidgetItem. The customized QListWidgetItem contains a textfield and a QPushButton.
Everything works perfectly on Ubuntu on my computer, but when I deploy and run the app on an embedded device, the buttons in the customized QListWidgetItem no longer responds. The "normal" buttons, that are not in the customized QListWidgetItem, still works normally.
I can't find a reason or fixes for this, and am quite stuck..
Here's my code, very simplified:
Edit! After some feedback I've created a smaller representation of the app/problem, which hopefully can make it easier to debug.
I no longer use pyqtSignal between the classes, only connected the buttons to different functions directly.
In this case, both the printing and color changing will happen if the buttons respond correctly.
python file:
import sys
from CustomListItem import Ui_custom_list_widget
from CollectorWidget import Ui_collector_widget
from PyQt5.QtWidgets import QWidget, QListWidgetItem, QApplication, QStackedWidget, QMainWindow
def main():
app = QApplication(sys.argv)
stack = QStackedWidget()
collector = CollectorWidget()
stack.addWidget(collector)
stack.setCurrentWidget(collector)
stack.show()
sys.exit(app.exec_())
class CollectorWidget(Ui_collector_widget, QWidget):
temp_list_items = []
def __init__(self, parent=None):
super(CollectorWidget, self).__init__(parent)
self.setupUi(self)
self.create_item_button.clicked.connect(self.create_item_clicked)
self.another_button.clicked.connect(lambda: print("this one works"))
def create_item_clicked(self):
self.listItem = QListWidgetItem()
self.item = CustomListItem()
self.item.custom_item_button.clicked.connect(self.test_signal)
self.qlistwidget_list.addItem(self.listItem)
self.qlistwidget_list.setItemWidget(self.listItem, self.item)
self.temp_list_items.append((self.listItem, self.item))
def test_signal(self):
print("--------------IT'S WORKING!--------------------------")
class CustomListItem(Ui_custom_list_widget, QWidget):
def __init__(self):
super().__init__()
self.setupUi(self)
self.item_name.setText("testing testing")
self.custom_item_button.clicked.connect(self.button_clicked)
def setItemText(self, text):
self.item_name.setText(text)
def button_clicked(self):
self.item_name.setStyleSheet("background-color: red;")
if __name__ == "__main__":
main()
Ui files (collector):
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'CollectorWidget.ui'
#
# Created by: PyQt5 UI code generator 5.15.6
#
# 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_collector_widget(object):
def setupUi(self, collector_widget):
collector_widget.setObjectName("collector_widget")
collector_widget.resize(625, 514)
self.verticalLayout = QtWidgets.QVBoxLayout(collector_widget)
self.verticalLayout.setObjectName("verticalLayout")
self.qlistwidget_list = QtWidgets.QListWidget(collector_widget)
self.qlistwidget_list.setObjectName("qlistwidget_list")
self.verticalLayout.addWidget(self.qlistwidget_list)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.create_item_button = QtWidgets.QPushButton(collector_widget)
self.create_item_button.setObjectName("create_item_button")
self.horizontalLayout.addWidget(self.create_item_button)
self.another_button = QtWidgets.QPushButton(collector_widget)
self.another_button.setObjectName("another_button")
self.horizontalLayout.addWidget(self.another_button)
self.verticalLayout.addLayout(self.horizontalLayout)
self.retranslateUi(collector_widget)
QtCore.QMetaObject.connectSlotsByName(collector_widget)
def retranslateUi(self, collector_widget):
_translate = QtCore.QCoreApplication.translate
collector_widget.setWindowTitle(_translate("collector_widget", "Form"))
self.create_item_button.setText(_translate("collector_widget", "Create"))
self.another_button.setText(_translate("collector_widget", "Just a button"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
collector_widget = QtWidgets.QWidget()
ui = Ui_collector_widget()
ui.setupUi(collector_widget)
collector_widget.show()
sys.exit(app.exec_())
Ui files (custom_list_item):
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'CustomListItem.ui'
#
# Created by: PyQt5 UI code generator 5.15.6
#
# 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_custom_list_widget(object):
def setupUi(self, custom_list_widget):
custom_list_widget.setObjectName("custom_list_widget")
custom_list_widget.resize(608, 40)
self.horizontalLayout = QtWidgets.QHBoxLayout(custom_list_widget)
self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setObjectName("horizontalLayout")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.item_name = QtWidgets.QLabel(custom_list_widget)
font = QtGui.QFont()
font.setKerning(True)
self.item_name.setFont(font)
self.item_name.setStyleSheet("")
self.item_name.setWordWrap(True)
self.item_name.setObjectName("item_name")
self.horizontalLayout_2.addWidget(self.item_name)
self.custom_item_button = QtWidgets.QPushButton(custom_list_widget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.custom_item_button.sizePolicy().hasHeightForWidth())
self.custom_item_button.setSizePolicy(sizePolicy)
self.custom_item_button.setMaximumSize(QtCore.QSize(20, 20))
self.custom_item_button.setStyleSheet("")
self.custom_item_button.setText("")
self.custom_item_button.setObjectName("custom_item_button")
self.horizontalLayout_2.addWidget(self.custom_item_button)
self.horizontalLayout.addLayout(self.horizontalLayout_2)
self.retranslateUi(custom_list_widget)
QtCore.QMetaObject.connectSlotsByName(custom_list_widget)
def retranslateUi(self, custom_list_widget):
_translate = QtCore.QCoreApplication.translate
custom_list_widget.setWindowTitle(_translate("custom_list_widget", "Form"))
self.item_name.setText(_translate("custom_list_widget", "TextLabel"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
custom_list_widget = QtWidgets.QWidget()
ui = Ui_custom_list_widget()
ui.setupUi(custom_list_widget)
custom_list_widget.show()
sys.exit(app.exec_())
Picture of app:

Is there a way to use retreanslateUi in python code while the function being described in .ui file?

I'm creating a multilanguage desktop app using Qt Designer and PyQt5. I'm following this answer to make my app change languages dynamically.
I've created a .ui file via Qt Designer and I'm loading the UI directly in python code via loadUi. Therefore, the function retranslateUi is described in my ui.file unlike the retranslateUi function in link above (it is present in python code). I wouldn't like to put the described function in python code because there's a lot buttons and labels. How can I use this function in my code and to keep it only in .ui file?
uic.loadUi
If you use the loadUi method it doesn't implement the retranslateUi method so if you use that method then the solution is the same as the previous post.
demo.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Demo</class>
<widget class="QWidget" name="Demo">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>102</width>
<height>108</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QComboBox" name="combo"/>
</item>
<item>
<widget class="QPushButton" name="button">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Hello, World</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
main.py
import sys
from PyQt5 import QtCore, QtGui, QtWidgets, uic
class Demo(QtWidgets.QWidget):
def __init__(self):
super(Demo, self).__init__()
uic.loadUi("demo.ui", self)
self.combo.currentIndexChanged.connect(self.change_func)
self.trans = QtCore.QTranslator(self)
options = [
("English", ""),
("français", "eng-fr"),
("中文", "eng-chs"),
]
for i, (text, lang) in enumerate(options):
self.combo.addItem(text)
self.combo.setItemData(i, lang)
self.retranslateUi()
#QtCore.pyqtSlot(int)
def change_func(self, index):
data = self.combo.itemData(index)
if data:
self.trans.load(data)
QtWidgets.QApplication.instance().installTranslator(self.trans)
else:
QtWidgets.QApplication.instance().removeTranslator(self.trans)
def changeEvent(self, event):
if event.type() == QtCore.QEvent.LanguageChange:
self.retranslateUi()
super(Demo, self).changeEvent(event)
def retranslateUi(self):
self.button.setText(QtWidgets.QApplication.translate("Demo", "Start"))
self.label.setText(QtWidgets.QApplication.translate("Demo", "Hello, World"))
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
demo = Demo()
demo.show()
sys.exit(app.exec_())
Then generate the .ts:
pylupdate5 main.py -ts eng-chs.ts
pylupdate5 main.py -ts eng-fr.ts
Then use Qt Linguist to do the translations.
And finally the .qm:
lrelease eng-fr.ts eng-fr.qm
lrelease eng-chs.ts eng-chs.qm
pyuic
On the other hand, if you are using pyuic5 to convert the .py then if the retranslateUi method is implemented so you can use it:
pyuic5 demo.ui -o demo_ui.py
pylupdate5 demo_ui.py -ts eng-chs.ts
pylupdate5 demo_ui.py -ts eng-fr.ts
Then use Qt Linguist to do the translations.
And finally the .qm:
lrelease eng-fr.ts eng-fr.qm
lrelease eng-chs.ts eng-chs.qm
main.py
import sys
from PyQt5 import QtCore, QtGui, QtWidgets, uic
from demo_ui import Ui_Demo
class Demo(QtWidgets.QWidget, Ui_Demo):
def __init__(self):
super(Demo, self).__init__()
self.setupUi(self)
self.combo.currentIndexChanged.connect(self.change_func)
self.trans = QtCore.QTranslator(self)
options = [
("English", ""),
("français", "eng-fr"),
("中文", "eng-chs"),
]
for i, (text, lang) in enumerate(options):
self.combo.addItem(text)
self.combo.setItemData(i, lang)
self.retranslateUi(self)
#QtCore.pyqtSlot(int)
def change_func(self, index):
data = self.combo.itemData(index)
if data:
self.trans.load(data)
QtWidgets.QApplication.instance().installTranslator(self.trans)
else:
QtWidgets.QApplication.instance().removeTranslator(self.trans)
def changeEvent(self, event):
if event.type() == QtCore.QEvent.LanguageChange:
self.retranslateUi(self)
super(Demo, self).changeEvent(event)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
demo = Demo()
demo.show()
sys.exit(app.exec_())

Insert qtpynodeeditor in main window pyside2

I want to use node editor in pyside2, i got the library qtpynodeeditor (https://pypi.org/project/qtpynodeeditor/). I am not able to insert inside to my main window.
I am able to display separately, Left window is node editor right is main window.
MainWindow_UI.py
# -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'ListViewForNodeEditor_UI.ui'
##
## Created by: Qt User Interface Compiler version 5.14.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint,
QRect, QSize, QUrl, Qt)
from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont,
QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap,
QRadialGradient)
from PySide2.QtWidgets import *
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
self.verticalLayout = QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName(u"verticalLayout")
self.graphicsView = QGraphicsView(self.centralwidget)
self.graphicsView.setObjectName(u"graphicsView")
self.verticalLayout.addWidget(self.graphicsView)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(MainWindow)
self.menubar.setObjectName(u"menubar")
self.menubar.setGeometry(QRect(0, 0, 800, 21))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QStatusBar(MainWindow)
self.statusbar.setObjectName(u"statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QMetaObject.connectSlotsByName(MainWindow)
# setupUi
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
# retranslateUi
NodeEditor.py
from ListViewForNodeEditor_UI import Ui_MainWindow
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PySide2.QtCore import *
import qdarkstyle
import qtpynodeeditor as nodeeditor
class testNode(QMainWindow):
def __init__(self, parent=None):
super(testNode, self).__init__(parent)
self.Wui = Ui_MainWindow()
self.Wui.setupUi(self)
#Shows the Node Editor
registry = nodeeditor.DataModelRegistry()
scene = nodeeditor.FlowScene(registry=registry)
self.view = nodeeditor.FlowView(scene)
self.view.show()
if __name__=="__main__":
import sys
app = QApplication(sys.argv)
dark_stylesheet = qdarkstyle.load_stylesheet_pyside2()
app.setStyleSheet(dark_stylesheet)
w = testNode()
w.show()
sys.exit(app.exec_())
any alternative node editor for pyside2 much appreciated.
You are showing the FlowView as a separate widget.
If you change the line
self.view.show()
to
self.Wui.verticalLayout.addWidget(self.view)
the FlowView will be added to your layout. See the Qt layout documentation for more information and examples.

How to embed an URxvt terminal in a Pyqt5 GUI?

I have constructed a GUI in QtChooser and the code for it is written in PyQt5. I have a total of 7 tabs in the GUI, each of which are defined in the QMainWindow class of my code. These definitions contain the codes for each TextEdit, LineEdit, PushButtons, RadioButtons, etc.
However, in one the the tabs, I want to embed an external terminal which will open when a particular PushButton is clicked within that tab. I was able to open the Urxvt terminal when the RadioButton is toggled. The issue I'm facing now is to open the terminal specifically in the area of the TextEdit. This is how the original GUI (built in the QtDesigner looks like. I need the terminal to open in the TextEdit below the Output label. But, this is how the terminal opens in the GUI when the code is run
This is a part of the updated code:
from PyQt5 import QtCore, QtGui, QtWidgets, uic
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QPushButton, QMessageBox, QAction
from PyQt5.QtCore import QDate, QTime, QDateTime, Qt
import sys
import platform
import os
import subprocess
import time
import re
import textwrap
class EmbTerminal(QtWidgets.QWidget):
def __init__(self, parent=None):
super(EmbTerminal, self).__init__()
self.process = QtCore.QProcess(self)
self.terminal = QtWidgets.QWidget(self)
layout = QtWidgets.QVBoxLayout(self)
layout.addWidget(self.terminal)
# Works also with urxvt:
self.process.start('urxvt',['-embed', str(int(self.winId())), '-bg', '#000000', '-fg', '#ffffff'])
self.setFixedSize(539, 308)
class Ui_Dialog(QtWidgets.QMainWindow):
def __init__(self):
super(Ui_Dialog, self).__init__()
#Load GUI from QT5 Designer
uic.loadUi("S1_mainwindow.ui", self)
def openTerminalCheckBox (self):
if self.openTerminalRMachineRadioButton.isChecked():
status = True
self.commandLineRemoteCommandRMachineLineEdit.setDisabled(True)
self.commandlineRemoteCommandRMachineLabel.setDisabled(True)
self.executeRemoteCommandRMachinePushButton.setDisabled(True)
self.remoteMachineOutputLabel.setText("Terminal")
self.outputRMachineTextEdit = QtWidgets.QTabWidget()
self.gridLayout_6.addWidget(self.outputRMachineTextEdit)
self.outputRMachineTextEdit.addTab(EmbTerminal(), "EmbTerminal")
else:
status = False
app = QtWidgets.QApplication(sys.argv) # Create an instance of QtWidgets.QApplication
window = Ui_Dialog()
main = mainWindow()
main.show() # Create an instance of our class
app.exec_()
I need to open the terminal specifically in the QTextEdit which is already been defined in that tab. Do you guys have any suggestions/input?

how to make multi window using pyqt5

everybody!
Here's what I'm trying to do:
First, I created a file called basic.ui with a pushbutton.
Press the pushbutton to set the path and select the picture file in the set path to want the picture to appear in a new window(another window).
Let me tell you about the part where I am having difficulty.
The command to blow up the file is executed. Selecting the file causes an error.
I wonder what the cause is the problem.
How do I get the picture to appear in a new window(another window) after pressing the button?????
MainActivity.python
import sys
try:
from PyQt5.QtCore import Qt, QT_VERSION_STR
from PyQt5.QtGui import QImage
from PyQt5.QtWidgets import QApplication, QFileDialog
except ImportError:
try:
from PyQt4.QtCore import Qt, QT_VERSION_STR
from PyQt4.QtGui import QImage, QApplication, QFileDialog
except ImportError:
raise ImportError("Requires PyQt5 or PyQt4.")
from QtImageViewer import QtImageViewer
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from PyQt5 import uic
from PyQt5.QtCore import pyqtSlot
class From(QtWidgets.QDialog):
def __init__(self, parent=None):
QtWidgets.QDialog.__init__(self, parent)
self.ui=uic.loadUi("basic.ui",self)
self.ui.show()
#pyqtSlot()
def add_number(self):
app = QApplication(sys.argv)
viewer=QtImageViewer()
fileName, dummy = QFileDialog.getOpenFileName(None, "Open image file...")
image = QImage(fileName)
viewer.setImage(image)
viewer.show()
sys.exit(app.exec_())
if __name__=='__main__':
app=QtWidgets.QApplication(sys.argv)
w=From()
sys.exit(app.exec())
Signals & Slots
Signals and slots are used for communication between objects. The signals and slots mechanism is a central feature of Qt and probably the part that differs most from the features provided by other frameworks. Signals and slots are made possible by Qt's meta-object system.
http://doc.qt.io/qt-5/signalsandslots.html
Try it:
import sys
from os import getcwd
from PyQt5 import QtWidgets
from PyQt5 import QtGui
from PyQt5 import uic
from PyQt5.QtCore import Qt, pyqtSlot
class From(QtWidgets.QDialog):
def __init__(self, parent=None):
super(From, self).__init__(parent)
self.ui=uic.loadUi("basic.ui",self)
self.ui.pushButton.clicked.connect(self.add_number) # +++
# ^^^^^^^^^^ vvvvvvvvvv
# <widget class="QPushButton" name="pushButton"> <---> "basic.ui"
self.ui.labelImagen = QtWidgets.QLabel()
self.ui.show()
#pyqtSlot()
def add_number(self):
fileName, dummy = QtWidgets.QFileDialog.getOpenFileName(
self, "Open image file...", getcwd(),
"Image (*.png *.jpg)",
options=QtWidgets.QFileDialog.Options())
if fileName:
pix = QtGui.QPixmap(fileName)
self.ui.labelImagen.setPixmap(pix)
self.ui.labelImagen.show()
if __name__=='__main__':
app=QtWidgets.QApplication(sys.argv)
w=From()
sys.exit(app.exec())