Jump to content
  • Advertisement
Sign in to follow this  

[python] Having trouble getting this to work.

This topic is 2898 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Whenever I test the code without the wxpython portions it works fine.

import wx
from socket import *
targetip = ""

class Test(wx.Frame):
def __init__(self, *args, **kwargs):
super(Test, self).__init__(*args, **kwargs)


def InitUI(self):

panel = wx.Panel(self)
button = wx.Button(panel, label = "GetIp", pos = (50, 20), size = (60,30))
self.Bind(wx.EVT_BUTTON, self.GetIp, button)
button2 = wx.Button(panel, label = "Scan", pos = (125, 20), size = (60,30))
self.Bind(wx.EVT_BUTTON, self.Scan, button2)
menubar = wx.MenuBar()
filemenu = wx.Menu()
fitem = filemenu.Append(wx.ID_EXIT, 'Quit', 'Quit Application')
menubar.Append(filemenu, '&File')

self.Bind(wx.EVT_MENU, self.OnQuit, fitem)
self.SetTitle('Simple Test')

def GetIp(self, e):
box = wx.TextEntryDialog(None, "Target IP", "Enter IP", "")
if box.ShowModal() == wx.ID_OK:
target = box.GetValue()
targetip = gethostbyname(target)
print targetip

def Scan(self, e):
print "Scanning IP"
for i in range(20, 1025):
s = socket(AF_INET, SOCK_STREAM)
result = s.connect_ex((targetip,i))

if(result == 0):
print "Port %d: OPEN" % (i,)

def OnQuit(self, e):

def main():
ex = wx.App()

if __name__ == '__main__':

Share this post

Link to post
Share on other sites
What does "work" mean? What is the first point at which the program's behaviour diverges from that which you expect?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!