Есть код, сгенерированный с помощью QtDesigner
:
Я отключил рамку, но теперь окно не двигается мышкой, куда бы я не тыкал, как исправить?
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(259, 301)
Form.setStyleSheet("QWidget {\n"
" background-color: gray;\n"
"}")
Form.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(0, 0, 31, 21))
self.pushButton.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;")
self.pushButton.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(30, 0, 31, 21))
self.pushButton_2.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;")
self.pushButton_2.setObjectName("pushButton_2")
self.lineEdit = QtWidgets.QLineEdit(Form)
self.lineEdit.setGeometry(QtCore.QRect(20, 30, 221, 41))
self.lineEdit.setLayoutDirection(QtCore.Qt.LeftToRight)
self.lineEdit.setAutoFillBackground(False)
self.lineEdit.setStyleSheet("border: 1px solid orange;\n"
"background-color: white;\n"
"color: black;\n"
"font-size: 15px;\n"
"text-align: center;")
self.lineEdit.setInputMethodHints(QtCore.Qt.ImhNone)
self.lineEdit.setObjectName("lineEdit")
self.gridLayoutWidget = QtWidgets.QWidget(Form)
self.gridLayoutWidget.setGeometry(QtCore.QRect(20, 120, 221, 172))
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.pushButton_9 = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButton_9.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 50px;\n"
"height: 30px;")
self.pushButton_9.setObjectName("pushButton_9")
self.gridLayout.addWidget(self.pushButton_9, 2, 0, 1, 1)
self.pushButton_10 = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButton_10.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 50px;\n"
"height: 30px;")
self.pushButton_10.setObjectName("pushButton_10")
self.gridLayout.addWidget(self.pushButton_10, 2, 1, 1, 1)
self.pushButton_11 = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButton_11.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 50px;\n"
"height: 30px;")
self.pushButton_11.setObjectName("pushButton_11")
self.gridLayout.addWidget(self.pushButton_11, 2, 2, 1, 1)
self.pushButton_6 = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButton_6.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 50px;\n"
"height: 30px;")
self.pushButton_6.setObjectName("pushButton_6")
self.gridLayout.addWidget(self.pushButton_6, 1, 0, 1, 1)
self.pushButton_5 = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButton_5.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 50px;\n"
"height: 30px;")
self.pushButton_5.setObjectName("pushButton_5")
self.gridLayout.addWidget(self.pushButton_5, 0, 2, 1, 1)
self.pushButton_4 = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButton_4.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 50px;\n"
"height: 30px;")
self.pushButton_4.setObjectName("pushButton_4")
self.gridLayout.addWidget(self.pushButton_4, 0, 1, 1, 1)
self.pushButton_8 = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButton_8.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 50px;\n"
"height: 30px;")
self.pushButton_8.setObjectName("pushButton_8")
self.gridLayout.addWidget(self.pushButton_8, 1, 2, 1, 1)
self.pushButton_3 = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButton_3.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 50px;\n"
"height: 30px;")
self.pushButton_3.setObjectName("pushButton_3")
self.gridLayout.addWidget(self.pushButton_3, 0, 0, 1, 1)
self.pushButton_7 = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButton_7.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 50px;\n"
"height: 30px;")
self.pushButton_7.setObjectName("pushButton_7")
self.gridLayout.addWidget(self.pushButton_7, 1, 1, 1, 1)
self.pushButton_12 = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButton_12.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 50px;\n"
"height: 30px;")
self.pushButton_12.setObjectName("pushButton_12")
self.gridLayout.addWidget(self.pushButton_12, 3, 1, 1, 1)
self.pushButton_20 = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButton_20.setStyleSheet("background-color: silver;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 50px;\n"
"height: 30px;")
self.pushButton_20.setObjectName("pushButton_20")
self.gridLayout.addWidget(self.pushButton_20, 3, 0, 1, 1)
self.pushButton_19 = QtWidgets.QPushButton(self.gridLayoutWidget)
self.pushButton_19.setStyleSheet("background-color: silver;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 50px;\n"
"height: 30px;")
self.pushButton_19.setObjectName("pushButton_19")
self.gridLayout.addWidget(self.pushButton_19, 3, 2, 1, 1)
self.gridLayoutWidget_2 = QtWidgets.QWidget(Form)
self.gridLayoutWidget_2.setGeometry(QtCore.QRect(20, 70, 221, 40))
self.gridLayoutWidget_2.setObjectName("gridLayoutWidget_2")
self.gridLayout_2 = QtWidgets.QGridLayout(self.gridLayoutWidget_2)
self.gridLayout_2.setContentsMargins(0, 0, 0, 0)
self.gridLayout_2.setObjectName("gridLayout_2")
self.pushButton_15 = QtWidgets.QPushButton(self.gridLayoutWidget_2)
self.pushButton_15.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 30px;\n"
"height: 10px;")
self.pushButton_15.setObjectName("pushButton_15")
self.gridLayout_2.addWidget(self.pushButton_15, 0, 1, 1, 1)
self.pushButton_14 = QtWidgets.QPushButton(self.gridLayoutWidget_2)
self.pushButton_14.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 30px;\n"
"height: 10px;")
self.pushButton_14.setObjectName("pushButton_14")
self.gridLayout_2.addWidget(self.pushButton_14, 0, 0, 1, 1)
self.pushButton_17 = QtWidgets.QPushButton(self.gridLayoutWidget_2)
self.pushButton_17.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 30px;\n"
"height: 10px;")
self.pushButton_17.setObjectName("pushButton_17")
self.gridLayout_2.addWidget(self.pushButton_17, 0, 3, 1, 1)
self.pushButton_16 = QtWidgets.QPushButton(self.gridLayoutWidget_2)
self.pushButton_16.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;\n"
"weight: 30px;\n"
"height: 10px;")
self.pushButton_16.setObjectName("pushButton_16")
self.gridLayout_2.addWidget(self.pushButton_16, 0, 2, 1, 1)
self.pushButton_13 = QtWidgets.QPushButton(Form)
self.pushButton_13.setGeometry(QtCore.QRect(230, 0, 31, 21))
self.pushButton_13.setStyleSheet("background-color: orange;\n"
"color: white;\n"
"font-weight: bold;")
self.pushButton_13.setObjectName("pushButton_13")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.pushButton.setText(_translate("Form", "X"))
self.pushButton_2.setText(_translate("Form", "-"))
self.pushButton_9.setText(_translate("Form", "7"))
self.pushButton_10.setText(_translate("Form", "8"))
self.pushButton_11.setText(_translate("Form", "9"))
self.pushButton_6.setText(_translate("Form", "4"))
self.pushButton_5.setText(_translate("Form", "3"))
self.pushButton_4.setText(_translate("Form", "2"))
self.pushButton_8.setText(_translate("Form", "6"))
self.pushButton_3.setText(_translate("Form", "1"))
self.pushButton_7.setText(_translate("Form", "5"))
self.pushButton_12.setText(_translate("Form", "0"))
self.pushButton_20.setText(_translate("Form", "."))
self.pushButton_19.setText(_translate("Form", "="))
self.pushButton_15.setText(_translate("Form", "-"))
self.pushButton_14.setText(_translate("Form", "+"))
self.pushButton_17.setText(_translate("Form", "/"))
self.pushButton_16.setText(_translate("Form", "*"))
self.pushButton_13.setText(_translate("Form", "?"))
class Widget(QtWidgets.QWidget, Ui_Form):
def __init__(self, parent=None):
super(Widget, self).__init__(parent)
self.setupUi(self)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint) # !!!!!
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
w = Widget()
w.show()
sys.exit(app.exec_())