Beat_Slayer 17

Beat_Slayer 17

[CODE]def init(self, title='Console Application Menu', size=(80, 25), border='#', log_title='Log Output:'):

"""The class initialization takes as optional arguments:

  • title: title text of the menu
  • size: the size in characteres of the console window menu
  • border: character to be printed as border for the menu and dialogs
  • log_title: title text of the log window"""[/CODE]

You change the [CODE]border='#'[/CODE] to [CODE]border='='[/CODE] in there. If you read the comments it gets pretty clear.

Hope I helped. Cheers and Happy Coding

P.S.: I'm back. =D

Beat_Slayer 17

I'm new ot twisted, but thats all I was able by now to extract as peer info.

But, your implementation does'nt seem right to me.

I'll take a look into twisted, I think I'll write something, meanwhile...

[CODE]from twisted.protocols.basic import LineOnlyReceiver
from twisted.internet import reactor
from twisted.internet.protocol import ServerFactory
import time

class ChatConnection(LineOnlyReceiver):

def __init__(self):
    self.hostlist = []
    self.hostname = ""
    self.master = ""

def sendLine(self, line):
    self.transport.write(line + '\n')

def print_time(self):
    return time.strftime("[%H:%M] ", time.localtime(time.time()))

def name(self):
    self.nick = self.transport.getPeer()
    return ' '.join([str(item) for item in self.nick])

def connectionMade(self):
    print  self.print_time() + "New connection from " + self.name()

    if self.name == self.hostname:
        self.master = self.transport.getPeer().host
    else:
        self.factory.IDandIP[self.name] = self.transport.getPeer().host
        self.hostlist.append(self.name())

    def connectionLost(self, reason):
        print self.print_time() + "Connection lost by", self.name()
        del self.factory.IDandIP[self.name]
        self.hostlist.remove(self.name())

    def lineReceived(self, line):

        if line == "/list":
            self.sendLine(self.print_time() + "Online users: \n\t" + str(self.hostlist))

        if line[:6] == "zombie":
            self.master.sendLine(line[:6])
        else:
            ID = line.split(" : ")[0]

            if ID in self.hostlist:
                  self.IDandIP[ID].sendLine(line)

class Chat(ServerFactory):

protocol = ChatConnection

def __init__(self):

    self.IDandIP = {}

print "Waiting connection from clients..."
main = Chat()
reactor.listenTCP(8000, main)
reactor.run()[/CODE]

Cheers and Happy coding

Beat_Slayer 17

I can't see the problem, and it's working good.

Maybe IDLE? Maybe version of the pygame you use?

Cheers and Happy coding

Beat_Slayer 17

Your import concept mate is totally wrong. You should read a good python tutorial.

Back to the code, something like
[CODE]self.image_list = []

def addImage(self, imageName):
try:
newImageData = {}
im = Image.open(imageName)
data = im.getdata()
width, height = im.size
self.image_list.append(imageName)
except IOError:
showerror( "File Error", "The selected file could either opened or converted." )
return

    newImageData['im'] = im
    newImageData['data'] = data
    newImageData['width'] = width
    newImageData['height'] = height
    newImageData['id'] = -1
    newImageData['contours'] = []
    newImageData['dots'] = []
    newImageData['landmarks'] = []
    newImageData['linewidth'] = 1
    newImageData['linelength'] = 20
    newImageData['stack'] = self.getCurrentStack()
    self.imageInfo.append(newImageData)[/CODE]

You can then use the image_list something like...
[CODE]
for image in self.image_list:
...[/CODE]
Cheers and Happy coding

Beat_Slayer 17

First wrap your code with Code-tags. You can do it easilly by selecting your code and clicking the code button.

And that code is useless mate. I mean you to show the code you use to open them.

And imports are done at the beginning of the script and never inside a function.

Cheers and Happy coding

Beat_Slayer 17

The usage is [CODE]SetGridCursor(self, row, col)[/CODE], so why collumn -1 on your code mate?
[CODE]self.SpeciesGrid.SetGridCursor(ind, -1)[/CODE]
Cheers and Happy coding

Beat_Slayer 17

[CODE]class SpeciesGrid(wx.Frame):

self.EnglishNameList = ['Great Tit','Marsh Tit','Coal Tot','Crested Tit'][/CODE]

Your code defines EnglishNameList as a attribute of the SpeciesGrid class, so you must change the [CODE]self.EnglishNameList[/CODE] on the SearchDlg class by something like [CODE]SpeciesGrid.EnglishNameList[/CODE].

Cheers and Happy coding

Beat_Slayer 17

Sorry mate, now I got it! :D

I made consfusion, the country I'm in now has a provider named 'Telnet', and I just stupidlly thought you were talking about it. I'm very sorry.

I'll take a look.

Cheers and Happy coding

