I am working on improvement of my program. Here is it's code.

import wx

class bucky(wx.Frame):
  def __init__(self, parent, id):
    wx.Frame.__init__(self, parent, id, "Testing erea", size=(280,400))

    panel = wx.Panel(self)
    food = wx.Button(panel,label='Food',pos=(10,10),size=(80,40))
    drink= wx.Button(panel,label='Drink',pos=(100,10), size=(80,40))

    self.Bind(wx.EVT_BUTTON, self.drink, drink)
    self.Bind(wx.EVT_BUTTON, self.food, food)
  def food(self, event):
    box = wx.TextEntryDialog(None, 'What is your fav food?', 'Title', 'enter food name')
    if box.ShowModal()==wx.ID_OK:
      answer = box.GetValue()
    wx.StaticText(self, -1, answer, (10,60))

  def drink(self, event):
    slider = wx.Slider(self, -1, 50,1,100, pos=(10,60), size=(260,-1))
  def closewindow(self,event):

if __name__=='__main__':

1.My program has two buttons: "Food" and "Drink".
When I click "Food" a dialog message pops-up and asks you
to enter your favorite food.
When I click "Drink" slider appears on a screen.

2.Problem. When I enter name of food and print it on a screen
and then click "Drink" button, the slider appears on top of the
text. Or, when I click on the "Food" button for a second time and
enter another item, then entered text #2 appears on top of
already existing text without erasing it.

3. I want my program to erase text (or slider, or anything that is
currently on a screen) and do next action (ether print new text, or show
slider) using clean screen.

Simply saying, my program has obvious bug and I need help
to figure out haw to erase needless stuff on the screen.

Thank you a lot for help.

Unfortunately I can't be of great help here, I have not had a chance to do much in the way of gui programming in python.

However I think that you should've done something more like this in __init__:

self.panel = wx.Panel(self)
    food = wx.Button(self.panel,label='Food',pos=(10,10),size=(80,40))
    drink= wx.Button(self.panel,label='Drink',pos=(100,10), size=(80,40))

and then in food

wx.StaticText(self.panel, -1, answer, (10,60))

I'm running late for a lecture, but if no one has helped further I when I'm done I will give it a closer look :) hope this helps

This article has been dead for over six months. Start a new discussion instead.