Quantcast
Channel: Preguntas activas con las etiquetas pyqt - Stack Overflow en español
Viewing all articles
Browse latest Browse all 77

Error en mi aplicación al tratar de cenrar el texto en mi aplicación hecha en PyQT

$
0
0

tengo un problema: cuando trato de usar QGridLayout, la etiqueta (label) no se centra y necesito que haga eso porque necesito hacer que se adapte al cambiar el tamaño de una ventana, y otro problema, cuando trato de importar un video en esa etiqueta, no funciona. ¿Me pueden ayudar por favor?Abajo tengo el código que tengo.Error que tengo

Gracias por su respuesta.

#Internal module(s)import osimport sysimport subprocessfrom colorama import Fore, Back, Style, initfrom time import sleepfrom PyQt5 import QtWidgets, QtMultimediaWidgets, QtGui, QtCorefrom PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QPushButton, QWidget, QMenu, QAction, QBoxLayout, QFrame, QFileDialog, QGridLayoutfrom PyQt5.QtMultimediaWidgets import QVideoWidgetfrom PyQt5.QtGui import *from PyQt5.QtCore import *#Modulesprint("Starting the application...")print("Importing modules...")from numpy import cbrtimport webbrowserinit()#Variables#No internal variables!#Window class and definitionsdef count_3secs_GRJT(timerInSeconds):    while timerInSeconds:        minutes, seconds = divmod(timerInSeconds, 60)        timerInThreeSecondsFmt = "{:2d}:{:02d}".format(minutes, seconds)        print("Exiting in:", timerInThreeSecondsFmt, end="\r")        sleep(1)        timerInSeconds -= 1    print(Back.BLUE + Fore.LIGHTWHITE_EX +"Program has been ended automatically by pressing the button and waiting some seconds." + Style.RESET_ALL)    sys.exit(0)class initializeAppGUIWindow(QMainWindow):    def __init__(self):        super().__init__()        print("Ready.")        #GUI window        self.resize(640, 480)        self.setMinimumWidth(640)        self.setMinimumHeight(360)        self.setMaximumWidth(1280)        self.setMaximumHeight(720)        self.setWindowTitle("A video playback window.")        gridLayoutApplication = QGridLayout(self)        self.setLayout(self.gridLayoutApplication)        self.videoPlaybackLabelApplication = QLabel("No video has been opened!")#       self.videoPlaybackLabelApplication.setAlignment(Qt.AlignCenter)        self.gridLayoutApplication.addWidget(self.videoPlaybackLabelApplication, 0, 0)#       frameApplication.setStyleSheet("background-color        videoItemWidgetApp = QVideoWidget()        openVideoApplication = QAction("&Open video", self)        openVideoApplication.setStatusTip("Open a video from your PC.\nAccepted formats are MP4, OGG and WEBM.")        openVideoApplication.triggered.connect(self.openAVideoDialog)        exitApplication = QAction("&Exit", self)        exitApplication.triggered.connect(self.mainButtonFunctionalityQuit)        menuApplicationBar = self.menuBar()        fileMenuApplicationBar = menuApplicationBar.addMenu("&File")        fileMenuApplicationBar.addAction(openVideoApplication)        fileMenuApplicationBar.addAction(exitApplication)    def mainButtonFunctionalityQuit(self):        print(Back. BLUE + Fore.LIGHTWHITE_EX +"Program has been ended by pressing the button." + Style.RESET_ALL)        sys.exit(0)    def openAVideoDialog(self):        importVideoDialog = QFileDialog.getOpenFileName(self, "Open a video", "", "MP4 Videos (*.mp4);;OGG Videos (*.ogg);;WEBM Videos (*.webm)")        if importVideoDialog != "":            self.videoItemWidgetApp.setMedia(QMediaContent(QUrl.fromLocalFile(importVideoDialog)))def mainButtonFunctionality1():    print(Back. BLUE + Fore.LIGHTWHITE_EX +"An URL has been opened by pressing the button." + Style.RESET_ALL)    webbrowser.open_new_tab("https://github.com/TheGitMpeg/Math-Calc-In-The-Console---0.28.6-BETA/tree/main/0.28.6.1%20Enhanced%20Beta")def mainButtonFunctionality2():    print(Back. BLUE + Fore.LIGHTWHITE_EX +"An URL has been opened and the program has been ended by pressing the button." + Style.RESET_ALL)    webbrowser.open_new_tab("https://github.com/TheGitMpeg/Math-Calc-In-The-Console---0.28.6-BETA/tree/main/0.28.6.1%20Enhanced%20Beta")    sys.exit(0)def mainButtonFunctionality3():    count_3secs_GRJT(3)    sys.exit(0)def mainButtonFunctionality4():    count_3secs_GRJT(5)    sys.exit(0)def main():    generalApplicationGUI = QApplication([])    applicationLoad = initializeAppGUIWindow()    applicationLoad.show()    sys.exit(generalApplicationGUI.exec_())try:    main()except IndexError:    print(Back.RED + Fore.LIGHTWHITE_EX +"Error! Something went wrong during or before running the application and/or doing an operation! Exiting..." + Style.RESET_ALL)    exit()

Lenguaje de programación usado: PythonMódulo usado para la aplicación: PyQT

Errores/dudas:

  1. ¿Cómo centrar la etiqueta (label) en una celda?
  2. Poner un video en una etiqueta (label)

Viewing all articles
Browse latest Browse all 77

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>