Beat_Slayer 17

1 - I mean that if you use subprocess, you don't have to edit or prepare the scripts, you can just load them as they are and redirect the output, with logging the scripts must be prepared to use the module and make the output.

2 - Yes you can make the two, it's a mather of implementation.

Cheers and Happy coding

Beat_Slayer 17

You can create a script, wich loads your scripts with subprocess, and then you can redirect the output, like this you won't need to adjust the scripts.

More than that, you can write a module or use [URL="http://docs.python.org/library/logging.html"]logging[/URL] as told, but for that you must adjust your acripts to.

Cheers and Happy coding

Cheers and Happy coding

Beat_Slayer 17

Add '\n' in each write.

Cheers and Happy coding

Beat_Slayer 17

You don't need to display them, if you maintain a list of the image objects open, you can easilly save them all in a nice loop.

Show a example of what you mean, I'll help you.

Cheers and Happy coding

Beat_Slayer 17

[QUOTE=;][/QUOTE]
Wait, this is the server code, right?

How do you connect to it?

Cheers and Happy coding

Beat_Slayer 17

Only the print implementation.

You can do
[CODE]from future import print_function[/CODE]
and keep the 3.x print style.

Cheers and Happy coding

Beat_Slayer 17

You are write, just not implementing good.

Because as you say, if you don't escape the '.' it will match any simbol, and so...
[CODE]re.search('[0-9][0-9][0-9].','1234atxt')[/CODE]
will work. But as you 'escaped' it using the '\' it matchs the '.'.

Cheers and happy coding

Beat_Slayer 17

What you mean? Like clipboard access? Or a internal function?

Copy to variable and write the variable to the widget maybe?

Cheers and Happy coding

Beat_Slayer 17

It seems to work here...

[CODE]import re

print re.findall('[0-9][0-9][0-9].', '1234_.txt')
print
print re.findall('[0-9][0-9][0-9].', '1234.txt')[/CODE]

Can you explain what's not working.

Cheers and Happy coding

Beat_Slayer 17

The distance between vectors, presuming you have vector A and B with two coordinates x and y, is:

[CODE]sqrt(((Ax - Bx) 2) + ((Ay - By) 2))[/CODE]

Beat_Slayer 17

The from_points function pass the values to the init by the cls variable, and not the other way around.

When you call 'AB = Vector2.from_points(A, B)' it will pass the 'A' and 'B' tuples to the 'from_points' function that will calculate and pass then the result to the class init function.

Cheers and Happy coding

Beat_Slayer 17

You want all the output in text file, or only the error output?

Wich OS? Are you using GUI?

Cheers and Happy coding

Beat_Slayer 17

This should be faster.

[CODE]lines = [line for line in tx.readlines(2000000)][/CODE]

Cheers and Happy coding

Beat_Slayer 17

I've installed twisted mate.

Do you have client code? Can you post it, or PM it to me?

Cheers and Happy coding

Beat_Slayer 17

And like this?

[CODE]def name(self):
connector = self.transport.connector
return connector.getDestination()[/CODE]

I'll install twisted to take a look.

Cheers and Happy coding

Beat_Slayer 17

Something like this...

[CODE]f_in = open('file.csv')
lines = f_in.readlines()[1:]
fields = [item for item in lines.split(',')]
selected = []
for field in fields:
selected.append((field[4], field[6]))[/CODE]

It will need adjusting...

Cheers and Happy coding

Beat_Slayer 17

Wheres your code?

Wich methods have you tryed to?

Wich are the errors?

Cheers and Happy coding

Beat_Slayer 17

@staticmethod returns a static method for function.

@classmethod returns a class method for function.

The classmethod is called with the 'cls' argument as first argument and it represents the class.

It's called when you create a class object and will serve as constructor for the class.

At line 13 it will pass the data from the 'from_points()' function to the class.

And when the class object 'AB' is called to be printed the 'str' function is called.

Hope that helps...

Cheers and Happy coding

Beat_Slayer 17

How about showing some code??

Anyway the getDestination() should retrieve you the hostname.

Try something like...

[CODE]peer = self.transport.getPeer()
nick = peer.getDestination()[/CODE]

Cheers and Happy coding

Beat_Slayer 17

Something like...

[CODE]self.transport.getDestination()[/CODE]

Cheers and Happy coding

Beat_Slayer 17

doffing81, theres no need to hardcode the 5 deals.

[CODE]def deal():
"""this function deals the cards individually to each hand"""
for i in range(5):
self.append(deck.pop(0)) #pop(0) grabs the first card/item in list
p2.append(deck.pop(0)) #pop() would grab last...I believe
p3.append(deck.pop(0))
p4.append(deck.pop(0))[/CODE]

Cheers and Happy coding

doffing81 commented: Perfect +1