SoFunction
Updated on 2024-12-16

wxPython based GUI implementation of the input dialog box (1)

In this article, we share the example of wxPython based GUI to achieve the specific code of the input dialog box for your reference, the details are as follows

When programming, it is inevitable that you have to enter some parameters, etc. This is where the input dialog box comes in handy.

#-*- coding:utf-8 -*-
#~ #--------------------------------------------------------------------------------
#~ FileName=
#~ Input dialog for Funciton:wx
#~ author:Wu Xu Ping
#~ Date:2013-04-28
#~ Email:539688300@
#~ #--------------------------------------------------------------------------------
import wx
 
class TextEntryDialog():
 
 def __init__(self, parent=None, title='Title', caption='Caption',size=(500, 200)):
  '''
  #~ dialog = TextEntryDialog(parent=None, title=title,caption=caption,size=size)
  #~ dialog = TextEntryDialog()
  ''' 
  style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
  super(TextEntryDialog, self).__init__(parent, -1, title=title, style=style)
   = (self, -1, caption)
   = (self, -1, style=wx.TE_MULTILINE)
  (size)
   = (|)
   = ()
  (, 0, , 5)
  (, 1, |, 5)
  (, 0, |, 5)
  ()
  ()
 def SetValue(self, value):
  (value)
 def GetValue(self):
  return ()
 
def wxinputbox(Initialstring='Initial String',title='Title',caption='Caption',size=(500,200)):
 '''
 #~ >>>stringvalue=wxinputbox(Initialstring='Initial String',title='Title',caption='Caption',size=(500,200)):
 #~ >>> stringvalue=wxinputbox()
 '''
 app = ()
 #~ dialog = TextEntryDialog(None, title=title,caption=caption,size=size)
 dialog = TextEntryDialog()
 (Initialstring)
 if () == wx.ID_OK:
  stringvalue= ()
 else:
  stringvalue=''
  ()
  ()
 return stringvalue
  
if __name__ == '__main__': 
 #~ #Use wx's input dialog box
 stringvalue=wxinputbox()
 print(stringvalue)
 
 
#~ if __name__ == '__main__':
 #~ app = ()
 #~ #Use wx's own input dialog box
 #~ dialog = (None, 'Rules:', 'Edit rules',
 #~ style=wx.TE_MULTILINE||)
 #~ ((500,200))
 #~ if () == wx.ID_OK:
  #~ print 'OK'
 #~ ()
 #~ ()

The result is as follows.


This is the whole content of this article.