先上参考链接
画窗体
生成代码
考虑到使用的是WInPython的环境,先使用工具转化为py代码:
pyuic5 form.ui -o form.py
重载无边框、编辑拖动函数
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 24 10:28:23 2017
@author: yuxiang.li
"""
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QCursor
from PyQt5.QtWidgets import
import sys
from form import Ui_Form # 导入生成form.py里生成的类
class mywindow(QtWidgets.QWidget,Ui_Form):
def __init__(self):
super(mywindow,self).__init__()
self.setWindowFlags(Qt.FramelessWindowHint)
self.setupUi(self)
#定义槽函数
def CompressFpga(self):
return
def Lic(self):
return
#重载,使得可以拖拽
def mousePressEvent(self, event):
if event.button()==Qt.LeftButton:
self.m_drag=True
self.m_DragPosition=event.globalPos()-self.pos()
event.accept()
self.setCursor(QCursor(Qt.OpenHandCursor))
def mouseMoveEvent(self, QMouseEvent):
if Qt.LeftButton and self.m_drag:
self.move(QMouseEvent.globalPos()-self.m_DragPosition)
QMouseEvent.accept()
def mouseReleaseEvent(self, QMouseEvent):
self.m_drag=False
self.setCursor(QCursor(Qt.ArrowCursor))
app =QtWidgets.QApplication(sys.argv)
window = mywindow()
window.show()
sys.exit(app.exec_())