Skip to content

Commit 2d9c565

Browse files
committed
Préparation d'un binaire pour Linux
1 parent 60be463 commit 2d9c565

4 files changed

Lines changed: 98 additions & 9 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
.lprof/
2+
build/
3+
dist/

image/splash_screen.png

58.9 KB
Loading

main.py

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from PyQt6 import QtWidgets
88
from PyQt6.QtGui import QPixmap, QColor, QPalette, QIcon, QPainter
99
from PyQt6.QtCore import Qt, QObject, QSize, QEvent, pyqtSignal, QPropertyAnimation, QEasingCurve, QTimer, QThread
10-
from PyQt6.QtWidgets import QTableWidget, QMessageBox, QDialog, QLineEdit, QPushButton, QCheckBox, QTableWidgetItem, QApplication, QMainWindow, QStackedWidget, QVBoxLayout, QScrollArea, QWidget, QGridLayout, QToolButton, QSplitter, QHBoxLayout, QLabel
10+
from PyQt6.QtWidgets import QProgressBar, QSplashScreen, QMessageBox, QDialog, QLineEdit, QPushButton, QCheckBox, QTableWidgetItem, QApplication, QMainWindow, QStackedWidget, QVBoxLayout, QScrollArea, QWidget, QGridLayout, QToolButton, QSplitter, QHBoxLayout, QLabel
1111
import vlc
1212
from io import BytesIO
1313
from functools import lru_cache
@@ -597,10 +597,20 @@ class SettingsDialog(QDialog):
597597
def __init__(self, config, parent=None):
598598
super().__init__(parent)
599599
self.setGeometry(400, 400, 400, 100)
600+
self.centerWindow()
600601
self.config = config
601602
self.setWindowTitle("Configuration")
602603
self.setup_ui()
603604

605+
def centerWindow(self):
606+
# Obtenir la taille de l'écran depuis l'application
607+
screen = QApplication.primaryScreen().geometry()
608+
windowSize = self.geometry() # Obtient la taille de la fenêtre courante
609+
# Calculer la position x et y pour centrer la fenêtre
610+
x = int((screen.width() - windowSize.width()) / 2)
611+
y = int((screen.height() - windowSize.height()) / 2)
612+
self.setGeometry(x, y, windowSize.width(), windowSize.height())
613+
604614
def setup_ui(self):
605615
layout = QVBoxLayout(self)
606616

@@ -650,6 +660,7 @@ def __init__(self):
650660

651661
self.setWindowTitle("App IPTV")
652662
self.setGeometry(100, 100, 1200, 800)
663+
self.centerWindow()
653664

654665
# Réglages et configurations
655666
self.config = load_config()
@@ -732,6 +743,15 @@ def __init__(self):
732743
self.initUI()
733744
self.setupClock()
734745

746+
def centerWindow(self):
747+
# Obtenir la taille de l'écran depuis l'application
748+
screen = QApplication.primaryScreen().geometry()
749+
windowSize = self.geometry() # Obtient la taille de la fenêtre courante
750+
# Calculer la position x et y pour centrer la fenêtre
751+
x = int((screen.width() - windowSize.width()) / 2)
752+
y = int((screen.height() - windowSize.height()) / 2)
753+
self.setGeometry(x, y, windowSize.width(), windowSize.height())
754+
735755
def setup_ui(self):
736756
# Bouton de configuration
737757
self.settings_button = QPushButton("⚙️")
@@ -1068,9 +1088,6 @@ def remove_epg_display_widget(self):
10681088
# Étape 4: Supprimer le widget
10691089
self.epg_table.deleteLater()
10701090
self.epg_table = None
1071-
1072-
# Nettoyer le layout qui contenait le widget si nécessaire
1073-
self.epg_table.widget().deleteLater()
10741091

10751092
def togglePlayPause(self):
10761093
if self.isPlaying:
@@ -1407,10 +1424,33 @@ def get_current_program(self, channel_uuid):
14071424

14081425
return program_name, program_desc, program_picture_url, program_start_date, program_duration
14091426

1410-
if __name__ == "__main__":
1411-
os.environ["QT_QPA_PLATFORM"] = "xcb"
1412-
app = QApplication([])
1413-
mainWindow = MainWindow()
1427+
class CustomSplashScreen(QSplashScreen):
1428+
def __init__(self, pixmap, *args, **kwargs):
1429+
super(CustomSplashScreen, self).__init__(pixmap, *args, **kwargs)
1430+
self.progressBar = QProgressBar(self)
1431+
self.progressBar.setGeometry(100, 350, 500, 20) # Ajuster la position et la taille
1432+
1433+
def setProgress(self, value):
1434+
self.progressBar.setValue(value)
1435+
QApplication.instance().processEvents()
1436+
1437+
def main():
1438+
app = QApplication(sys.argv)
1439+
splash_pix = QPixmap('./image/splash_screen.png')
1440+
splash = CustomSplashScreen(splash_pix)
1441+
splash.show()
1442+
1443+
# Simuler le chargement de l'application
1444+
for i in range(1, 101):
1445+
splash.setProgress(i)
1446+
time.sleep(0.03) # Simuler le temps de chargement
1447+
1448+
mainWindow = MainWindow() # Supposons que vous avez une fenêtre principale
14141449
mainWindow.show()
1450+
splash.finish(mainWindow)
14151451

1416-
app.exec()
1452+
sys.exit(app.exec())
1453+
1454+
if __name__ == '__main__':
1455+
os.environ["QT_QPA_PLATFORM"] = "xcb"
1456+
main()

main.spec

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
from PyInstaller.utils.hooks import collect_data_files
3+
from PyInstaller.utils.hooks import exec_statement
4+
5+
block_cipher = None # Ajout si nécessaire pour 'cipher' dans PYZ
6+
7+
a = Analysis(
8+
['main.py'],
9+
pathex=['.'],
10+
binaries=[],
11+
datas=[('./image/*', './image/'),
12+
('./logos/*', './logos/'),
13+
],
14+
hiddenimports=['vlc'],
15+
hookspath=[],
16+
hooksconfig={},
17+
runtime_hooks=[],
18+
excludes=[],
19+
noarchive=False
20+
)
21+
22+
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
23+
24+
exe = EXE(
25+
pyz,
26+
a.scripts,
27+
a.binaries,
28+
a.zipfiles,
29+
a.datas,
30+
[],
31+
name='APPIPTV',
32+
debug=False,
33+
bootloader_ignore_signals=False,
34+
strip=False,
35+
upx=True,
36+
upx_exclude=[],
37+
runtime_tmpdir=None,
38+
console=True, # Change to False if you do not want a console window
39+
disable_windowed_traceback=False,
40+
argv_emulation=False,
41+
target_arch=None,
42+
codesign_identity=None,
43+
entitlements_file=None,
44+
icon='image/missing_icon.png', # Chemin vers l'icône
45+
)
46+
47+

0 commit comments

Comments
 (0)