Estoy tratando de abrir una venta diferente desde mi ventana principal, esto al terminar de ejecutarse la funcion obetenerHostNmae()
.
Para lo cual hago una instancia de la clase CInicial()
y la mando a llamar con el metodo show()
sin embargo al hacer esto el programa se queda trabado y no hace nada mas:
Trate de hacerlo pero con la clase Contenedor()
ya que pense que esa seria la clase ala que habria que llamar pero tampoco funciono:
Esto intente con contenedor()
Contenedor(CInical).show()
No funciono
archivo1.py
from PyQt5.QtWidgets import QMainWindow,QApplication,QMessageBox
from PyQt5.QtCore import Qt,QTimer
from PyQt5 import uic,QtCore
import socket
import threading
from threading import Timer
import keyboard
from ConfigInicial import CInicial,Contenedor
class Hilo(threading.Thread):
def __init__(self,obj):
threading.Thread.__init__(self)
#self.text = text
self.obj = obj
def run(self):
Inicio.onError(self.obj,"Error", "errrrrror")
#QtCore.QMetaObject.invokeMethod(self.obj,'onError',
# QtCore.Qt.QueuedConnection,
# QtCore.Q_ARG(str,"Error"),
# QtCore.Q_ARG(str,'errorr'))
class Inicio(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
uic.loadUi("Inicio.ui",self)
self.timer = QTimer()
#Instancia de clases
self.Next1 = CInicial()
keyboard.add_hotkey('ctrl+s', lambda:Hilo(self).start())
self.setWindowFlags(Qt.FramelessWindowHint)
self.Lstatus.setText("Obteniendo Host...")
t = Timer(2, self.obetenerHostNmae)
t.start()
#@QtCore.pyqtSlot(str,str)
def onError(self,title,text):
QMessageBox.critical(None,title,text,QMessageBox.Ok)
def obetenerHostNmae(self):
solved = socket.gethostname()
self.Lstatus.setText(solved)
self.close()
self.Next1.show()
app = QApplication([])
i = Inicio()
i.show()
app.exec_()
archivo2.py
from PyQt5.QtWidgets import QMainWindow,QWidget,QVBoxLayout,QApplication,QGraphicsDropShadowEffect
from PyQt5 import QtCore,QtGui
from PyQt5.QtGui import QPainter,QColor
from PyQt5 import uic
class Contenedor(QWidget):
def __init__(self,window):
QWidget.__init__(self)
#self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
#self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
lay = QVBoxLayout(self)
lay.addWidget(window)
#lay.setContentsMargins(10,10,10,10)
shadow = QGraphicsDropShadowEffect(self)
shadow.setBlurRadius(9.9)
shadow.setColor(QColor(95,99,114))
shadow.setOffset(8,8)
#window.setGraphicsEffect(shadow)
class CInicial(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
#uic.loadUi("ConfiguracionInicial.ui",self)
app = QApplication([])
w = CInicial()
contenedor = Contenedor(w)
contenedor.resize(640,480)
contenedor.show()
app.exec_()
inicio.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>683</width>
<height>482</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="centralwidget">
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QFrame" name="frame">
<property name="geometry">
<rect>
<x>200</x>
<y>-1</y>
<width>485</width>
<height>484</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background:url(SD.jpg)</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QFrame" name="frame_4">
<property name="geometry">
<rect>
<x>0</x>
<y>462</y>
<width>681</width>
<height>20</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">background:none;
border:0px;
border-bottom:3px solid qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(54, 77, 185, 244), stop:1 rgba(42, 46, 48, 255));</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</widget>
<widget class="QFrame" name="frame_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>201</width>
<height>491</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">QFrame#frame_2{
background:#2a2e30;
}</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>130</y>
<width>161</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">
color:#4057A3;
color:#4253f4;</string>
</property>
<property name="text">
<string>School Admin</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>20</x>
<y>40</y>
<width>70</width>
<height>70</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>asd.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>4</x>
<y>464</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color:#4253F4;</string>
</property>
<property name="text">
<string>School Admin - v.0.0.1</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>20</x>
<y>150</y>
<width>161</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#4253F4;</string>
</property>
<property name="text">
<string>School administration system</string>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>20</x>
<y>190</y>
<width>131</width>
<height>16</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">QLabel#label_5{
color:#4253F4;
background:none;
border:none;
}</string>
</property>
<property name="text">
<string>Director's version</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QLabel" name="statusInicio">
<property name="geometry">
<rect>
<x>20</x>
<y>250</y>
<width>161</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#4253F4;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="Lstatus">
<property name="geometry">
<rect>
<x>20</x>
<y>230</y>
<width>161</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color:#4253F4;</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
<zorder>frame_2</zorder>
<zorder>frame</zorder>
</widget>
</widget>
<resources/>
<connections/>
</ui>