Skip to content

Instantly share code, notes, and snippets.

@lrmendiburo
Created July 2, 2020 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrmendiburo/5abc28a2756a252c04afc22808e49ac3 to your computer and use it in GitHub Desktop.
Save lrmendiburo/5abc28a2756a252c04afc22808e49ac3 to your computer and use it in GitHub Desktop.
Example in PyQT5
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/TestPyQt5.iml" filepath="$PROJECT_DIR$/.idea/TestPyQt5.iml" />
</modules>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="442970e4-31b9-426a-be4a-b8c3f6d7367d" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="ProjectId" id="1e6yR92Sxo3SUw8MSg1RnVrB09i" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\lrmendiburo\PycharmProjects\TestPyQt5" />
</key>
</component>
<component name="RunManager" selected="Python.aplicacionPrincipal">
<configuration name="aplicacionPrincipal (1)" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="TestPyQt5" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/aplicacionPrincipal.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="aplicacionPrincipal" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="TestPyQt5" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="C:\Users\lrmendiburo\PycharmProjects\TestPyQt5\aplicacionPrincipal.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="aplicacionVentana1" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="TestPyQt5" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/aplicacionVentana1.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="aplicacionVentana2" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="TestPyQt5" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/aplicacionVentana2.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<configuration name="test" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="TestPyQt5" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/test.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.aplicacionPrincipal" />
<item itemvalue="Python.test" />
<item itemvalue="Python.aplicacionPrincipal (1)" />
<item itemvalue="Python.aplicacionVentana2" />
<item itemvalue="Python.aplicacionVentana1" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="442970e4-31b9-426a-be4a-b8c3f6d7367d" name="Default Changelist" comment="" />
<created>1593656325616</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1593656325616</updated>
</task>
<servers />
</component>
<component name="WindowStateProjectService">
<state x="413" y="115" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1593704734734">
<screen x="0" y="0" width="1366" height="738" />
</state>
<state x="413" y="115" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog/0.0.1366.738/-1366.0.1366.738@0.0.1366.738" timestamp="1593704734734" />
<state x="438" y="71" key="#xdebugger.evaluate" timestamp="1593705459194">
<screen x="0" y="0" width="1366" height="738" />
</state>
<state x="438" y="71" key="#xdebugger.evaluate/0.0.1366.738/-1366.0.1366.738@0.0.1366.738" timestamp="1593705459194" />
<state x="463" y="123" key="FileChooserDialogImpl" timestamp="1593659423589">
<screen x="0" y="0" width="1366" height="738" />
</state>
<state x="463" y="123" key="FileChooserDialogImpl/0.0.1366.738/-1366.0.1366.738@0.0.1366.738" timestamp="1593659423589" />
<state width="1345" height="227" key="GridCell.Tab.0.bottom" timestamp="1593705727419">
<screen x="0" y="0" width="1366" height="738" />
</state>
<state width="1345" height="227" key="GridCell.Tab.0.bottom/0.0.1366.738/-1366.0.1366.738@0.0.1366.738" timestamp="1593705727419" />
<state width="1345" height="227" key="GridCell.Tab.0.center" timestamp="1593705727419">
<screen x="0" y="0" width="1366" height="738" />
</state>
<state width="1345" height="227" key="GridCell.Tab.0.center/0.0.1366.738/-1366.0.1366.738@0.0.1366.738" timestamp="1593705727419" />
<state width="1345" height="227" key="GridCell.Tab.0.left" timestamp="1593705727419">
<screen x="0" y="0" width="1366" height="738" />
</state>
<state width="1345" height="227" key="GridCell.Tab.0.left/0.0.1366.738/-1366.0.1366.738@0.0.1366.738" timestamp="1593705727419" />
<state width="1345" height="227" key="GridCell.Tab.0.right" timestamp="1593705727419">
<screen x="0" y="0" width="1366" height="738" />
</state>
<state width="1345" height="227" key="GridCell.Tab.0.right/0.0.1366.738/-1366.0.1366.738@0.0.1366.738" timestamp="1593705727419" />
<state width="1345" height="227" key="GridCell.Tab.1.bottom" timestamp="1593705727419">
<screen x="0" y="0" width="1366" height="738" />
</state>
<state width="1345" height="227" key="GridCell.Tab.1.bottom/0.0.1366.738/-1366.0.1366.738@0.0.1366.738" timestamp="1593705727419" />
<state width="1345" height="227" key="GridCell.Tab.1.center" timestamp="1593705727419">
<screen x="0" y="0" width="1366" height="738" />
</state>
<state width="1345" height="227" key="GridCell.Tab.1.center/0.0.1366.738/-1366.0.1366.738@0.0.1366.738" timestamp="1593705727419" />
<state width="1345" height="227" key="GridCell.Tab.1.left" timestamp="1593705727419">
<screen x="0" y="0" width="1366" height="738" />
</state>
<state width="1345" height="227" key="GridCell.Tab.1.left/0.0.1366.738/-1366.0.1366.738@0.0.1366.738" timestamp="1593705727419" />
<state width="1345" height="227" key="GridCell.Tab.1.right" timestamp="1593705727419">
<screen x="0" y="0" width="1366" height="738" />
</state>
<state width="1345" height="227" key="GridCell.Tab.1.right/0.0.1366.738/-1366.0.1366.738@0.0.1366.738" timestamp="1593705727419" />
</component>
</project>
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from main import *
import aplicacionVentana1
import aplicacionVentana2
class aplicacionPrincipal(QDialog):
def __init__(self):
super().__init__()
self.ventanaPrincipal = Ui_DialogMain()
self.ventanaPrincipal.setupUi(self)
self.ventanaPrincipal.btn_Ventana1.clicked.connect(self.mostrarVentana1)
self.ventanaPrincipal.btn_Ventana2.clicked.connect(self.mostrarVentana2)
self.ventanaPrincipal.pushButton.clicked.connect(self.cerrar)
self.show()
def mostrarVentana1(self):
print("Abrir Ventana1")
aplicacionVentana1.ventana1.show()
def mostrarVentana2(self):
print("Abrir Ventana2")
aplicacionVentana2.ventana2.show()
def cerrar(self):
print("Cerrar Ventana")
sys.exit()
if __name__ == '__main__':
app = QApplication(sys.argv)
ventanaPrincipal = aplicacionPrincipal()
ventanaPrincipal.show()
sys.exit(app.exec_())
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from ventana1 import *
class aplicacionVentana1(QDialog):
def __init__(self):
super().__init__()
self.ventana1 = Ui_DialogVentana1()
self.ventana1.setupUi(self)
self.ventana1.pushButton.clicked.connect(self.volver)
def volver(self):
print("Volviendo desde la ventana 1")
self.close()
app = QApplication(sys.argv)
ventana1 = aplicacionVentana1()
import sys
from PyQt5.QtWidgets import QDialog, QApplication
from ventana2 import *
class aplicacionVentana2(QDialog):
def __init__(self):
super().__init__()
self.ventana2 = Ui_DialogVentana2()
self.ventana2.setupUi(self)
self.ventana2.pushButton.clicked.connect(self.volver)
def volver(self):
print("Volviendo desde la ventana 2")
self.close()
app = QApplication(sys.argv)
ventana2 = aplicacionVentana2()
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'main.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# 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_DialogMain(object):
def setupUi(self, DialogMain):
DialogMain.setObjectName("DialogMain")
DialogMain.resize(180, 161)
self.lbl_Saludo = QtWidgets.QLabel(DialogMain)
self.lbl_Saludo.setGeometry(QtCore.QRect(10, 10, 111, 21))
self.lbl_Saludo.setObjectName("lbl_Saludo")
self.btn_Ventana1 = QtWidgets.QPushButton(DialogMain)
self.btn_Ventana1.setGeometry(QtCore.QRect(50, 40, 75, 23))
self.btn_Ventana1.setObjectName("btn_Ventana1")
self.btn_Ventana2 = QtWidgets.QPushButton(DialogMain)
self.btn_Ventana2.setGeometry(QtCore.QRect(50, 80, 75, 23))
self.btn_Ventana2.setObjectName("btn_Ventana2")
self.pushButton = QtWidgets.QPushButton(DialogMain)
self.pushButton.setGeometry(QtCore.QRect(50, 120, 75, 23))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(DialogMain)
QtCore.QMetaObject.connectSlotsByName(DialogMain)
def retranslateUi(self, DialogMain):
_translate = QtCore.QCoreApplication.translate
DialogMain.setWindowTitle(_translate("DialogMain", "Main"))
self.lbl_Saludo.setText(_translate("DialogMain", "Selecciona la ventana:"))
self.btn_Ventana1.setText(_translate("DialogMain", "Ventana1"))
self.btn_Ventana2.setText(_translate("DialogMain", "Ventana2"))
self.pushButton.setText(_translate("DialogMain", "Cerrar"))
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogMain</class>
<widget class="QDialog" name="DialogMain">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>180</width>
<height>161</height>
</rect>
</property>
<property name="windowTitle">
<string>Main</string>
</property>
<widget class="QLabel" name="lbl_Saludo">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Selecciona la ventana:</string>
</property>
</widget>
<widget class="QPushButton" name="btn_Ventana1">
<property name="geometry">
<rect>
<x>50</x>
<y>40</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Ventana1</string>
</property>
</widget>
<widget class="QPushButton" name="btn_Ventana2">
<property name="geometry">
<rect>
<x>50</x>
<y>80</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Ventana2</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>50</x>
<y>120</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>Cerrar</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ventana1.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# 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_DialogVentana1(object):
def setupUi(self, DialogVentana1):
DialogVentana1.setObjectName("DialogVentana1")
DialogVentana1.resize(320, 84)
self.label = QtWidgets.QLabel(DialogVentana1)
self.label.setGeometry(QtCore.QRect(10, 10, 141, 16))
self.label.setObjectName("label")
self.pushButton = QtWidgets.QPushButton(DialogVentana1)
self.pushButton.setGeometry(QtCore.QRect(120, 40, 75, 23))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(DialogVentana1)
QtCore.QMetaObject.connectSlotsByName(DialogVentana1)
def retranslateUi(self, DialogVentana1):
_translate = QtCore.QCoreApplication.translate
DialogVentana1.setWindowTitle(_translate("DialogVentana1", "Ventana1"))
self.label.setText(_translate("DialogVentana1", "Esta es la ventana numero 1:"))
self.pushButton.setText(_translate("DialogVentana1", "<< Volver"))
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogVentana1</class>
<widget class="QDialog" name="DialogVentana1">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>320</width>
<height>84</height>
</rect>
</property>
<property name="windowTitle">
<string>Ventana1</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>141</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Esta es la ventana numero 1:</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>120</x>
<y>40</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>&lt;&lt; Volver</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ventana2.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# 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_DialogVentana2(object):
def setupUi(self, DialogVentana2):
DialogVentana2.setObjectName("DialogVentana2")
DialogVentana2.resize(320, 88)
self.label = QtWidgets.QLabel(DialogVentana2)
self.label.setGeometry(QtCore.QRect(10, 10, 151, 16))
self.label.setObjectName("label")
self.pushButton = QtWidgets.QPushButton(DialogVentana2)
self.pushButton.setGeometry(QtCore.QRect(120, 40, 75, 23))
self.pushButton.setObjectName("pushButton")
self.retranslateUi(DialogVentana2)
QtCore.QMetaObject.connectSlotsByName(DialogVentana2)
def retranslateUi(self, DialogVentana2):
_translate = QtCore.QCoreApplication.translate
DialogVentana2.setWindowTitle(_translate("DialogVentana2", "Ventana2"))
self.label.setText(_translate("DialogVentana2", "Esta es la ventana numero 2:"))
self.pushButton.setText(_translate("DialogVentana2", "<< Volver"))
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogVentana2</class>
<widget class="QDialog" name="DialogVentana2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>320</width>
<height>88</height>
</rect>
</property>
<property name="windowTitle">
<string>Ventana2</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>151</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>Esta es la ventana numero 2:</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>120</x>
<y>40</y>
<width>75</width>
<height>23</height>
</rect>
</property>
<property name="text">
<string>&lt;&lt; Volver</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment