import traceback
import wx
from pyrx import Ap
class TestUIDialog(wx.Dialog):
def __init__(self, parent=None):
style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
super().__init__(
parent,
title="PyRx wxPython Control Check",
size=(340, 240),
style=style,
name="PyRxTestUIDialog",
)
# Create a panel, a sizer and some controls
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
self.cb = wx.CheckBox(panel, label="Modern Visual Styles Active")
self.cb.SetValue(True)
self.combo = wx.ComboBox(
panel,
choices=["Option A", "Option B"],
value="Option A",
style=wx.CB_READONLY,
)
# Bind to an event
self.combo.Bind(wx.EVT_COMBOBOX, self.on_combo_select)
self.gauge = wx.Gauge(panel, range=100)
self.gauge.SetValue(70)
self.txt = wx.TextCtrl(panel, value="Text input test")
self.btn = wx.Button(panel, wx.ID_OK, label="Close Test")
# add the controls to the sizer
for ctrl in (self.cb, self.combo, self.gauge, self.txt, self.btn):
sizer.Add(ctrl, 0, wx.ALL | wx.EXPAND, 8)
# add the sizer to the panel
panel.SetSizer(sizer)
def on_combo_select(self, event):
print("Selected:", self.combo.GetValue())
event.Skip()
@Ap.Command()
def testui():
try:
with TestUIDialog() as dlg:
res = Ap.Application.showModalDialog(dlg)
print(res)
except Exception as err:
traceback.print_exception(err)