By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,876 Members | 1,206 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,876 IT Pros & Developers. It's quick & easy.

Refreshing a wx.Panel

Elias Alhanatis
P: 56
Dear friends,

First of all , i wish a Happy New Year to all of you!!!!

I have been learning Python and the Tkinter GUI package for the last 6 months ,
and now i am trying to rewrite a program i made using the wxPython package.
I have a toolbar , a panel ( on which all the 'action' takes place ) ,and a status bar.
My question is , how do i delete and then redraw the panel? Here is an example of the code i use:

Expand|Select|Wrap|Line Numbers
  1. # -*- coding: cp1253 -*-
  2. from wxPython.wx import *
  3. import wx
  4.  
  5.  
  6. class ApplicationFrame(wxFrame):
  7.     def __init__(self, parent, ID, title):
  8.         wxFrame.__init__(self, parent, ID, title,
  9.                          wxDefaultPosition, wxSize(720, 450))
  10.         self.CreateStatusBar()
  11.         self.SetStatusText(u" StatusBar : Σύντομη περιγραφή της υπό επιλογή λειτουργίας")
  12.         toolbar1 = self.CreateToolBar( wx.TB_HORIZONTAL | wx.TB_TEXT | wx.BORDER_DOUBLE)
  13.         toolbar1.SetToolBitmapSize((70,63))
  14.         toolbar1.SetBackgroundColour("#d5ab6c")
  15.         toolbar1.AddSimpleTool(10, wx.Bitmap('Apothiki_Button.gif'),u" Αποθήκη ",u" Άνοιγμα καταλόγου αποθήκης")
  16.         toolbar1.AddSimpleTool(20, wx.Bitmap('Pelates_Button.gif'),u" Πελάτες ",u" Άνοιγμα καταλόγου πελατών")
  17.         toolbar1.AddSimpleTool(30, wx.Bitmap('Promitheftes_Button.gif'),u" Προμηθευτές ",u" Άνοιγμα καταλόγου προμηθευτών")
  18.         toolbar1.AddSimpleTool(40, wx.Bitmap('Exit_Button.gif'),u" Έξοδος ",u" Έξοδος από το πρόγραμμα")
  19.         toolbar1.Realize()
  20.         EVT_MENU(self,40,self.TimeToQuit)
  21.         EVT_MENU(self,20,self.Pelates)
  22.         EVT_MENU(self,30,self.ChangeColour)
  23.         self.panel=wx.Panel(self,id=50,style=wx.BORDER_SUNKEN,name=" My Panel")
  24.         self.panel.SetBackgroundColour("red")
  25.         self.panel.Show()
  26.         self.panel.Bind(EVT_LEFT_DCLICK,lambda event:self.panel.SetBackgroundColour("blue"))
  27.  
  28.  
  29.     def ChangeColour(self,event):
  30.         self.panel.SetBackgroundColour("skyblue")
  31.         self.panel.Refresh(true)
  32.  
  33.     def Pelates ( self,event):
  34.         pass
  35.  
  36.     def TimeToQuit(self, event):
  37.         self.Close(true)
  38.  
  39.  
  40. class MyApp(wxApp):
  41.     def OnInit(self):
  42.         frame = ApplicationFrame(NULL, -1, "Midas wx_Python")
  43.         frame.Show(true)
  44.         self.SetTopWindow(frame)
  45.         return true
  46.  
  47. app = MyApp(0)
  48. app.MainLoop()
As you can see , i try both ways to change the colour of the panel , but none of
them works properly. I have noticed that with the Bind method , the panel gets refreshed when i drag and move on it another window from my desktop.
I am using Python 2.5.1 on Windows Vista.

Thank you all in advance!!!!

Elias
Dec 30 '07 #1
Share this Question
Share on Google+
1 Reply


Elias Alhanatis
P: 56
Puzzle solved!!!!

No need to answer this post!!

Elias
Jan 4 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.