Posts
 
Reputation
Joined
Last Seen
Ranked #2K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
93% Quality Score
Upvotes Received
17
Posts with Upvotes
13
Upvoting Members
12
Downvotes Received
1
Posts with Downvotes
1
Downvoting Members
1
3 Commented Posts

56 Posted Topics

Member Avatar for jaison2

He is using the graphics file from a python book. Your code for the stick figure would look like this. The Line command uses two points(x,y) for the starting point and (x,y) for the ending point. [CODE]def drawStickFigure(): from graphics import * win = GraphWin("Stick figure") head = Circle(Point(100, 60), …

Member Avatar for bumsfeld
0
10K
Member Avatar for tracieam

I just look at the code in the Checkbook2 class, and it needs to be reviewed. To get started I updated the fileWriter to print out the correct lines to the file. [CODE] public void fileWriter(){ //Checkbook2 write = new Checkbook2(); //System.out.println("Unavailable"); try{ BufferedWriter out = new BufferedWriter(new FileWriter("Checkbook.txt")); out.write(getName()+"\n"); …

Member Avatar for tbone2sk
0
110
Member Avatar for harinath_2007

[CODE]// Set the host smtp address Properties props = new Properties(); props.put("smtp.host", "smtp.server.com"); // create some properties and get the default Session Session session = Session.getDefaultInstance(props, null); // create a message Message msg = new MimeMessage(session); //adding an attachment DataSource source = new FileDataSource("pathToFile/filename.zip"); msg.setDataHandler(new DataHandler(source)); msg.setFileName("filename.zip");[/CODE]

Member Avatar for tbone2sk
0
93
Member Avatar for SergioEspaillat

I would take a look at this article, your computer is fairly old so I would not spend more than $150 on a video card as your CPU will handicap it. [URL="http://www.tomshardware.com/reviews/gaming-radeon-hd-geforce-gtx,2676.html"]http://www.tomshardware.com/reviews/gaming-radeon-hd-geforce-gtx,2676.html[/URL]

Member Avatar for alanfalala
-1
319
Member Avatar for SpeedyChase

This part of the forum is for Python questions, you can post your question to hardware and software.

Member Avatar for caperjack
0
270
Member Avatar for gonzigg

Why don't you just use the button class that I gave you in another thread, it would make your life a lot easier if you learn classes. Your problem is that once a click occurs outside of one of the buttons there is no infinite loop to check for the …

Member Avatar for tbone2sk
0
342
Member Avatar for gonzigg

You can use this button class to create a button with all the methods needed without hard coding every button. [CODE]# button.py # A simple Button widget. from graphics import * class Button: """A button is a labeled rectangle in a window. It is activated or deactivated with the activate() …

Member Avatar for Gribouillis
0
235
Member Avatar for wolfeater017

The button is a sprite which makes it very easy to use many times in the program and easy to customize. [CODE] #load_image is used in most pygame programs for loading images def load_image(name, colorkey=None): fullname = os.path.join('data', name) try: image = pygame.image.load(fullname) except pygame.error, message: print 'Cannot load image:', …

Member Avatar for tbone2sk
0
157
Member Avatar for faby

Python dictionaries are unordered key-value pairs, so there is no way for them to be in the same order at all times, but recently python version 2.7 was released with a ordered dictionary feature. I have not used any of the 3.0+ versions of python so I don't know if …

Member Avatar for TrustyTony
0
2K
Member Avatar for wolfeater017

Hate to say it but there are a lot of problems with your code, but you can only learn from mistakes. First I'm going to address the syntax errors, which should be easy to fix from looking at what the red error text says in your console. Line 27 [CODE]text …

Member Avatar for wolfeater017
0
292
Member Avatar for kate2mba

I have not used the graphics package cImage, but you can use the built-in random package. To call a random number between 1 and 255 just use the code below. [CODE]from random import randint print randint(1,255)[/CODE]

Member Avatar for Beat_Slayer
0
114
Member Avatar for wolfeater017

The variable windowSurface is not a global value and is local to the newscreen() method. You can make it that newscreen() returns windowSurface, but it will make your program much more future proof if you wrap these methods in a class, and declare windowSurface as self.windowSurface so that it can …

Member Avatar for tbone2sk
0
218
Member Avatar for v8smurf

Yes you can run two fans off of the 3 pin connector. You can also connect them into the the power supply cables which run at 12v too, but then they will be running at full speed because of the constant 12v.

Member Avatar for v8smurf
0
116
Member Avatar for Kanem

You can use the time library using import time. You are going to want to use something along the lines of time.sleep([I]Seconds[/I]) [URL="http://docs.python.org/library/time.html"]http://docs.python.org/library/time.html[/URL] I don't really understand what you are talking about with a hour being 5 minutes in a hour and 11 seconds in a minute.

Member Avatar for TrustyTony
0
145
Member Avatar for lewashby

[B]Question 1[/B] You do not have to recycle your "choice" variable from your for loop to make the input work. "choice" is being reassigned in this line: [CODE]choice = int(input("Choose an option: "))[/CODE] If you change the later part of your program to this it will still work perfectly. [CODE] …

Member Avatar for lewashby
0
108
Member Avatar for G_S

I have not tried it out, but after a quick google search I found this. Looks like it should work. [URL="http://search.cpan.org/~dunniganj/Tk-LineNumberText-0.5/LineNumberText.pm"]http://search.cpan.org/~dunniganj/Tk-LineNumberText-0.5/LineNumberText.pm[/URL]

Member Avatar for G_S
0
2K
Member Avatar for hondros

I tested it out and successfully downloaded an Atari game, it is a really cool application. A few things that you may want to change: [LIST] [*]After you download a rom it exits the program, there should be a choice to continue. [*]Is there a reason that you zipped a …

Member Avatar for hondros
0
129
Member Avatar for nezbo

I'm little confused on what you are trying to do, but it seems that if a item has a count of 0 then it should not even be active and just have pygame kill() it. If count is enumerating the number of classes on the screen then it is easier …

Member Avatar for nezbo
0
197
Member Avatar for lightning18

This should get you started, it will have to be tweaked depending on the infile that you are using. [CODE]def main(): d = {} text1 = ["dog","cat"] infile = open("words.txt","r") #Opening words.txt, r is for read counter = 0 for line in infile: words = line.split(",") #Using "," for delimiter …

Member Avatar for lightning18
0
80
Member Avatar for sob_andizzle

This will get you started in the right direction, I'm storing the 3 pieces of data for a painting as a tuple. If you want to get the name, you index for list[0], and so on for the other two. [CODE]#returns a list of tuples def createList(): paintingList = [] …

Member Avatar for TrustyTony
0
105
Member Avatar for jpl1993

vegaseat has a good list of examples in this thread. [URL="http://www.daniweb.com/code/snippet216689.html"]http://www.daniweb.com/code/snippet216689.html[/URL]

Member Avatar for lllllIllIlllI
0
140
Member Avatar for prashanth s j

Give this a try, using [ ] to index in that tuple. [CODE]valuesfor1 = [('WER', 100)] valuesfor2= [('WER', 700)] for tuple1 in valuesfor1: for tuple2 in valuesfor2: if tuple1[0] == tuple2[0]: if tuple1[1] < tuple2[1]: print "values for 2 is greater" elif tuple1[1] > tuple2[1]: print "values for 1 is …

Member Avatar for TrustyTony
0
111
Member Avatar for tkpanther
Member Avatar for TrustyTony
0
181
Member Avatar for tbone2sk

I'm putting together the basic layout for a contacts book, and I want to know how I can make the 3 test buttons span from edge to edge just as the arrow buttons do. [CODE]import java.awt.BorderLayout; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; …

Member Avatar for tbone2sk
0
130
Member Avatar for Krysis

Is there anyway that you can attach the entire program as a zip or pm it. I feel like I can fix the problem, but really need to try it out on the program.

Member Avatar for Krysis
0
475
Member Avatar for Dan08

This should do it, I did not test it on any files so if there might be an error. [CODE]infile = open("filename.txt","r") wordsDict = {} for line in infile: addBoolean = True for word in wordsDict: if word == line: addBoolean = False break if addBoolean: wordsDict[line] = None infile.close() …

Member Avatar for TrustyTony
0
4K
Member Avatar for spacemandan

I would start with building the board. Then create a class called ship and methods that change the size of the ship and move it. The ships are be stored in a stack for drawing. Mostly likely user input will be from console input, so make sure your board has …

Member Avatar for ultimatebuster
0
89
Member Avatar for jozz3

What do you have so far? To start you are going index the first and last in the method. [CODE]str = '123456' str[0] #index the first str[-1:]#index the last[/CODE] Then just build a simple recursive method to solve. Post your code if you have any more questions.

Member Avatar for jozz3
0
573
Member Avatar for kjock002
Member Avatar for peppermints

Minor fixes are commented. [CODE]from Tkinter import * import random weapons = ("rock", "paper", "scissors") class Application(Frame): def __init__(self, master): Frame.__init__(self, master) self.grid() self.create_widgets() def create_widgets(self): Label(self, text = "Choose your weapon!\n" ).grid(row = 0, column = 0, sticky = W) Label(self, text = "Weapons:" ).grid(row = 1, column = …

Member Avatar for jcao219
0
714
Member Avatar for Tops

[CODE]from string import split def main(): testString = "US 9 15 13 37" #using split from the string library #splitting it based on whitespace splitString = testString.split(' ') #now splitString is a list and we remove the first node splitString.pop(0) print splitString #prints as a list #Now just concatenate the …

Member Avatar for TrustyTony
0
2K
Member Avatar for biomed

Still a lot that you can add, but this should get you started. [CODE]from string import split class Line: def __init__(self,one,two,three,four): self.one = one self.two = two self.three = three self.four = four class FindMatch: def __init__(self): self.dict = {} def addFromFile(self,filename): infile = open(filename, 'r') for line in infile: …

Member Avatar for Gribouillis
0
97
Member Avatar for the_mia_team

This should solve the problem, below is the correct way to search a dictionary with a for loop. [CODE]def solve(): dict = {9:'B', 8:'C', 7:'D', 6:'E'} choice = raw_input("Please enter a number: ") if int(choice) >= 10: return 'A' elif int(choice) <= 5: return 'F' else: for letter in dict: …

Member Avatar for the_mia_team
0
126
Member Avatar for ultimatebuster

Simple example of inheritance in python. [CODE]class Basic: def __init__(self): self.var1 = None #This class inherits all aspects from Basic and can change them class Test(Basic): def __init__(self): Basic.__init__(self) def main(): testClass = Test() testClass.var1 = 5 print testClass.var1 if __name__ == '__main__': main()[/CODE]

Member Avatar for bumsfeld
0
99
Member Avatar for SgtMe

Simple example taken from pygame.org [CODE]for event in pygame.event.get() : if event.type == pygame.KEYDOWN : if event.key == pygame.K_SPACE : print "Space bar pressed down." elif event.key == pygame.K_ESCAPE : print "Escape key pressed down." elif event.type == pygame.KEYUP : if event.key == pygame.K_SPACE : print "Space bar released." elif …

Member Avatar for tbone2sk
0
14K
Member Avatar for tkpanther

Minor fixes, also if you have problems with libraries just google them or look at Python's documentation. [URL="http://docs.python.org/library/math.html"]http://docs.python.org/library/math.html[/URL] [CODE] from graphics import* import math from random import* def buildWindow(win, position): # Create the y axis lines yAxis = Line(Point(position, -50), Point(position, 50)) yAxis.setFill("black") yAxis.draw(win) # Create the x-axis lines xAxis …

Member Avatar for ssmokincamaro
0
193
Member Avatar for GMUPATS

[CODE]infile = open('InputFileName.txt', 'r') for line in infile: #line is one string print line[/CODE]

Member Avatar for vegaseat
0
88
Member Avatar for pymatio

Played the game twice and I did not have the problem with formation being broken.

Member Avatar for pymatio
0
611
Member Avatar for jeffery12109

Put them into a class. Then you can store them all in a list if you like. Sample class [CODE]class Monster: def __init__(self): #Store the unit attributes self.hp = 25 self.type = 'bird' self.attackDmg = 15 self.defence = .5 def attcker(self,unitBeingAttacked) dmgDone = self.attackDmg*unitBeingAttacked.defense[/CODE]

Member Avatar for jcao219
0
139
Member Avatar for Simes

I put your program in a class which is useful if you need to use it later in a different program. The below comments explain a few pointers. If you have any questions just ask, classes can be confusing at first. [CODE]import random #Code should always be in a method …

Member Avatar for Simes
0
147
Member Avatar for Lylywhatever

Works fine now, just had to indent the last few lines of code into your main. [CODE]from graphics import * import time def moveAll(shapeList, dx, dy): for shape in shapeList: shape.move(dx, dy) def moveAllOnLine(shapeList, dx, dy, repetitions, delay): for i in range(repetitions): moveAll(shapeList, dx, dy) time.sleep(delay) def makeFace(center, win): head …

Member Avatar for tbone2sk
0
2K
Member Avatar for rahul8590

The os is not even meant for primary computers, it is made for secondary computers and boots from flash memory. All programs and files are saved on the internet, it will be great for tablets and day to day uses, but don't plan on playing games on chrome.

Member Avatar for vaultdweller123
-1
229
Member Avatar for Nazere

Just little errors, first need to use raw_input() when inputting strings, and have to use a different variable instead of search in the for loop. [CODE]def main(): list_of_names = open_file() print""" --------------- non sorted---------------------""" print_names(list_of_names) print """ ----------------sorted-------------------------""" list_of_names = sort_names(list_of_names) save_file(list_of_names) search_names(list_of_names) def open_file(): list_of_names = [] name = …

Member Avatar for vegaseat
0
112
Member Avatar for rmatelot

Pretty sure this will work. If you have any questions just ask. [CODE]from string import find def main(): infile = open("logfile.txt", "r") pastLine = infile.readline() cont = 0 for line in infile: if cont == 1: if find(line,'-------') > -1: #find returns -1 if not found cont = 0 print …

Member Avatar for Namibnat
0
2K
Member Avatar for Nazere

Most people will not want to download .zip files, it is better if you copy and paste your code between the CODE tags.

Member Avatar for snippsat
0
71
Member Avatar for Workingwmyhands

It is considered a null string, which is ''. [CODE]a = raw_input("Enter your first name:") b = raw_input("Enter your last name:") c = raw_input("Enter your phone number:") print a print b print c d = (a and b and c) print d if d == '': print "Do not leave …

Member Avatar for SoulMazer
0
163
Member Avatar for etypaldo

This code is taken from the aliens.py example from pygame.org. [URL="http://www.pygame.org/docs/ref/examples.html#pygame.examples.aliens.main"]http://www.pygame.org/docs/ref/examples.html#pygame.examples.aliens.main[/URL]] [CODE]class Score(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) self.font = pygame.font.Font(None, 20) self.font.set_italic(1) self.color = Color('white') self.lastscore = -1 self.update() self.rect = self.image.get_rect().move(10, 450) def update(self): if SCORE != self.lastscore: self.lastscore = SCORE msg = "Score: %d" % SCORE self.image = self.font.render(msg, …

Member Avatar for tbone2sk
0
240
Member Avatar for Aqualily6
Member Avatar for Chaky
-2
134
Member Avatar for gangster88

Can you please be more clear, from what I understand you want 8 eyes total to be printed out on the screen, but with the radius size of 40 you have, all there is room for is a single eye before overlap.

Member Avatar for battlecrab
0
113
Member Avatar for jaison2

[CODE]def population(): current=input("please enter the current population of the city: ") yearCount = 1 print "At year 0 The population is ",current while current < 1000000: current += current*0.08 print "At year ",yearCount,"The population is ",current yearCount += 1 if __name__ == '__main__': population()[/CODE]

Member Avatar for leegeorg07
0
112

The End.