Creating custom dialog in pyhamilton

Hi, has anyone looked into whether it would be possible to create and launch a custom dialog in pyhamilton? The dialogs are in xaml so if there was a way to send an xaml file in a command to venus that would theoretically work, just not sure how that command would work.

1 Like

yeah 100% possible, what are the input fields in the dialog? I can share a quick example.

Also moving to the pyhamilton category.

1 Like

For input fields it’d be nice to see a checkbox and numeric input? The details aren’t too important, just interested in how it would work creating from python. Thanks!

For the most basic interface you can use the input function:

output = input("Your prompt here")

Where output is a string.

Another library that provides windows for dialog boxes is Tkinter. For example:

import tkinter as tk
from tkinter import simpledialog

def show_numeric_dialog():
    root = tk.Tk()
    root.withdraw()
    value = simpledialog.askfloat("Numeric Input", "Enter a number:")
    if value is not None:
        print("Entered number:", value)
    else:
        print("No value entered.")

show_numeric_dialog()

Hope this helps

2 Likes

Ah okay I was thinking about creating a dialog such as in you would in Venus, but you’re right using tkinter is definitely the better route. Thanks!

Take a look into the Tkinter wrapper PySimpleGUI if you are interested in creating dialogs with Python. It’s really easy to program :slight_smile:

1 Like

I’m quite late to this topic but I’ll suggest pyqt5 if you’re making something academic or for internal use. Qt Designer ships with anaconda and it has a slightly more modern look than what you get with Tkinter.

1 Like