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

  • Home
  • SEARCH
  • 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 599701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:31:35+00:00 2026-05-13T16:31:35+00:00

import wx class TestDraw(wx.Panel): def __init__(self,parent=None,id=-1): wx.Panel.__init__(self,parent,id) self.SetBackgroundColour(#FFFFFF) self.Bind(wx.EVT_PAINT,self.onPaint) def onPaint(self, event): event.Skip() dc=wx.PaintDC(self)

  • 0

import wx

class TestDraw(wx.Panel):
    def __init__(self,parent=None,id=-1):
        wx.Panel.__init__(self,parent,id)
        self.SetBackgroundColour("#FFFFFF")
        self.Bind(wx.EVT_PAINT,self.onPaint)
    def onPaint(self, event):
        event.Skip()

        dc=wx.PaintDC(self)
        dc.BeginDrawing()
        width=dc.GetSize()[0]
        height=dc.GetSize()[1]
        if height<width:
            self.drawTestRects(dc)
        else:
            dc.Clear()
        dc.EndDrawing()

    def drawTestRects(self,dc):
        dc.SetBrush(wx.Brush("#000000",style=wx.SOLID))
        dc.DrawRectangle(50,50,50,50)
        dc.DrawRectangle(100,100,100,100)

class TestFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title, size=(640,480))
        self.mainPanel=TestDraw(self,-1)

        self.Show(True)


app = wx.App(False)
frame = TestFrame(None,"Test App")
app.MainLoop()


This code should draw the test rectangles only when the height is less than the width, and otherwise the window should remain clear. However, if you mess with resizing the window, the panel isn’t actually redrawn unless it is moved off the window. What am I doing wrong?

  • 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-13T16:31:36+00:00Added an answer on May 13, 2026 at 4:31 pm

    You can bind a method to handle wx.EVT_SIZE or the panel and invalidate it there. Alternatively simply use the wx.FULL_REPAINT_ON_RESIZE for the panel.

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

Sidebar

Related Questions

Given the following simple program: import wx class TestDraw(wx.Panel): def __init__(self,parent=None,id=-1): wx.Panel.__init__(self,parent,id,style=wx.TAB_TRAVERSAL) self.SetBackgroundColour(#FFFFFF) self.Bind(wx.EVT_PAINT,self.onPaint)
import wx class MainFrame(wx.Frame): def __init__(self,parent,title): wx.Frame.__init__(self, parent, title=title, size=(640,480)) self.mainPanel=DoubleBufferTest(self,-1) self.Show(True) class DoubleBufferTest(wx.Panel):
import wx class bucky(wx.Frame): # Creating the outer window/frame def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,'Karls Network Tool',
from TKinter import * class Ui(Frame): def __init__(self) Frame.__init__(self, None) self.grid() bquit=Button(self, text=Quit, command=self.quit_pressed)
Having a snippet like this: import yaml class User(object): def __init__(self, name, surname): self.name=
from Tkinter import * class StatusBar(Frame): def __init__(self, master): Frame.__init__(self, master) self.label = Label(self,
here is some code: from Tkinter import * class Main(object): def __init__(self): self.console =
from Tkinter import * class Output: def __init__(self,master): self.u=Text(master,width=40) self.u.grid(row=0,column=0) self.v=Button(master,text=Add text,command=Write) self.v.grid(row=1,column=0) def
I have the following Python (3.2) code: from pygame import * class Application: def
For example I have class Class Cls: var 1 var 2 def func(self): ---

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.