0

I want the position of the button in the interface to change randomly. But I can't view the button.(I can also share the .ui file if you want)

object_1 = None

class aim(QMainWindow):
    
    def __init__(self):

        super(aim,self).__init__()
        ui_path = r"C:\Users\EfkanEfe\Desktop\aim_lab_fold\target_pos_silincecek.ui"
        unicode_tr(u"{}".format(ui_path))
        loadUi(ui_path,self)

        self.target_pos()

    def target_pos(self):

        for i in range(5):
            x = random.randint(540,1050)
            y = random.randint(260,600)

            #print(f"{x},{y}")

            self.target_btn.setGeometry(x,y,200,150)

            time.sleep(0.5)

if __name__ == "__main__":
            
    app = QApplication(sys.argv)
    object_1 = aim()
    object_1.show()
    sys.exit(app.exec_())

0 Answers0