基于Dragonboard 410c的智能魔镜设计(8)——python脚本实现UI原型
在上一篇文章中,已经跟大家介绍如何智能魔镜的UI原型设计,并且采用designer.exe工具完成了原始的魔镜UI界面设计,可以看出,整个魔镜的UI设计非常简单,但是如果要实心较好的效果,我们单独使用designer.exe工具很难完成,这就需要我们在完成原型设计后得到的xml文件进行进一步的修改和细化,以达到我们的设计要求。
这里,大家可以直接修改designer.exe文件的xml的元素的属性等来调节和细化UI,同时也可以使用pyuic5工具将其转换成py脚本,然后对其进行修改,本文在设计中,直接使用pyuic5工具将其进行了转换,然后进行修改,最终得到的UI代码如下:
# -*- coding: utf-8 -*-
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
desktopRect=QtWidgets.QDesktopWidget().screenGeometry()
MainWindow.resize(desktopRect.width(), desktopRect.height())
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/images/icon"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
MainWindow.setWindowIcon(icon)
self.centralWidget = QtWidgets.QWidget(MainWindow)
self.centralWidget.setObjectName("centralWidget")
self.centralWidget.resize(357, 1059)
self.temp = QtWidgets.QLabel(self.centralWidget)
self.centralWidget.setGeometry(desktopRect.width()-self.centralWidget.width(),0,self.centralWidget.width(),self.centralWidget.height())
self.temp.setGeometry(QtCore.QRect(20, 60, 231, 100))
FONT = QtGui.QFont()
FONT.setFamily("楷体")
FONT.setPointSize(40)
FONT.setBold(False)
FONT.setWeight(50)
self.temp.setFont(FONT)
self.temp.setText("")
self.temp.setAlignment(QtCore.Qt.AlignCenter)
self.temp.setObjectName("temp")
self.city = QtWidgets.QLabel(self.centralWidget)
self.city.setGeometry(QtCore.QRect(50, 160, 150, 30))
FONT = QtGui.QFont()
FONT.setPointSize(13)
FONT.setBold(True)
FONT.setWeight(75)
self.city.setFont(FONT)
self.city.setText("")
self.city.setAlignment(QtCore.Qt.AlignCenter)
self.city.setObjectName("city")
self.date = QtWidgets.QLabel(self.centralWidget)
self.date.setGeometry(QtCore.QRect(30, 245, 211, 25))
FONT = QtGui.QFont()
FONT.setPointSize(10)
FONT.setBold(True)
FONT.setWeight(75)
self.date.setFont(FONT)
self.date.setText("")
self.date.setAlignment(QtCore.Qt.AlignCenter)
self.date.setObjectName("date")
self.closeButton = QtWidgets.QPushButton(self.centralWidget)
self.closeButton.setGeometry(QtCore.QRect(240, 5, 25, 25))
self.closeButton.setCursor(QtGui.QCursor(QtCore.Qt.PoinTIngHandCursor))
self.closeButton.setText("")
self.closeButton.setFlat(True)
self.closeButton.setObjectName("closeButton")
#self.layoutWidget = QtWidgets.QWidget(self.centralWidget)
self.layoutWidget = QtWidgets.QWidget(MainWindow)
self.layoutWidget.setGeometry(QtCore.QRect(0, desktopRect.height()-170, desktopRect.width(), 170))
self.layoutWidget.setObjectName("layoutWidget")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.layoutWidget)
self.horizontalLayout.setContentsMargins(11, 11, 11, 11)
self.horizontalLayout.setSpacing(6)
self.horizontalLayout.setObjectName("horizontalLayout")
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setContentsMargins(11, 11, 11, 11)
self.gridLayout.setSpacing(8)
self.gridLayout.setObjectName("gridLayout")
self.forecast_0_date = QtWidgets.QLabel(self.layoutWidget)
self.forecast_0_date.setMinimumSize(QtCore.QSize(80, 20))
self.forecast_0_date.setMaximumSize(QtCore.QSize(
DragonBoard 410c python XML 相关文章: