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)
Why doesn't the following work (Python 2.5.2)? >>> import datetime >>> class D(datetime.date): def
Given a class: from django.db import models class Person(models.Model): name = models.CharField(max_length=20) Is it
Given: from django.db import models class Food(models.Model): Food, by name. name = models.CharField(max_length=25) class
What is the correct way to import a C++ class from a DLL? We're
I have the following entity class (in Groovy): import javax.persistence.Entity import javax.persistence.Id import javax.persistence.GeneratedValue
When used like this: import static com.showboy.Myclass; public class Anotherclass{} what's the difference between
I have created UITableCellView class called NoteCell . The header defines the following: #import
Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private
So here's the class and the super class, question to follow: TestDraw: package project3;

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.