Search code examples
pythonuser-interfaceresizefiremonkey

How can I prevent a Python FMX GUI Form from being resized?


I have a window Form that is created with the DelphiFMX GUI library for Python. My code and Form look like this:

from delphifmx import *

class frmMain(Form):
    def __init__(self, owner):
        self.Caption = 'My Form'
        self.Width = 1000
        self.Height = 500

def main():
    Application.Initialize()
    Application.Title = "My Application"
    Application.MainForm = frmMain(Application)
    Application.MainForm.Show()
    Application.Run()
    Application.MainForm.Destroy()

main()

Python empty GUI Form

The Form should not be able to be resized by dragging the sides of the Form and the Maximize button should be disabled or invisible.

How do you stop the app (Form) from being resized?


Solution

  • I asked the same question on GitHub and got an answer. Need to add the following two lines of code to stop the Form from being resized:

    self.BorderStyle = "Single"
    self.BorderIcons = ["biSystemMenu","biMinimize"]
    

    BorderStyle = "Single" stops the Form from being resized by dragging the sides of it.

    BorderIcons = ["biSystemMenu","biMinimize"] disables the Maximize button in Title Bar.

    Here's how the Form looks like. You can see Maximize is disabled: Empty Python GUI Form