Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6761103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:08:46+00:00 2026-05-26T14:08:46+00:00

I want to click a button, have a text input box show up and

  • 0

I want to click a button, have a “text input box” show up and then print the value typed in the original panel where the button is.

I managed to get the button + box working but I can’t figure out how to display the value in the panel.

I’m pretty new to all this 🙂

Here’s the code:

import wx

class st3000(wx.Frame):

    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'title', size=(353,270))

        panel=wx.Panel(self)

        button1=wx.Button(panel,label='something',pos=(10,10),size=(-1,60))
        button2=wx.Button(panel,label='anything',        pos=(150,10),size=(-1,60))
        button3=wx.Button(panel,label='nothing',           pos=(250,10),size=(-1,60))

        self.Bind(wx.EVT_BUTTON, self.opcao1, button1)
        self.Bind(wx.EVT_BUTTON, self.opcao2, button2)
        self.Bind(wx.EVT_BUTTON, self.opcao3, button3)

        self.Bind(wx.EVT_CLOSE,  self.closewindow)

    def opcao1(self,event):
        box1=wx.TextEntryDialog(None,'Type...','','...here')
        if box1.ShowModal()==wx.ID_OK:
            answer1=box1.GetValue()

        output=wx.StaticText(panel,-1,answer1,(10,80),(260,-1),wx.ALIGN_CENTER)
        output.SetForegroundColour('red')
        output.SetBackgroundColour('blue')

    def opcao2(self,event):
        self.Close(True)

    def opcao3(self,event):
        self.Close(True)

    def closewindow(self,event):
        self.Destroy()

if __name__=='__main__':
    app=wx.PySimpleApp()
    frame=st3000(parent=None,id=-1)
    frame.Show()
    app.MainLoop()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:08:47+00:00Added an answer on May 26, 2026 at 2:08 pm

    The problem here is that your panel object goes out of scope once the end of the “init” method is reached, thus you cannot use it in your “opcao1” method. If you replace “panel” with “self.panel” in your code where ever it’s referenced, then it will work as you intended. The “self” makes the variable a class property.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an input text box and a search submit button, and when user
I have a <form /> with a text box, and an <input /> button.
I have several text box's where input is added. All these input are then
I have a text box and a button in a form.i want to save
I have two tables on a webform. On a button click I want to
I have a form which I want to submit upon button click which is
in my web application I have a button when I click I want to
Suppose, I want to have a link or a button that when user click
I want to trigger on click of a button this: <asp:Button runat=server ID=submit Text=Submit
I have a list <ul id=list> <li>list1</li> <li>list2</li> <li>list3</li> </ul> and text box <input

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.