HI,
my gui has one horizontalbox layout, who has a left panel and a right panel.

I have wrote a function to populate the left panel with the widgets that I need. They are inside a verticalbox:

def rightPanel(self):
verticalboxRP=QVBoxLayout()
welcomeText = QLabel("Android Forensic Automator (AnForA)\n a software tool that automates the forensic analysis of Android applications", self)
verticalboxRP.addWidget(welcomeText)
self.setLayout(verticalboxRP)
self.show()

I have a similar function for the left panel.

Now the problem is: since I like to keep the creation of the left and right panel in separate functions, how can I use these functions in order to add them in the main gui who has a horizontal box layout.

My attempt to create the main window was something like this:

def UI(self):
horizontalbox=QHBoxLayout()
rightPanel(horizontalbox)
leftPanel(horizontalbox)

#horizontalbox.addLayout(lp)
#horizontalbox.addLayout(rp)

self.setLayout(horizontalbox)
self.show()

but, of course, I get error since I'm not very confident with pyqt and with python too (sorry).

Could you help me to figure out how can I manage a horizontal box who contains two vertical box layouts?
Below my signature, my current code.

Thanks.

Massimo
Qt Code:
  1. import sys
  2. from PyQt5.QtWidgets import *
  3. from PyQt5.QtGui import QPixmap
  4.  
  5. class Window(QWidget):
  6. def __init__(self):
  7. super().__init__()
  8. self.setWindowTitle("some text")
  9. #self.setGeometry(50,50,500,500) #if I want set the size
  10. self.UI()
  11.  
  12. def UI(self):
  13. horizontalbox=QHBoxLayout()
  14. rightPanel(horizontalbox)
  15. leftPanel(horizontalbox)
  16.  
  17. #horizontalbox.addLayout(lp)
  18. #horizontalbox.addLayout(rp)
  19.  
  20. self.setLayout(horizontalbox)
  21. self.show()
  22.  
  23.  
  24. def rightPanel(horizontalbox):
  25. verticalboxRP=QVBoxLayout()
  26. welcomeText = QLabel("some text", self)
  27. verticalboxRP.addWidget(welcomeText)
  28. self.setLayout(verticalboxRP)
  29.  
  30. #self.show()
  31.  
  32. def leftPanel(self):
  33. verticalboxLP=QVBoxLayout()
  34.  
  35. image = QLabel(self)
  36. image.setPixmap(QPixmap('logoUPO.png'))
  37. text = QLabel("AnForA\n Android Forensic Automator", self)
  38. installAPKBtn = QPushButton("Install APK on the device", self)
  39. detectPathBtn = QPushButton("Detect analysis paths", self)
  40. startExpBtn = QPushButton("Start experiment", self)
  41. analyzeResBtn = QPushButton("Analyze results", self)
  42. quitBtn = QPushButton("quit", self)
  43.  
  44. verticalbox.addWidget(image)
  45. verticalbox.addWidget(text)
  46. verticalbox.addWidget(installAPKBtn)
  47. verticalbox.addWidget(detectPathBtn)
  48. verticalbox.addWidget(startExpBtn)
  49. verticalbox.addWidget(analyzeResBtn)
  50. verticalbox.addWidget(quitBtn)
  51.  
  52. self.setLayout(verticalboxLP)
  53.  
  54. self.show()
  55.  
  56. def installAPK(self):
  57. pass
  58.  
  59. def detectPath(self):
  60. pass
  61.  
  62. def main():
  63. App = QApplication(sys.argv)
  64. window = Window()
  65. sys.exit(App.exec_())
  66.  
  67. if __name__=='__main__':
  68. main()
To copy to clipboard, switch view to plain text mode