[Tutor] Problems with Gauge Bar.
Olrik Lenstra
o.lenstra at gmail.com
Sun Aug 10 12:49:04 CEST 2008
This is the part I tried to get the Bar in. I actually got it in GUI wise.
But I had no idea to let it run the moment I clicked "Scan"
I got the code I tried to put in from another python file that I found
somewhere on the net. It's attached as test.pyw
<<<
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
wx.Size(300, 280),
style = wx.DEFAULT_FRAME_STYLE & ~
(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
self.timer = wx.Timer(self, 1)
self.count = 0
panel = wx.Panel(self, -1)
introFont = wx.Font(10, wx.ROMAN, wx.NORMAL, wx.NORMAL)
introText = wx.StaticText(panel, -1, introRaw,(50, 10),
style=wx.ALIGN_CENTRE)
introText.SetFont(introFont)
wx.Button(panel, 1, 'Scan!', (115, 90))
wx.Button(panel, 2, 'Logs', (115, 120))
wx.Button(panel, 3, 'Version', (115, 150))
wx.Button(panel, 4, 'Credits', (115, 180))
wx.Gauge(panel, 5, 50, (50, 210), size=(250, 25))
self.Bind(wx.EVT_BUTTON, self.OnScan, id=1)
self.Bind(wx.EVT_BUTTON, self.OnLogs, id=2)
self.Bind(wx.EVT_BUTTON, self.OnVersion, id=3)
self.Bind(wx.EVT_BUTTON, self.OnCredits, id=4)
>>>
Alan, I'm using pyinstaller. is it possible to make several python files
into a single exe? If so, Can you direct me to maybe some documentation? (I
might have overlooked it.)
The program runs fine and works perfectly as the code is right now, But
while I'm asking for the bar, can I ask for some advice on the following bit
of code too?
<<<
##------------------------------------------------------------------------------
## Define all the private IP ranges that we're not going to filter in
## the ipconfig part of the program.
## From private4 to private19 is actually 1 range. (Needs to be looked at.)
##------------------------------------------------------------------------------
private1 = r"192\.168\.\d+\.\d+"
private2 = r"169\.254\.\d+\.\d+"
private3 = r"10\.\d+\.\d+\.\d+"
private4 = r"172\.16\.\d+\.\d+"
private5 = r"172\.17\.\d+\.\d+"
private6 = r"172\.18\.\d+\.\d+"
private7 = r"172\.19\.\d+\.\d+"
private8 = r"172\.20\.\d+\.\d+"
private9 = r"172\.21\.\d+\.\d+"
private10 = r"172\.22\.\d+\.\d+"
private11 = r"172\.23\.\d+\.\d+"
private12 = r"172\.24\.\d+\.\d+"
private13 = r"172\.25\.\d+\.\d+"
private14 = r"172\.26\.\d+\.\d+"
private15 = r"172\.27\.\d+\.\d+"
private16 = r"172\.28\.\d+\.\d+"
private17 = r"172\.29\.\d+\.\d+"
private18 = r"172\.30\.\d+\.\d+"
private19 = r"172\.31\.\d+\.\d+"
##------------------------------------------------------------------------------
## Define concealip. This will make sure no public addresses will be
published
## on the forums and decreasing the risk for the poster.
##------------------------------------------------------------------------------
def concealip():
##------------------------------------------------------------------------------
## Start a loop to replace the public addresses with X's.
## Currently this part is really inefficient.
##------------------------------------------------------------------------------
lines = file('ipconfig.txt', "r+").readlines()
for i in range(len(lines)):
if re.search("IP\D+ \:", lines[i]):
if not re.search(private1, lines[i]):
if not re.search(private2, lines[i]):
if not re.search(private3, lines[i]):
if not re.search(private4, lines[i]):
if not re.search(private5, lines[i]):
if not re.search(private6, lines[i]):
if not re.search(private7, lines[i]):
if not re.search(private8,
lines[i]):
if not re.search(private9,
lines[i]):
if not re.search(private10,
lines[i]):
if not
re.search(private11, lines[i]):
if not
re.search(private12, lines[i]):
if not
re.search(private13, lines[i]):
if not
re.search(private14, lines[i]):
if not
re.search(private15, lines[i]):
if
not re.search(private16, lines[i]):
if not re.search(private17, lines[i]):
if not re.search(private18, lines[i]):
if not re.search(private19, lines[i]):
lines[i] = lines[i].replace('1', 'x')
lines[i] = lines[i].replace('2', 'x')
lines[i] = lines[i].replace('3', 'x')
lines[i] = lines[i].replace('4', 'x')
lines[i] = lines[i].replace('5', 'x')
lines[i] = lines[i].replace('6', 'x')
lines[i] = lines[i].replace('7', 'x')
lines[i] = lines[i].replace('8', 'x')
lines[i] = lines[i].replace('9', 'x')
lines[i] = lines[i].replace('0', 'x')
>>>
This bit of code is meant to X-away public IP addresses on an ipconfig log.
It works perfectly but I think it's way to large or ineffective. Since I'm
only a beginner I left it at this for now, Is there a way for me to improve
this?
Thanks for all the help!!
Regards,
Olrik
2008/8/10 Alan Gauld <alan.gauld at btinternet.com>
>
> "Olrik Lenstra" <o.lenstra at gmail.com> wrote
>
> I've been developing a program for a while now (I am still a beginner
>> though) and I want to add a progress bar (gauge bar) to my program.
>> I am having quite some trouble actually implementing it though. I attached
>> the file TSO.pyw which is my current project.
>>
>
> Can you show us what you have tried so far?
>
> I want to keep it within 1 python file if it's possible. Because I want to
>> turn it into a single executable file.
>>
>
> You can use multiple files and still produce an EXE using
> py2exe or similar. There is no need to keep it in one file.
>
> Alan G
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080810/d95568e9/attachment.htm>
More information about the Tutor
mailing list