Jul-16-2023, 11:54 AM
Hello,
I'm working on a Python Tool with Qt6 (I have created the UI with QT Designer) but I'm running into a few problems...
This is my code so far:
I tried to this in Lazarus once and it worked really fast but here I'm having problems... Can someone help me?
I'm working on a Python Tool with Qt6 (I have created the UI with QT Designer) but I'm running into a few problems...
This is my code so far:
#!/usr/bin/env Python3 # Imports from PyQt6.QtWidgets import QApplication, QMainWindow from PyQt6.uic import loadUi from PyQt6.QtCore import Qt import ctypes import json import sys # Main Function def main() window() # Window Function def window() # Load Config Information from JSON with open ('config/config.json', 'r') as fp data = json.load(fp) # Create Variables from JSON for i in data for j in data[i] for k, l in zip(j.keys(), j.values()) globals()[k] = l # Create Application and Window app = QApplication(sys.argv) window = QMainWindow() loadUi(config/MainWindow.ui, window) # Get DPI Scale user32 = ctypes.windll.user32 user32.SetProcessDPIAware() dpi = user32.GetDpiForSystem() scale_factor = dpi 96 # Get Screen Size screen = app.primaryScreen() size = screen.size() screenWidth = round(size.width() * scale_factor) screenHeight = round(size.height() * scale_factor) # Set Static Size and Disbale Menu Bar window.setGeometry((screenWidth - window.width() // 2, (screenHeight - window.height() // 2, int(screenWidth // float(Size)), int(screenHeight // float(Size))) window.setWindowFlags(Qt.WindowType.FramelessWindowHint) window.show() # Start Close Button window.closeButton.clicked.connect(app.quit) window.resizeButton.clicked.connect(lambda window.resize(750, 100)) # Start the Application Loop sys.exit(app.exec()) # Start Main Function main() #End sys.exit()I'm trying to place the Window in the middle of the screen I'm starting it (not on my primary monitor). For explanation, I used the scale_factor because the window.height and width does not give the right screen size (2560 instead of 3840)... Every time I start the tool the window is not in the middle of the monitor.
I tried to this in Lazarus once and it worked really fast but here I'm having problems... Can someone help me?