Skip to content

Instantly share code, notes, and snippets.

@june9713
Created May 3, 2020 19:10
Show Gist options
  • Save june9713/dcb2711b828ebb90c8978656409e4cac to your computer and use it in GitHub Desktop.
Save june9713/dcb2711b828ebb90c8978656409e4cac to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'untitled.ui'
#
# Created by: PyQt4 UI code generator 4.11.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Form(object):
def setupUi(self, Form):
self.Form = Form
Form.setObjectName(_fromUtf8("Form"))
Form.resize(939, 668)
self.TAB_OMR = QtGui.QTabWidget(Form)
self.TAB_OMR.setGeometry(QtCore.QRect(0, 70, 941, 591))
self.TAB_OMR.setObjectName(_fromUtf8("TAB_OMR"))
self.lbLogBase = QtGui.QLabel(Form)
self.lbLogBase.setStyleSheet(_fromUtf8("background-color: rgb(200, 160, 130);"))
self.lbLogBase.setGeometry(QtCore.QRect(30, 90, 541, 520))
self.lbLogBase.setObjectName(_fromUtf8("lbLogBase"))
self.textBrowserOMR = QtGui.QTextBrowser(self.lbLogBase)
self.textBrowserOMR.setStyleSheet(_fromUtf8("background-color: rgb(255, 255, 200);"))
self.textBrowserOMR.setGeometry(QtCore.QRect(10, 10, 520, 430))
self.textBrowserOMR.setObjectName(_fromUtf8("textBrowserOMR"))
self.pbSendLog = QtGui.QPushButton(self.lbLogBase)
self.pbSendLog.setGeometry(QtCore.QRect(300, 450, 191, 51))
self.pbSendLog.setObjectName(_fromUtf8("pbSendLog"))
self.lbLogo = QtGui.QLabel(Form)
self.lbLogo.setGeometry(QtCore.QRect(0, 0, 941, 61))
self.lbLogo.setObjectName(_fromUtf8("lbLogo"))
self.loginScreen = QtGui.QLabel(Form)
self.loginScreen.setGeometry(QtCore.QRect(0,0,939, 668))
self.loginScreen.setStyleSheet(_fromUtf8("background-color: rgba(255, 255, 255,255);"))
self.loginScreen.hide()
self.nameLael = QtGui.QLabel(self.loginScreen)
self.nameLael.setGeometry(QtCore.QRect(200, 300, 100, 31))
self.nameLael.setText("test1")
self.NameInput = QtGui.QLineEdit(self.loginScreen)
self.NameInput.setGeometry(QtCore.QRect(300, 300, 100, 31))
self.juminLael = QtGui.QLabel(self.loginScreen)
self.juminLael.setGeometry(QtCore.QRect(420, 300, 130, 31))
self.juminLael.setText("test2")
self.JuminInput = QtGui.QLineEdit(self.loginScreen)
self.JuminInput.setGeometry(QtCore.QRect(530, 300, 100, 31))
self.academyNameLabel = QtGui.QLabel(self.loginScreen)
self.academyNameLabel.setGeometry(QtCore.QRect(640, 300, 100, 31))
self.academyNameLabel.setText("test3")
self.academyNameInput = QtGui.QLineEdit(self.loginScreen)
self.academyNameInput.setGeometry(QtCore.QRect(750, 300, 100, 31))
self.pushButton_5 = QtGui.QPushButton(self.loginScreen)
self.pushButton_5.setGeometry(QtCore.QRect(470, 350, 100, 31))
Form.resize(1200, 800)
################ This Is Magic Code!!!!!!!!!######################################################
self.initObjs = ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__self.Format__', '__ge__',
'__getattribute__', '__gt__', '__hash__', '__init__', '__le__', '__lt__', '__module__', '__ne__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__',
'__weakref__', 'setupUi','tab_2' , 'tab_3', 'tab']
self.objs = {}
for oi , obj in enumerate(dir(self)):
o = eval("self."+obj)
if obj not in self.initObjs:
if obj != 'Form':
if str(type(o)) != "<class 'method'>" and type(o)!= list and type(o)!=tuple and type(o)!=dict and type(o)!=str:
if "PyQt4" in str(type(o)):
if "setGeometry" in dir(o):
if "QTabWidget" not in str(o.parent().parent()):
self.objs[oi] = {}
self.objs[oi]["obj"] = o
try:
self.objs[oi]["font"] = o.font()
except:
self.objs[oi]["font"] = None
try:
self.objs[oi]["fontSize"] = o.font().pointSize()
except:
self.objs[oi]["fontSize"] = None
try:
self.objs[oi]["geo"] = o.geometry()
except:
self.objs[oi]["geo"] = None
################ This Is End Of Magic Code!!!!!!!!!######################################################
def resizeEvent(self,event):
wr = self.Form.size().width()/939
hr = self.Form.size().height()/668
for obji , obj in enumerate(self.objs):
if self.objs[obj]["geo"]:
x = self.objs[obj]["geo"].x()*wr
w = self.objs[obj]["geo"].width()*wr
y = self.objs[obj]["geo"].y()*hr
h = self.objs[obj]["geo"].height()*hr
self.objs[obj]['obj'].setGeometry((QtCore.QRect(x, y, w, h)))
if self.objs[obj]["fontSize"] and self.objs[obj]["font"]:
font = self.objs[obj]["font"]
pSize = self.objs[obj]["fontSize"]
if pSize < 1:
pSize = 1
if wr > hr:
font.setPointSize(pSize*hr)
else:
font.setPointSize(pSize*wr)
self.objs[obj]['obj'].setFont(font)
if "imgPath" in dir(self.objs[obj]['obj']):
pixmap = QtGui.QPixmap("./datas/background.png")
tmp = pixmap.scaled(w, h)
self.objs[obj]['obj'].setPixmap(tmp)
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
Form = QtGui.QWidget()
ui = Ui_Form()
ui.setupUi(Form)
################ This Is Magic Code!!!!!!!!!######################################################
Form.resizeEvent = ui.resizeEvent
################ This Is End Of Magic Code!!!!!!!!!######################################################
Form.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment