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)) self.Bind(wx.EVT_CLOSE,self.closewindow) def closewindow(self,event): self.Destroy() if __name__=='__main__': app=wx.PySimpleApp() frame=bucky(parent=None,id=-1) frame.Show() app.MainLoop()
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.