Calling paintEvent() from a class in pyqt4 python

前端 未结 2 1532
执念已碎
执念已碎 2020-12-12 00:21

I have written a class to display rectangles (the cell class). I would like to have functions inside the class to call in another class (i.e. calling cell.paintEvent(s

2条回答
  •  情书的邮戳
    2020-12-12 01:16

    Well, you would need to import the cell object. To that you need to

    from yourFileNameWithCellObject import cell
    

    To initialize a cell, you simply need to do

    newCell = cell(args_here)
    

    or to make the newCell as a part of self (Window)

    self.newCell = cell(args_here)
    

    To call methods in the cell object is quite simple.

    self.newCell.paintEvent(args_here)
    

提交回复
热议问题