Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To change the content of a window in PyForms-GUI, you can modify the init_form() method of your form class. This method is called when the form is created, and it is where you can add widgets and configure their properties.

For example, if you want to add a label widget to the form, you can use the self.addWidget() method to add it. The addWidget() method takes two arguments: the widget instance and a tuple containing the widget's position and size.

Here's an example that adds a label widget to a form:

from pyforms.basewidget import BaseWidget
from pyforms.controls import ControlLabel

class MyForm(BaseWidget):
    def __init__(self):
        super().__init__('My Form Title')

        # Add a label widget to the form
        self.label = ControlLabel('Hello, world!')
        self.addWidget(self.label, (0, 0, 1, 1))

# Create and show the form
form = MyForm()
form.show()

In this example, the ControlLabel widget is created with the text 'Hello, world!' as its argument, and added to the form using the addWidget() method. The tuple (0, 0, 1, 1) specifies that the widget should be positioned at row 0 and column 0, and occupy one row and one column. Finally, the form is created and shown using the show() method.