【发布时间】:2019-05-27 08:33:00
【问题描述】:
我不知道为什么,但我无法使用 Pyside2 移动按钮。
我命名了一个按钮 Lina,并尝试使用:
self.__ButtonLina.move(400,400)
但它不起作用,也许我将这行放在代码中的错误位置?
代码如下:(Lina 的按钮在最后一个标签中)
# -*- coding: utf-8 -*-
import sys
from PySide2 import QtCore, QtGui
from PySide2.QtWidgets import *
from PySide2.QtGui import *
# orange Continental rgb(255, 128, 0)
class Dialog(QDialog):
def __init__(self, parent=None):
QDialog.__init__(self,parent)
# Les champs
self.__champTexteNomAuteur = QLineEdit("")
self.__champTextePrenomAuteur = QLineEdit("")
self.__champDateNaissanceAuteur = QDateEdit()
self.__champDateNaissanceAuteur.setCalendarPopup(True)
self.__champTexteTitreLivre = QLineEdit("")
self.__champDatePublication = QDateEdit()
self.__champDatePublication.setCalendarPopup(True)
self.__ButtonLina = QPushButton("Lina")
self.__ButtonLina.setMaximumWidth(145)
self.__ButtonLina.move(400,400)#------<----here is the problem
self.__ButtonLina.setStyleSheet("background-color: rgb(255, 128, 0);")
# Les widgets
self.__widgetAuteur = QWidget()
self.__widgetLivre = QWidget()
self.__widget1 = QWidget()
self.__widget2 = QWidget()
self.__Tools = QWidget()
self.__widget1.setStyleSheet("background-color: black;");
# Les layouts des onglets
self.__layoutTools = QFormLayout()
self.__layoutTools.addRow(self.__ButtonLina)
self.__Tools.setLayout(self.__layoutTools)
self.__layoutAuteur = QFormLayout()
self.__widgetAuteur.setLayout(self.__layoutAuteur)
# La boîte à onglets
self.__tabWidget = QTabWidget()
self.__tabWidget.addTab(self.__widgetAuteur, " Single Simulation ")
self.__tabWidget.addTab(self.__widgetLivre, " Batch Simulation ")
self.__tabWidget.addTab(self.__widget1, " Vehicule Simulation Tool ")
self.__tabWidget.addTab(self.__widget2, " Simulation ")
self.__tabWidget.addTab(self.__Tools, " Tools ")
# Le layout final
self.__mainLayout = QVBoxLayout()
self.__mainLayout.addWidget(self.__tabWidget)
self.setLayout(self.__mainLayout)
self.resize(1200,800)
self.setWindowTitle('VSS Vehicule Simulation Suite')
self.setStyleSheet("color: black;"
"background-color: black");
app = QApplication(sys.argv)
dialog = Dialog()
dialog.exec_()
如果你有任何想法,它会很酷!
【问题讨论】:
标签: python python-2.7 pyside2