try:from pymxs import runtime as rt 
except:pass
if (rt.maxversion())[7] < 2026:
    from PySide2 import QtCore, QtGui
    from PySide2.QtWidgets import QApplication, QMainWindow, QTabWidget
else:
    from PySide6 import QtCore, QtGui
    from PySide6.QtWidgets import QApplication, QMainWindow, QTabWidget
from UploadProductImages import FileBrowserUI

kutuphaneYukle = False
try:
    import pandas as pd #excel dosyalarini okumak icin
    import UploadProduct
    from UploadProduct import mainDialog
    import importlib
    importlib.reload(UploadProduct)
except:
    kutuphaneYukle = True
    import pymxs
    rt = pymxs.runtime  # runtime nesnesi MaxScript ortamini temsil eder
    maxscript_code = """
        dosyayolu = (getdir #temp)+"\\InstallPandasCommand.bat"
        ss = ""
        ss += "\\""+(getdir #maxroot)+"\Python\python.exe\\" -m ensurepip \\n"
        ss += "\\""+(getdir #maxroot)+"\Python\python.exe\\" -m pip uninstall pandas numpy -y \\n"
        ss += "\\""+(getdir #maxroot)+"\Python\python.exe\\" -m pip install numpy==1.26.4 pandas==2.1.4 python-dateutil==2.8.2 pytz==2023.3.post1 \\n"
        ss += "\\""+(getdir #maxroot)+"\Python\python.exe\\" -m pip install openpyxl \\n"
        ss += "pause\n"
        encoding = (dotNetClass "System.Text.Encoding").GetEncoding 1252 -- Windows-1252: Western Europe ANSI (Ingilizce karakterler için standart)
        (dotnetclass "system.io.file").writealltext dosyayolu ss encoding
        ShellLaunch dosyayolu ""
    """
    try:rt.execute(maxscript_code)
    except:pass
    
class AnaPencere(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("JLSF Product Management")

        # Sekme widget'ı oluştur
        self.tabs = QTabWidget()
        self.setCentralWidget(self.tabs)

        # Sayfaları ekle
        self.tabs.addTab(mainDialog(), "Upload Product")
        self.tabs.addTab(FileBrowserUI(), "Upload Images")


if kutuphaneYukle == False and __name__ == "__main__":
    app = QApplication.instance()
    pencere = AnaPencere()
    pencere.show()
    screen = QApplication.primaryScreen()
    width = ((screen.size()).width())
    height = screen.size().height()
    pencere.resize(width/1.5, height/1.2)
    pencere.move((width-(width/1.5))/2,(height-(height/1.2))/4)
