2021年3月23日星期二

How to create tablet interface

My question: How do I display the buttons on the top when RadioButton0 is enabled and when I press PushButton 1 ?

When you press the Radio button 0: * When I press Push button 0: I will see 3 buttons in the upper interface * When I press the Push button 1: I will see 5 buttons in the upper interface * When I press Push button 2: I will see 4 buttons in the upper interface

This is a result of the my code My code

Here is the result I want to get :

Result

Code: This is my attempt with him

from PyQt5 import QtCore, QtGui, QtWidgets from select_button import Ui_Form    import sys    class mainWidget(QtWidgets.QWidget) :      def __init__(self):          super().__init__()          self.ui = Ui_Form()          self.ui.setupUi(self)          self.ui.OK_PushButton.pressed.connect(self.lineEdit_Valus)          self.show()        def lineEdit_Valus(self):          self.radioButton = {}          l = 0          Nbre_RadioButtons = int(self.ui.lineEdit_RadioButton.text())          Nbre_Buttons = int(self.ui.lineEdit_PushButton.text())            for i in range(Nbre_RadioButtons):              self.radioButton[i]= Radio_Buttons(self.ui.frame_RadioButton)              self.radioButton[i].Push_Buttons(self.ui.frame_Button, Nbre_Buttons)              if i !=0 :                  l = l + 40                  self.radioButton[i].setGeometry(QtCore.QRect(l, 0, 30, 25))                self.radioButton[i].setMaximumSize(QtCore.QSize(30, 25))              self.radioButton[i].setMinimumSize(QtCore.QSize(30, 25))              self.radioButton[i].setObjectName("RadioButton" + str(i))              if i == 0 :                  self.radioButton[i].setChecked(True)              self.radioButton[i].show()      class Radio_Buttons(QtWidgets.QRadioButton):      def mousePressEvent(self, event):          if event.buttons() & QtCore.Qt.LeftButton:              print(self.objectName())              super().mousePressEvent(event)          def Push_Buttons(self,frame_Button,Nbre_Buttons):          self.button = {}          l = 0          for j in range(Nbre_Buttons) :              self.button[j] = MovableButton(frame_Button)              if j !=0 :                  l = l + 60                  self.button[j].setGeometry(QtCore.QRect(l, 0, 50, 50))                self.button[j].setMinimumSize(QtCore.QSize(50, 50))              self.button[j].setMaximumSize(QtCore.QSize(50, 50))              self.button[j].setObjectName("button"+ str(j))              self.button[j].setText(str(j))              self.button[j].show()    class MovableButton(QtWidgets.QPushButton):      def mousePressEvent(self, event):          if event.buttons() & QtCore.Qt.LeftButton:              super().mousePressEvent(event)              print(self.objectName())        if __name__ == "__main__" :      app = QtWidgets.QApplication(sys.argv)      Widget = mainWidget()      sys.exit(app.exec_())  
https://stackoverflow.com/questions/66767724/how-to-create-tablet-interface March 24, 2021 at 12:56AM

没有评论:

发表评论