Closed dncarachiola closed 2 hours ago
What's the problem?
It seems to be working OK using wxPython 4.2.2 gtk3 (phoenix) wxWidgets 3.2.6 + Python 3.12.3 + Linux Mint 22
import wx
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
wx.Frame.__init__(self, *args, **kwds)
self.SetSize((400, 300))
self.SetTitle("Test GetNumberFromUser()")
self.main_panel = wx.Panel(self, wx.ID_ANY)
main_sizer = wx.BoxSizer(wx.VERTICAL)
self.text_ctrl = wx.TextCtrl(self.main_panel, wx.ID_ANY, "", style=wx.TE_MULTILINE)
main_sizer.Add(self.text_ctrl, 1, wx.ALL | wx.EXPAND, 4)
bottom_sizer = wx.BoxSizer(wx.HORIZONTAL)
main_sizer.Add(bottom_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 8)
self.close_button = wx.Button(self.main_panel, wx.ID_ANY, "Close")
bottom_sizer.Add(self.close_button, 0, wx.RIGHT, 30)
self.get_number_button = wx.Button(self.main_panel, wx.ID_ANY, "Get Number")
bottom_sizer.Add(self.get_number_button, 0, 0, 0)
self.main_panel.SetSizer(main_sizer)
self.Layout()
self.Bind(wx.EVT_BUTTON, self.OnClose, self.close_button)
self.Bind(wx.EVT_BUTTON, self.OnGetNumber, self.get_number_button)
def OnClose(self, _event):
self.Destroy()
def OnGetNumber(self, _event):
message = "Please enter the number of items"
prompt = "Number of items:"
caption = "Required Number Of Items"
value = 42
num = wx.GetNumberFromUser(message, prompt, caption, value, min=0, max=999, parent=self)
if num == -1:
msg = "User pressed Escape or Cancel\n"
else:
msg = f"Number of items = {num}\n"
self.text_ctrl.AppendText(msg)
if __name__ == "__main__":
app = wx.App()
frame = MyFrame(None)
frame.Show()
app.MainLoop()
Closing as there are no details...
Operating system: wxPython version & source: Python version & source:
Description of the problem:
Code Example (click to expand)
```python # Put code sample here ```