520 Posted Topics
[CODE]background_image_filename = "sushiplate.jpg" sprite_image_filename = 'fugu.png' import pygame from pygame.locals import * from sys import exit pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) background = pygame.image.load(background_image_filename).convert() sprite = pygame.image.load(sprite_image_filename) # The x coordinate of our sprite x = 0. while True: for event in pygame.event.get(): if event.type == QUIT: exit() … | |
In the following program can someone help me figure out why the close button [X] at the top right corner isn't working? [CODE] # imports from Tkinter import * from sound_panel import * import pygame.mixer # create gui app = Tk() app.title("Head First Mix") # create mixder mixer = pygame.mixer … | |
[CODE]import pygame from pygame.locals import * from sys import exit from random import * pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) while True: for event in pygame.event.get(): if event.type == QUIT: exit() random_color = (randint(0, 255), randint(0, 255), randint(0, 255)) random_pos = (randint(0, 639), randint(0, 479)) random_radius = randint(1,200) pygame.draw.circle(screen, … | |
[CODE]import pygame from pygame.locals import * from sys import exit from random import * pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) while True: for event in pygame.event.get(): if event.type == QUIT: exit() screen.lock() for count in range(10): random_color = (randint(0, 255), randint(0, 255), randint(0, 255)) random_pos = (randint(0, 639), randint(0, … | |
[CODE]import pygame from pygame.locals import * from sys import exit from random import randint pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) while True: for event in pygame.event.get(): if event.type == QUIT: exit() rand_col = (randint(0, 255), randint(0, 255), randint(0, 255)) for _ in xrange(100): rand_pos = (randint(0, 630), randint(0, 479)) … | |
I'M learning python and I can write very small simple programs with Tkinter or play sound through pygame. I've just started the book "Beginning Game Development with Python and Pygame". I'M in the earlier part of the book and I've just been given the program below. The thing is, even … | |
Could someone please tell me why this code will not close my app when the [X] at top right corner is clicked? [CODE]def shutdown(): track.stop() app.destroy() app.protocol("WM_DELETE_WINDOW", shutdown)[/CODE] If you want to see the whole code it's on an earlier post called "Tkinter Scale". Thanks. | |
file = hfmix2.py error is on line 3 [CODE]# imports from Tkinter import * from sound_panel2 import * import pygame.mixer # create gui app = Tk() app.title("Head First Mix") # create mixder mixer = pygame.mixer mixer.init() # call functions panel1 = SoundPanel(app, mixer, "50459_M_RED_Nephlimizer.wav") panel1.pack() panel1 = SoundPanel(app, mixer, "49119_M_RED_HardBouncer.wav") … | |
Re: I was a good one. But the first Half-Life was better. I still believe it's the best game ever made. | |
I'M currently tacking Database Administration at [url]http://www.oreillyschool.com/certificates/[/url] I want to get into the IT community and out of this factory work. Could some more experienced people please take a look at that site and tell me if my certificate or any of them are worth taking, both in terms of … | |
In the following program I don't understand why 'mixer' is given as an argument to the function 'create_gui'. Please explain. File 1 [CODE]# imports from Tkinter import * from sound_panel import * import pygame.mixer # create gui app = Tk() app.title("Head First Mix") # create mixder mixer = pygame.mixer mixer.init() … | |
[CODE]from Tkinter import * import tkMessageBox import pygame.mixer # create GUI window app = Tk() app.title("Head Frist Mix") sound_file = "50459_M_RED_Nephlimizer.wav" # start the sounds system mixer = pygame.mixer mixer.init() # create function def track_toggle(): if track_playing.get() == 1: track.play(loops = -1) else: track.stop() # create function volume def change_volume(v): … | |
[CODE]# create options menu options = read_depots("depots.txt") OptionMenu(app, depot, *options).pack()[/CODE] In the above code I'M getting the error that __inti__ takes 4 arguments and that it's only given 3. I'M writing the code just how the book gives it to me. | |
[CODE]# create GUI app = Tk() app.title("Head-Ex Deliveries") # create a label Label(app, text = "Depot:").pack() # add to Tk app window # create a text entry depot = Entry(app) depot.pack()[/CODE] I understand and have been told that placing the instance name(app) as a parameter of Tk methods and other … | |
I'M getting error below when I run the following program code. It's with the following function. [COLOR="Red"]fileD.write("%\n" % depot.get())[/COLOR] [COLOR="Red"]Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1413, in __call__ return self.func(*args) File "/home/developer/Projects/Head First/Chapter 7/Head-Ex.py", line 7, in save_data fileD.write("%\n" % depot.get()) ValueError: unsupported format … | |
I am reading the book "Python Programming 2nd Ed. for the absolute beginner" and I am having some trouble with a very simple program. I was instructed to download and install pygame and the livewires package as I have done. This program is meant to display a grahical window, that's … ![]() | |
I have a computer split between Windows Vista and Ubuntu 9.10. A friend of mine who has the same configuration update his Ubuntu several months back and found that his Windows partition was unable to boot up. In order to restore his sytem he had to run Windows recover through … | |
[CODE]from Tkinter import * import pygame.mixer sounds = pygame.mixer sounds.init() correct_s = sounds.Sound("Correct.wav") wrong_s = sounds.Sound("Wrong.wav") number_correct = 0 number_wrong = 0 def play_correct_sound(): global number_correct number_correct = number_correct + 1 correct_s.play() def play_wrong_sound(): global number_wrong number_wrong = number_wrong + 1 wrong_s.play() app = Tk() # creat a tkinter application … | |
[CODE]app = Tk() # creat a tkinter application window called "app" app.title("TVN Game Show") app.geometry("300x100+200+100") b1 = Button(app, text = "Correct!", width = 10, command = play_correct_sound) b1.pack(side = "left", padx = 10, pady = 10)[/CODE] In the above code, I understand that "app" is my TK() object. But what … | |
I'M a single parent, 24, and I have a full time job in a factory. That's pretty much killed any change for me to go back to school. I love the computer field and I've been playing around with C# and Python for a little bit and I'M also a … | |
I've been trying to find pygame that will work with python 3 on my Ubuntu machine far a while with no luck. I can find a version that will work with Ubuntu but now for python 3, or I can find one that will work with python 3 but not … | |
I am trying to get into the IT field and I'M unable to go to school. Everything I learn is from books I get vie Amazon.com or Books-A-Million. I don't really know anyone in the programming or IT field to whom I can get guidance and direction. Does anyone have … | |
[CODE]def save_transaction(price, credit_card, description): file = open("transactions.txt", "a") # the "a" means you are always going to append to this file file.write("%s%07d%s\n" % (credit_card, price, description)) file.close() items = ["DONUT", "LATTE", "FILTER", "MUFFIN"] prices = [1.50, 2.0, 1.80, 1.20] running = True while running: option = 1 for choice in … | |
[CODE]import sqlite3 def find_details(id2find): db = sqlite3.connect("surfersDB.sdb") # grap surfer data from database db.row_factory = sqlite3.Row cursor = db.cursor() cursor.execute("select * from surfers") rows = cursor.fetchall()[/CODE] In the code snippet above from "Head First Programming", the syntax for the database code is poorly explained. Is row_factory a call, method, or … | |
[CODE]def find_details(id2find): surfers_f = open("surfing_data.csv") for eash_line in surfers_f: s = {} (s["id"], s["country"], s["average"], s["board"], s["age"]) = eash_line.split(";") if id2find == int(s["id"]): surfers_f.close() return(s) return({}) lookup_id = int(input("Enter the id of the surfer: ")) surfer = find_details(lookup_id) if surfer: print("ID: " + surfer["id"]) print("Name: " + surfer["name"]) print("Country: " … | |
I know there was a problem with one of the recent Ubuntu Linux updates involving Karmic to Lucid that would no longer allow a Windows partition to load. I have not update my Ubuntu since that update release. Does anyone of if it's safe to update yet? Thanks. | |
Could anyone point me to a good C++ compiler for Ubuntu, other than Mono. Note that I was using Visual C++ 6. thanks. | |
In the following program I have a few questions. [B]results.txt[/B] Johnny 8.65 Juan 9.12 Joseph 8.45 Stacey 7.81 Aideen 8.05 Zack 7.21 Aaron 8.31 [CODE]scores = {} result_f = open("results.txt") for line in result_f: (name, score) = line.split() scores[score] = name result_f.close() print("The toop scores were:") for each_score in sorted(scores.keys(), … | |
[CODE]line = "101;johnny 'wave-boy' Jones;USA;8.32;Fish;21" s = {} (s['id'], s['name'], s['country'], s['average'], s['board'], s['age']) = line.split(";") # above, why is "s" and the end of the key list surrounded by parenthesis? print("ID: " + s['id']) print("Name: " + s['name']) print("Country " + s['country']) print("Average " + s['average']) print("Board type: " … | |
[CODE]StreamWriter outFile = File.CreateText ¬ ("output1.txt");[/CODE] In the above line of what, what is File. I see that StreamWriter is a class, outFile is our instance of that class, and CreateText would be a method. But what is the "File." before the CreateText method? Normally when I have created any … | |
I prefer gnome to KDE but I don't know what this is but I thought I might give it a try. If anyone knows what this is and where to get it, please let me know, thanks. [url]http://www.tomshardware.com/gallery/ubuntu-linux,0201--6247----jpg-.html[/url] | |
I'M using Ubuntu and I'M running python 3. I'M trying to find a pygame download for Ubuntu and python 3. I went to pygame.org and followed the Ubuntu link. I eventually found one link for pygame 1.9, which I'M told works for pythan 3. There were two files, amd64 & … | |
I use Ubuntu Linux and I'M running python 3. How do I know what version of pygame to get for python 3? And could someone point me to it? Thanks. | |
Recently a friend of mine updated his Ubuntu Linux and then his Windows partition failed to boot there after. I read up on it and apparently a lot of people are having the problem and it has something to do with karmic to lucid, or something like that I can't … | |
I know a lot of you out there are probably way to stuck up to consider iTunes, I use to be the same way. I felt that I may lose control over my music files or some other ridicules scare. But when I finally did try it, I absolutely loved … | |
I just updated Ubuntu and now my Windows partition will not start from within the grub loader. When I select Windows, the screen is black with a white blinking cursor at the top left of the screen. Any help would be greatly appreciated. Thanks. | |
I'M rather new to Linux and I've just started with Ubuntu. I'M trying to understand the file system. I see that rather than a traditional drive letter like C: , Linux uses a single /. But I guess my real question is, where are programs stored? In Windows they're stored … | |
Since I first moved to Ubuntu, one of my biggest complaints is Totem not having any audio, does anyone have any suggestions? Thanks. | |
The book I'M reading "Head First C#" is trying to teach my about the use of properties, private vs public. But when viewing the following code, I still don't understand why the program is behaving the way it is. The code shows 5 bags of feed no matter how many … | |
I recently uninstalled python 2.6 from my Ubuntu, unbeknown to me at the time, the gnome desktop is reliant on python 2.6. Ubuntu then crashed and now will only load up in Kubuntu KDE. Kubuntu will not let me switch back to Ubuntu gnome, it's not an option. So from … | |
I recently decided to update my version of python from 2.6 to 3.1. At the time I didn't realize that the gnome desktop relied upon python 2.6. In the middle of py 2.6 un-installation, Ubuntu crashed, when it reloaded I could only use Kubuntu KDE. I would just try to … | |
I'M reading the book "Beginning C# Game Programming by Ron Penton". The book is instucting me to create a small framework for a game, the problem is, the book was written for VS 2002 and I'M using VCs 2008 express. I'M instructed to add references to the project, two of … | |
I've had KDE for a while but I didn't like it as much to I stuck with gnome. Today I updated my gnome and a while later I decided to un-install python 2.6 and replace it with 3.0. I noticed that un-install was going really slow. Then my computer suddenly … | |
In the code below I can't understand the line [COLOR="Red"]List<Surface> sfcStars = new List<Surface>();[/COLOR] What's going on here, and what are "<>" those doing in the code, I've never seen the before. I got this code from [url]http://www.tuxradar.com/beginnerscode[/url] [CODE]using System; using SdlDotNet.Graphics; using System.Collections.Generic; using System.Drawing; namespace TroutWars { class … | |
[COLOR="red"]Dog[] dogs = new Dog[7]; dogs[5] = new Dog(); dogs[0] = new Dog();[/COLOR] According to the book I'M reading the second two lines here create instances but the first only creates an array. I'M still learning how to program but it looks to me like the fist line is also … | |
First off, I did google this before hand but most of the answers I got were about assigning attributes, but that's the the trouble I'M having. I'M trying to understand the "this" keyword beging used as a parameter/argument. Here some sample code There is a class by the name Elephant. … | |
In the code below, I'M having trouble with one line of code [COLOR="Red"]MenuMaker menu = new MenuMaker() { Randomizer = new Random() };[/COLOR] The program is a simple windows Form with two main files, Form1.cs & MenuMaker.cs, the second one is a class. What I'M trying to understand is why … | |
I'M reading this tutorial at [url]http://www.tuxradar.com/beginnerscode[/url] at all I have done thus far is enough for an empty game window built with two small .cs files. Here are the error messages. [COLOR="Red"]Line=15, Column=72, Type=Error, Priority=Normal, Description=An object reference is required to access non-static member TroutWars.MainClass.Quit(object, SdlDotNet.Core.QuitEventArgs)'(CS0120)][/COLOR] & [COLOR="Red"]Description=`System.EventArgs' does not … | |
Running Mono on Ubuntu 9.10 Main.cs [CODE]using System; using SdlDotNet; using SdlDotNet.Core; using SdlDotNet.Graphics; using System.Drawing; namespace TroutWars { class MainClass { public static void Main(string[] args) { Video.SetVideoMode(1024, 768); Events.Quit += new EventHandler < QuitEventArgs > (Quit); EventArgs.Run(); } void Quit(object sender, QuitEventArgs e) { Events.QuitApplication(); } } }[/CODE] … | |
I'M trying to build a simple Console.WriteLine program in mono. It build with no errors but there is not output for what I have coded it to say. All I'M getting is ---------------Done---------------- Build Successful. Thanks. |
The End.