Skip to content

Instantly share code, notes, and snippets.

@eyllanesc
Created December 26, 2017 04:24
Show Gist options
  • Save eyllanesc/01ef7eb60efc2554bb7bf69ef271b25c to your computer and use it in GitHub Desktop.
Save eyllanesc/01ef7eb60efc2554bb7bf69ef271b25c to your computer and use it in GitHub Desktop.
161947
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from PySide.QtCore import *
from PySide.QtGui import *
import json
js = """{
"fullwindow": {
"bottomOffset": 616,
"creationClass": "LayoutFrame",
"leftOffset": 0,
"rightOffset": 992,
"topOffset": 0
},
"button": {
"bottomOffset": 45,
"creationClass": "LayoutFrame",
"leftOffset": 0,
"rightOffset": 992,
"topOffset": 0
}
}"""
class UI(QDialog):
def __init__(self, *args, **kwargs):
super(UI, self).__init__(*args, **kwargs)
self.setWindowFlags(Qt.FramelessWindowHint)
self.data = json.loads(js)
self.getDimmensions()
button = QPushButton(self)
self.loadWidget(button, "button")
def getDimmensions(self):
fullwindow = self.data["fullwindow"]
self.sizeFullWindow = QSize(fullwindow["rightOffset"]-fullwindow["leftOffset"], fullwindow["bottomOffset"]-fullwindow["topOffset"])
def loadWidget(self, widget, id):
winfo = self.data[id]
rect = QRect()
rect.setBottom(winfo["bottomOffset"])
rect.setTop(winfo["topOffset"])
rect.setLeft(winfo["leftOffset"])
rect.setRight(winfo["rightOffset"])
widget.setGeometry(self.getRect(rect))
def getRect(self, rect):
screen_resolution = qApp.desktop().screenGeometry()
width = screen_resolution.width()
height = screen_resolution.height()
transform = QTransform()
transform.scale(width/self.sizeFullWindow.width(), height/self.sizeFullWindow.height())
return transform.mapRect(rect)
if __name__ == '__main__':
app = QApplication(sys.argv)
ui = UI()
ui.showFullScreen()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment