4,305 Posted Topics
Re: You have two separate programs, so you might have to create two separate projects. | |
Re: Generally its done this way ... [code=python]import pygame # optional pygame.init() # create the screen (or pygame window) screen = pygame.display.set_mode((800, 600)) # fill the screen black (default) screen.fill((0, 0, 0)) # pick an image you have (.bmp .jpg .png .gif) # if the image file is not in the … | |
Re: [QUOTE=BearofNH;749071]That doesn't square with what you said in the original post ... you know ... the part that reads "I can't seem to figure it out." For all I know, English isn't your native language. Just wanted to make sure we start out with common definitions. Also it appears you … | |
Re: Played around with it a little ... [code=python]# use PIL to count pixels in letters I and O # image file needs to be a bitmap file to maintain # red (255,0,0) and black (0,0,0) pixel colors correctly from PIL import Image # img_I.bmp --> 50x50 black bg + red … | |
Re: Not sure if I follow this correctly, but you start with a one dimensional list and append other lists to it. For example ... [code=python]qq = [] for row in range(3): for col in range(3): qq.append([row, col]) print qq """ my output --> [[0, 0], [0, 1], [0, 2], [1, … | |
Re: Let me rewrite your code a little to illustrate this ... [code=python]from Tkinter import * master = Tk() def draw_circle(event): x1 = event.x y1 = event.y x2 = x1 + 10 y2 = y1 + 10 # note that c1 is simply a numeric id c1 = cv.create_oval(x1, y1, x2, … | |
Re: In Dev-C++ go File > New > Project > Console Application > give the project a name > OK > create a directory, open it and save the .dev file there. A skeleton file comes up, flesh this one out with your code. The skeleton file has system("PAUSE") and the … | |
Re: Catch 22 here, the various operating system backends are used (auto-detected) to make the media controls work cross platform. | |
Re: Normally the free market balances things out, but when the the Federal Reserve Banking System in the US comes in with ridiculously low interest rates, that are less the half the inflation rate, things turn unreal and unbalanced. The banks are sitting on so much freshly printed money that they … | |
Re: There is an English dictionary file attached to: [url]http://www.daniweb.com/forums/post160495-8.html[/url] The file contains one English word per line, so pick one at random. | |
Re: Use the slicing operators defaults and -1 as the step ... [code=python]# slicing operator seq[begin : end : step] # defaults are index begin=0, index end=len(seq)-1, step=1 # -begin or -end --> count from the end backwards # step = -1 reverses sequence message = raw_input ("Enter any message...")[::-1] print … | |
Re: If I read your question correctly, you are thinking about something like that ... [code=python]# create a string of random '0' and '1' characters # then replace '0' with '001' and '1' with '010' import random size = int(raw_input("How long should the string be?")) # only the characters in the … | |
Re: Where it shows includes = ['PIL'], try to replace 'PIL' with 'PYOpenGL3' or whatever your import module is ... [code=python]# Py2Exe version 0.6.9 setup file for console programs. # # If this is a windows GUI application replace the last line with # windows = [{"script": 'myFile.py'}] ) # # … | |
Re: Classes don't make functions obsolete. The beauty of Python is that you can go either way. It's up to you, if a class makes sense, use it. I use classes in most GUI programs, using inheritance is very common. Also, the program looks more organized and simply makes life easier. | |
Re: I am not sure if the vice president makes such a difference, as long as he/she doesn't suffer from "foot in mouth" disease. | |
Re: So what does your initial code look like? What error messages are you getting? | |
Re: Of hand, I would say main vertical sizer mains is missing. | |
Re: You really should use module pickle for that ... [code=python]# use module pickle to save/dump and load a dictionary object # or just about any other intact object import pickle # create the test dictionary before_d = {} before_d[1]="Name 1" before_d[2]="Name 2" before_d[3]="Name 3" # pickle dump the dictionary fout … | |
Re: If you are using wx.grid.Grid, there is an example here: [url]http://www.daniweb.com/forums/post666940-59.html[/url] | |
Re: To do this you will have to adapt your code to a modified Python called Cython or Pyrex. See: [url]http://wiki.cython.org/[/url] For smaller projects you can also look into the Boo language that uses Python like syntax and connects to the .NET C# compiler. For an example of the Boo language … | |
Re: If you do reseaarch on global warming, it will be very difficult to get funding, if you do not subscripe to the 'gorist' junk science view of things. As jwenting says, this view has been elevated to the status of a religion. | |
Re: On Windows systems Python uses wx core DLLs written in C++, together with PYD files (similar to DLLs) and just plain old Python code, you might call these wrappers, to do its magic. | |
Re: I think we had that just a few weeks ago, anyway here is an example how to do this ... [code=python]# create two frames with wxFrame, only one is showing import wx class Frame1(wx.Frame): def __init__(self, parent, mytitle): wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle) self.SetBackgroundColour("green") # pass frame1 to frame2 as instance … | |
Re: Latest news in Tennesee: Another two nut cases with a car full of guns were caught planning to shoot Barack Obama. | |
Re: Wonderful footage! The Israeli police should have simply allowed them fight and let the winner take all! :) | |
Re: I think Nancy Reagan looked and dressed better than Jackie! | |
Re: Dubya already has a Scottish Terrier named Barney. What is it with names starting with a B? So Blair would be Poodle #1 and Brown would be Poodle #2 at best. I guess the reference to the dog was the humour portion of Obama's news conference, since he refers to … | |
Re: GrimJack, finally a good use of the otherwise wasted space above our highways. Looks like the old eggbeater windmills should work well and could even be mass produced by our sluggish car manufacturers. | |
Re: Britain is still paying off debts that predate the Napoleonic wars because it's cheaper to do so than buy back the bonds on which they are based. | |
Re: I heard this from a 120% Republican: [QUOTE]The US Postal Service created a stamp with a picture of President Bush to honor his achievements. In daily use it was shown that the stamp was not sticking to envelopes. After a month's testing, a special presidential commission made the following findings: … | |
Re: [QUOTE=GrimJack;722699]No wonder she crashed - she was on the broom backwards.[/QUOTE]You know in all my years I have never learned how to fly a broom properly! | |
Re: Hello Byron! I would like to ask you to play real well on your electric bass guitar. :) | |
Re: If a deaf person has to go to court, is it still called a hearing? | |
Re: Take a look at this wxPython code example at: [url]http://www.daniweb.com/forums/post627032-17.html[/url] It shows you how to use an image as a background to put widgets on. In general, pygame is more applicable for games, but there aren't as many example here on DaniWeb. | |
Re: tyincali explained that very nicely. [QUOTE]And is 'background.SetSizer(verticalBox)' saying verticalBox is parent of background? [/QUOTE]You are simply setting the main sizer, background is still the parent. Remember that the first object inside the () is not necessarily the parent. In your case only the widgets have a parent argument: wx.Frame(parent, … | |
Re: Hello Vernon, and welcome to the Python forum. We are a small, but growing number of Pythonians, Pythononistas and Pythonurus. I see you didn't waste much time and already posted on the forum. Hope you enjoy programming in Python as much as I do. | |
Re: Take a look at ... [url]http://www.daniweb.com/forums/post723559-152.html[/url] ... to learn a few things about turtle drawing. | |
Re: I think you might mean this: [code=python]# access count using a bookie or helper function # (code from G-Do) def bookie(func): """helper function""" func.count += 1 def f3(): bookie(f3) # your code goes here f3.count = 0 for k in range(10): f3() print "Function f3() has been accessed", f3.count,"times" """ … | |
Re: My first PC had an RCA CMOS elf chip used by NASA in those days. Used to program in machine code, assembler, Forth, Basic, C, Pascal (Delphi), and now mostly Python. Yes, it has taken up many hours of my life, but it has not taken over. | |
Re: I have played around with VPython, looks like I have to do some more. Here are some of my favorite programs ... [code=python]# experiments with visual Python (VPython) # free download from http://vpython.org # bounce a ball on the floor (no wind resistance) # drag the right mouse button to … | |
![]() | Re: I think the game is also called "Tic Tac Toe" just take a look at: [url]http://en.literateprograms.org/Tic_Tac_Toe_(Python)[/url] It goes through great detail how to create a simple game. |
| |
Re: Ene, you are using global instances, so the frame.panel1 or frame.panel2 reference is actually not needed. You can just use panel1 and panel2. However, your approach keeps things together. | |
Re: Good day! Don't be shy, let us know a bit more about yourself. Technical stuff, hobbies, whatever. Should you use or want to use Python, visit the Python forum here. [url]http://www.daniweb.com/forums/forum114.html[/url] or ... [url]http://www.daniweb.com/forums/thread20774.html[/url] | |
Re: Zeek welcome to our friendly web site. Being new to computer programming you might like to acquaint yourself with a great starting language called Python. Visit the Python forum here. [url]http://www.daniweb.com/forums/thread20774.html[/url] |
The End.