Merhabalar
Python üzerinden geliştirdiğim uygulamada açılış esnasında kısa bir resim İntrosu koymak istiyorum…Resim birkaç saniye ekranda kaldıktan sonra yapmış olduğum uyglama açılacak…Değerli fikirlerinizi için şimdiden teşekkür ederim.
İyi çalışmalar dilerim…
İki pencere oluşturup ilkni çalıştırıp sonra istenilen süre sonrasında onu kapatıp ana pencereyi gösterebilirsiniz
Böyle birşey iş görür …
import sys
from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtGui import QPixmap
from PyQt5.QtWidgets import (QApplication, QDialog, QLabel, QMainWindow,
QPushButton, QVBoxLayout, QWidget)
class AnaPencere(QMainWindow):
def __init__(self):
super().__init__()
self.setCentralWidget(QPushButton("Ana pencere"))
self.setMinimumSize(400,400)
class Intro(QDialog):
def __init__(self):
super().__init__()
self.setWindowFlags( Qt.CustomizeWindowHint)
lbl = QLabel()
lbl.setPixmap(QPixmap("1.png"))#Buraya resim
box = QVBoxLayout()
box.addWidget(lbl)
self.timer = QTimer()
self.timer.timeout.connect(self.kapat)
self.timer.start(5000) # İntronun Çalışacağı süre
self.setLayout(box)
self.exec()
def kapat(self):
self.timer.stop()
self.close()
app = QApplication(sys.argv)
intro = Intro()
ana = AnaPencere()
ana.show()
sys.exit(app.exec_())
1 Beğeni
Teşekkür ederim tam istediğim yanıt oldu:)
1 Beğeni
Eğer İntro resmin kenarları ayrıntı içeriyor yani KARE bir şekil değilse :
İntro pencere arkaplan transparan yapmak için:
self.setAttribute(Qt.WA_TranslucentBackground, 60) #İnro Penceresinin altını Transparan yapar
Resmin yerleştiği QLabel öğesinin arkaplan transparan yapmak için :
lbl.setStyleSheet("background-color:rgba(0, 0, 0, 0.05);") # resim dosyasının altındaki Label background transparan yapar
Genel anlamda :
import sys
from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtGui import QPixmap,QPalette
from PyQt5.QtWidgets import (QApplication, QDialog, QLabel, QMainWindow,
QPushButton, QVBoxLayout, QWidget)
class AnaPencere(QMainWindow):
def __init__(self):
super().__init__()
self.setCentralWidget(QPushButton("Ana pencere"))
self.setMinimumSize(400,400)
class Intro(QDialog):
def __init__(self):
super().__init__()
self.setWindowFlags( Qt.CustomizeWindowHint)
self.setStyleSheet("background-color:rgba(0, 0, 0, 0.5);opacity: 0.5;")
self.setAttribute(Qt.WA_TranslucentBackground, 60) #İnro Penceresinin altını Transparan yapar
lbl = QLabel()
lbl.setStyleSheet("background-color:rgba(0, 0, 0, 0.05);") # resim dosyasının altındaki Label background transparan yapar
lbl.setPixmap(QPixmap("2.png"))#Buraya resim
box = QVBoxLayout()
box.addWidget(lbl)
self.timer = QTimer()
self.timer.timeout.connect(self.baslat)
self.timer.start(2000) # İntronun Çalışacağı süre
self.setLayout(box)
self.exec()
def baslat(self):
self.timer.stop()
self.close()
app = QApplication(sys.argv)
intro = Intro()
ana = AnaPencere()
ana.show()
sys.exit(app.exec_())
Şu kod görsel açıdan daha güzel gözüküyor …
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
class Form(QDialog):
""" Just a simple dialog with a couple of widgets
"""
def __init__(self, parent=None):
super(Form, self).__init__(parent)
self.browser = QTextBrowser()
self.setWindowTitle('Just a dialog')
self.lineedit = QLineEdit("Write something and press Enter")
self.lineedit.selectAll()
layout = QVBoxLayout()
layout.addWidget(self.browser)
layout.addWidget(self.lineedit)
self.setLayout(layout)
self.lineedit.setFocus()
self.lineedit.returnPressed.connect(self.update_ui)
def update_ui(self):
self.browser.append(self.lineedit.text())
if __name__ == "__main__":
import sys, time
app = QApplication(sys.argv)
# Create and display the splash screen
splash_pix = QPixmap('debian.png')
splash = QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
splash.setMask(splash_pix.mask())
splash.show()
app.processEvents()
# Simulate something that takes time
time.sleep(2)
form = Form()
form.show()
splash.finish(form)
app.exec_()
Örenek bir resim
2 Beğeni