Page 1 of 1

[SOLVED] Customizing a waptguihelper.message_dialog dialog box

Published: July 6, 2023 - 2:01 PM
by Regis Lemonnier
Hello,

is it possible to format a dialog box using the command: waptguihelper.message_dialog or another command?
If so, where can I find the available options?

Re: Customizing a waptguihelper.message_dialog dialog box

Published: July 6, 2023 - 4:27 PM
by htouvet
waptguihelper doesn't offer any real customization options...
One question at a time.
Apart from waptguihelper.grid_dialog(..) which allows input in a grid

Code: Select all

Parameters:
- Title: the title for the dialog
- Data: a list or JSON string
Optional: 
- ResultType: GRT_ALL or GRT_SELECTED - default is GRT_ALL
- MetaData: it can be used to change columns data type
  - it must be a JSON
  - all types: String, Date, Time, DateTime, Integer, Float, Boolean, Memo
  - example: {"columns":[{"propertyname":"id","datatype":"Integer"}]}
- Text: the label above search box - default is "Search"
- StayOnTop: indicates if the form will always stay on top - default is False
Alternatively, you can use waptmessage with an HTML form

Example:


setup.py

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
import base64
import json

form = """\
<html encoding="utf8">
    <form method="STDOUT">
        <h2>Formulaire</h2>
        Votre machine :
        <input type="text" name="machine" value="%(machine)s"><br>
        Votre nom:
        <input type="text" name="nom" value="%(nom)s"><br>
        Votre prénom:
        <input type="text" name="prenom" value="%(prenom)s"><br>
        <label for="pet-select">Choose a pet:</label>

        <select name="pets" id="pet-select">
            <option value="">--Please choose an option--</option>
            <option value="dog">Dog</option>
            <option value="cat">Cat</option>
            <option value="hamster">Hamster</option>
            <option value="parrot">Parrot</option>
            <option value="spider">Spider</option>
            <option value="goldfish">Goldfish</option>
        </select>
        <input type="submit" value="Valider">
    </form>
</html>
"""

def install():
    pass

def update_package():
    nom = ''
    prenom = ''
    machine = get_computername()
    pets=''

    s = base64.b64encode((form % locals()).encode('utf8'))
    result = run(['waptmessage','-c','-b',s])
    if result:
        data = json.loads(result)
        nom = data['result']['nom']
        prenom = data['result']['prenom']
        machine = data['result']['machine']
        pets = data['result']['pets']
        print("""\
Nom: %s
Prénom: %s
Machine: %s
Animal: %s
""" % (nom,prenom,machine,pets))

Re: Customizing a waptguihelper.message_dialog dialog box

Published: July 17, 2023 - 1:40 PM
by Regis Lemonnier
Using waptmessage with HTML meets my display needs, but when I use the code portion provided as an example, the "if result" returns 'False' even though the form fields are completed and validated (buttons "Validate" + Ok).
Any idea what caused the failure?



htouvet wrote: July 6, 2023 - 4:27 PM waptguihelper doesn't offer any real customization options...
One question at a time.
Apart from waptguihelper.grid_dialog(..) which allows input in a grid

Code: Select all

Parameters:
- Title: the title for the dialog
- Data: a list or JSON string
Optional: 
- ResultType: GRT_ALL or GRT_SELECTED - default is GRT_ALL
- MetaData: it can be used to change columns data type
  - it must be a JSON
  - all types: String, Date, Time, DateTime, Integer, Float, Boolean, Memo
  - example: {"columns":[{"propertyname":"id","datatype":"Integer"}]}
- Text: the label above search box - default is "Search"
- StayOnTop: indicates if the form will always stay on top - default is False
Alternatively, you can use waptmessage with an HTML form

Example:


setup.py

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
import base64
import json

form = """\
<html encoding="utf8">
    <form method="STDOUT">
        <h2>Formulaire</h2>
        Votre machine :
        <input type="text" name="machine" value="%(machine)s"><br>
        Votre nom:
        <input type="text" name="nom" value="%(nom)s"><br>
        Votre prénom:
        <input type="text" name="prenom" value="%(prenom)s"><br>
        <label for="pet-select">Choose a pet:</label>

        <select name="pets" id="pet-select">
            <option value="">--Please choose an option--</option>
            <option value="dog">Dog</option>
            <option value="cat">Cat</option>
            <option value="hamster">Hamster</option>
            <option value="parrot">Parrot</option>
            <option value="spider">Spider</option>
            <option value="goldfish">Goldfish</option>
        </select>
        <input type="submit" value="Valider">
    </form>
</html>
"""

def install():
    pass

def update_package():
    nom = ''
    prenom = ''
    machine = get_computername()
    pets=''

    s = base64.b64encode((form % locals()).encode('utf8'))
    result = run(['waptmessage','-c','-b',s])
    if result:
        data = json.loads(result)
        nom = data['result']['nom']
        prenom = data['result']['prenom']
        machine = data['result']['machine']
        pets = data['result']['pets']
        print("""\
Nom: %s
Prénom: %s
Machine: %s
Animal: %s
""" % (nom,prenom,machine,pets))

Re: Customizing a waptguihelper.message_dialog dialog box

Published: July 17, 2023 - 3:02 PM
by htouvet
This might be due to the version difference. I tested the code snippet with my development version of Wapt.
You're apparently using version 2.2.
You can try running it manually in a command prompt to see the output (or lack thereof in your case).

Re: [SOLVED] Customizing a waptguihelper.message_dialog dialog box

Published: September 14, 2023 - 5:40 PM
by jpele
This works with ensure_unicode

Code: Select all

    s = ensure_unicode(base64.b64encode((form % locals()).encode("utf8")))
 {"method":"STDOUT","action":"","target":"","enctype":"","result":{"machine":"jpe-clt-win11","nom":"jghjgj","prenom":"","pets":"--Please choose an option--"}}