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

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

The Archive Base Latest Questions

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

thanks in advance for the replies…. I have started to create a network topology

  • 0

thanks in advance for the replies…. I have started to create a network topology program which works in the same way as cisco packet tracer or GNS3… I have used Python for a number of projects but using the wxPython library for the first time is proving to be a huge handful when it comes to understanding what functions to use.

The user has a variety of different buttons such as a router button, switch, host computers and server button etc when they click this button I would like the image on the button to appear in a editable area. (somthing similar to paint) The user can then move it within this area using the wxPython drag and drop function. I cant get my head around what to use for this area…. I have tryed searching in google for ‘wxPython how to create a paint program’ etc but still no luck.

Please could someone suggest how they would make this program?

Karl

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

    Here is the excerpt from the wxpython (wxpython in action by Robin Dunn) book which shows how to use paint. Hope this helps:

        import wx
        class SketchWindow(wx.Window):
        def __init__(self, parent, ID):
        wx.Window.__init__(self, parent, ID)
        self.SetBackgroundColour("White")
        self.color = "Black"
        self.thickness = 1
        self.pen = wx.Pen(self.color, self.thickness, wx.SOLID)
        self.lines = []
        self.curLine = []
        self.pos = (0, 0)
        self.InitBuffer()
        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
    
        self.Bind(wx.EVT_MOTION, self.OnMotion) self.Bind(wx.EVT_SIZE,
        self.OnSize) self.Bind(wx.EVT_IDLE, self.OnIdle)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
    
        def InitBuffer(self):
        size = self.GetClientSize()
        self.buffer = wx.EmptyBitmap(size.width, size.height)
        dc = wx.BufferedDC(None, self.buffer)
        dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
        dc.Clear()
        self.DrawLines(dc)
        self.reInitBuffer = False
    
        def GetLinesData(self):
         return self.lines[:]
       def SetLinesData(self, lines):
         self.lines = lines[:]
         self.InitBuffer()
         self.Refresh()
       def OnLeftDown(self, event):
        self.curLine = []
        self.pos = event.GetPositionTuple()
        self.CaptureMouse()
       def OnLeftUp(self, event):
        if self.HasCapture():
         self.lines.append((self.color,
        self.thickness,
       self.curLine))
       self.curLine = []
        self.ReleaseMouse()
       def OnMotion(self, event):
         if event.Dragging() and event.LeftIsDown():
        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
        self.drawMotion(dc, event)
        event.Skip()
       def drawMotion(self, dc, event):
       dc.SetPen(self.pen)
       newPos = event.GetPositionTuple()
       coords = self.pos + newPos
       self.curLine.append(coords)
        dc.DrawLine(*coords)
       self.pos = newPos
    
        def OnSize(self, event):
        self.reInitBuffer = True
          def OnIdle(self, event):
           if self.reInitBuffer:
         self.InitBuffer()
          self.Refresh(False)
        def OnPaint(self, event):
         dc = wx.BufferedPaintDC(self, self.buffer)
        def DrawLines(self, dc):
       for colour, thickness, line in self.lines:
        pen = wx.Pen(colour, thickness, wx.SOLID)
        dc.SetPen(pen)
        for coords in line:
        dc.DrawLine(*coords)
        def SetColor(self, color):
        self.color = color
         self.pen = wx.Pen(self.color, self.thickness, wx.SOLID)
        def SetThickness(self, num):
        self.thickness = num
        self.pen = wx.Pen(self.color, self.thickness, wx.SOLID)
       class SketchFrame(wx.Frame):
        def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "Sketch Frame",
         size=(800,600))
        self.sketch = SketchWindow(self, -1)
          if __name__ == '__main__':
          app = wx.PySimpleApp()
         frame = SketchFrame(None)
          frame.Show(True)
          app.MainLoop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks in advance for your help. I have a need within an application to
Thanks in advance for your assistance. I have the following exported part: [Export (typeof(INewComponent))]
Thanks in advance to anyone who can think of a more efficient or a
thanks in advance for looking at this. Essentially, I'm calling didInsertElement() and binding an
Thanks in advance for any help you can provide on this issue! I manage
Thanks in advance for taking the time to read my question. I'm using MySQL
Thanks in advance for your help experts. I want to be able to copy
Thanks in Advance for reading and answer this question. I got button in asp
thanks in advance for reviewing my post. I've only been using jquery for about
I have a site with a customer front end, which has a catalogue, homepage,

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.