def main_app(base_path, file, file_config): """Run the GUI of xBan The function initiates and resize the application """ app = QApplication(sys.argv) if hasattr(QStyleFactory, "AA_UseHighDpiPixmaps"): app.setAttribute(Qt.AA_UseHighDpiPixmaps) with open(os.path.join(base_path, "xBanStyle.css"), "r") as style_sheet: style = style_sheet.read() app.setWindowIcon(QIcon(os.path.join(base_path, "xBanUI.png"))) xBanApp = xBanWindow(base_path, file, file_config) xBanApp.setStyleSheet(style) # resize and move screen to center primary_screen = QGuiApplication.primaryScreen() if primary_screen: screen_size = primary_screen.availableSize() xBanApp.resize(screen_size.width() / 3, screen_size.height() / 2) xBanApp.move( (screen_size.width() - xBanApp.width()) / 2, (screen_size.height() - xBanApp.height()) / 2, ) app.setStyle("Fusion") sys.exit(app.exec_()) else: main_logger.error("Primary screen not found")
def initUI(self): # setup UI self.setWindowTitle("Taplist - Let's Beer Brewpub") # get screen width and height self.screen = QGuiApplication.primaryScreen().geometry() self.width = self.screen.width() self.height = self.screen.height() # set screen size self.resize(1920, 1080) # self.setMinimumWidth(800) self.layout = QGridLayout()
def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle('Qt DataVisualization 3D Bars') self.bars = Q3DBars() self.columnAxis = QCategory3DAxis() self.columnAxis.setTitle('Columns') self.columnAxis.setTitleVisible(True) self.columnAxis.setLabels(['Column1', 'Column2']) self.columnAxis.setLabelAutoRotation(30) self.rowAxis = QCategory3DAxis() self.rowAxis.setTitle('Rows') self.rowAxis.setTitleVisible(True) self.rowAxis.setLabels(['Row1', 'Row2']) self.rowAxis.setLabelAutoRotation(30) self.valueAxis = QValue3DAxis() self.valueAxis.setTitle('Values') self.valueAxis.setTitleVisible(True) self.valueAxis.setRange(0, 5) self.bars.setRowAxis(self.rowAxis) self.bars.setColumnAxis(self.columnAxis) self.bars.setValueAxis(self.valueAxis) self.series = QBar3DSeries() self.arrayData = [[1, 2], [3, 4]] self.series.dataProxy().addRows(dataToBarDataArray(self.arrayData)) self.bars.setPrimarySeries(self.series) self.container = QWidget.createWindowContainer(self.bars) if not self.bars.hasContext(): print("Couldn't initialize the OpenGL context.") sys.exit(-1) camera = self.bars.scene().activeCamera() camera.setYRotation(22.5) geometry = QGuiApplication.primaryScreen().geometry() size = geometry.height() * 3 / 4 self.container.setMinimumSize(size, size) self.container.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.container.setFocusPolicy(Qt.StrongFocus) self.setCentralWidget(self.container)
def initialize(self): screen = QGuiApplication.primaryScreen().size() size = screen.height() * 0.7 self.window = QMainWindow() self.window.setAutoFillBackground(True) self.window.setWindowFlag( PySide6.QtCore.Qt.WindowType.WindowMaximizeButtonHint, False) self.window.setWindowTitle('Chess') self.window.resize(size, size) self.window.move((screen.width() - self.window.width()) // 2, (screen.height() - self.window.height()) // 2) self.window.show() self.margin = 10 self.button_size = (size - 2 * self.margin) // 8
def __init__(self): QtWidgets.QMainWindow.__init__(self) Ui_MainWindow.__init__(self) self.userInfo = None self.setupUi(self) self.setWindowTitle("Waifu2x-Gui") self.msgForm = QtBubbleLabel(self) self.settingForm = QtSetting(self) self.settingForm.hide() self.settingForm.LoadSetting() self.aboutForm = QtAbout(self) self.img = QtImg() self.stackedWidget.addWidget(self.img) # self.resize(1000, 1000) self.menuabout.triggered.connect(self.OpenAbout) desktop = QGuiApplication.primaryScreen().geometry()
def update_device_pixel_ratio(self): # Using QGuiApplication::devicePixelRatio() gives too coarse values, # i.e.it directly jumps from 1.0 to 2.0. We want tighter control on # sizing, so we compute the exact ratio and use that. # TODO: make it possible to adapt to the dpi for the current screen dpi # instead of assuming that all of them use the same dpi which applies for # X11 but not for other systems. primary = QGuiApplication.primaryScreen() if primary: return dpi = primary.logicalDotsPerInchX() # Usual "default" is 96 dpi # that magic ratio follows the definition of "device independent pixel" by Microsoft self._device_pixel_patio = dpi / 96 self._changed_spacing.emit()
def __init__(self): super(Ruler, self).__init__() self.old_position = None # is used for dragging of the window self.setMinimumWidth(50) self.setMinimumHeight(50) # load the options self.data = Data() # main widget self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.constructContextMenu) self.setWindowTitle('Screen Ruler') self.resize(self.data.get('ruler_width'), self.data.get('ruler_height')) self.setMouseTracking(True) self.setAttribute(Qt.WA_TranslucentBackground, True) self.setGeometry( QStyle.alignedRect( Qt.LeftToRight, Qt.AlignCenter, self.size(), QGuiApplication.primaryScreen().availableGeometry())) windowFlags = Qt.CustomizeWindowHint | Qt.FramelessWindowHint leftResize = SizeGrip(self, True) rightResize = SizeGrip(self, False) self.left_resize = leftResize self.right_resize = rightResize if self.data.get('always_above'): windowFlags = windowFlags | Qt.WindowStaysOnTopHint self.setWindowFlags( windowFlags) # Turns off the default window title hints # initialize the secondary windows self.about_window = AboutWindow() self.options_window = OptionsWindow(self) if self.data.get('options_opened'): self.openOptions()
def center(self): qr = self.frameGeometry() cp = QGuiApplication.primaryScreen().availableGeometry().center() qr.moveCenter(cp) self.move(qr.topLeft())