614 Posted Topics
Re: So i take it your making you own module and importing it right? Well if you import a module you can access its variables by going [code=python] module.variable [/code] If you have imported the module then the module is global and therefore there is global access to the variable. If … | |
Re: try using wx.EVT_TEXT and bind it to the Rich Text control. | |
Re: In your code you go: [code=python] Monster.getAttributesInfo() #and weapon.getAttributesInfo() [/code] The problem with this is that you are not instanciating your class. First creat an instance of the class and then you can call methods then. Otherwise you will keep getting this error. | |
Re: You would use a GUI module such as wxPython to do it. As to not just give you the answer but to point you in the right direction here is a basic frame with one button on it. [code=python] import wx app = wx.App(redirect=False) frame = wx.Frame(None, wx.ID_ANY,title = "Example") … | |
Re: Try editing it in IDLE, you are probably getting an Error/Exception. If you double click it to start your python script then if there is an error it will not tell you what it is, the window and program will just close. If you run it from IDLE (F5) then … | |
Well daniweb is a pretty vast community right? People here live all around the world. Well with the whole thing about fuel being hugely expensive all around the world i thought it would be good to see the price of fuel all around the world. So just post your location … | |
Re: You have no choice when it comes to ordering dictionaries. If you want it to print nicely then you CAN order [icode]gameTable.keys()[/icode]. Here is how i would do it: [code=python] gameTable = {(-5,10):0,(-4,10):0,(-3,10):0,(-2,10):0,(-1,10):0,(0,10):0, (1,10):0, (2,10):0, (3,10):0, (4,10):0, (5,10):0, (-5,9):0, (-4,9):0, (-3,9):0, (-2,9):0, (-1,9):0, (0,9):0, (1,9):0, (2,9):0, (3,9):0, (4,9):0, (5,9):0, (-5,8):0, … | |
Re: Well the problem is that in your text file you may have an empty line and therefore splitting it will give you a list with nothing in it and therefore if you try and acces the variable at location 0 there is nothing there. A list index out of range … | |
Hi everyone, I have been fiddling around with a speech recognition program for a while now and i always had something that bothered me. Here is my code i have been using. It is the example code from code.activestate.com [code=python] from win32com.client import constants import win32com.client import pythoncom """Sample code … | |
Re: Well i can just say that it is not the code's fault. It runs of windows XP fine so i would have to say that the problem most likely lies in the installation of something or your operating system. | |
Re: Is this what your talking about? [code=python] import random count = input("How long shall the sequence be?") seq = ''.join([random.choice('AGTC') for x in range(count)]) print "Length:",count print ">",seq [/code] | |
Re: Try putting an r before the string to make it a raw text and therefore you wont get suff ups due to escaped characters: [code=python] elif choice == 5: h = open(r"C:/Users/Dhylan/Documents/"+raw_input()+".txt") [/code] Hope that helps, if not the please help us help you by posting the exact error you … | |
Re: There are a few different sort methods you could use. One of which you can find here: [url]http://www.daniweb.com/forums/thread153427.html[/url] This uses insertion sorting to sort a list of numbers. It should work for this as well. | |
Re: Have a look at vega's code snippet on this: [url]http://www.daniweb.com/code/snippet393.html[/url] I think it is what you want. Otherwise just explain exactly what you mean by storing it in a .py file. | |
Re: Yeah i'm fed up with the bush administration and im really glad its going. I spent today watching the election and from here in Australia you get the general feel that people here would rather Obama in. Here we have Kevin Rudd in and he is a pretty young guy … | |
Re: Okay, do you have any code so-far or are you starting from scratch? | |
Re: Yeah you cant assign values to a string. Thats what your program is trying to do. Well i would advise using a dictionary for this one: [code=python] d1 = {} d2 = {} for swipeload in range (0, 15, 1): d1["E"+str(swipeload)+"_Path"] = os.path.join("data","E"+str(swipeload)+".gif") d2["E"+str(swipeload)] = pygame.image.load("E"+str(swipeload)+"_Path") [/code] This now has … | |
Re: What happens now when you hit return? Oh and for the algin left and right just bind something to this code: [code=python] #to align left self.textarea.ApplyAlignmentToSelection(rt.TEXT_ALIGNMENT_LEFT) #to align right self.textarea.ApplyAlignmentToSelection(rt.TEXT_ALIGNMENT_RIGHT) [/code] Hope that helps | |
So. Today i had this though. What is one dollar times two dollars. Instantly the thought sprang to mind that it would be two dollars right? Becuase 1 x 2 = 2. But then i though wait. What about the dollar sign? That means that this has become algebra! So … | |
Hi guys, I was just wondering how far peole have ever gotten in the python challenge? if you havent heard of it, it is a series of python based problems that explore many programming techniques including regex and images. If you havent tried it the link to it is: [url]http://www.pythonchallenge.com[/url] … | |
Hi Guys, I was wondering if there was any way in which you can change the opacity of a window in wxPython. I would like to create a window that is mostly see through but so far i have found no way to do that. My program is a simple … | |
Re: Okay, what it your whole program try and do? I'm not quite sure with the information given. | |
Hi guys, I was looking at some of the commercial IDE's today. Most notably being wingware's python IDE personal edition. I was wondering wether people thought wether the $30 you need to pay for it is worth it or is it not that great when it comes to it. Any … | |
Re: I really enjoy pyScripter on windows, it lets you debug as well as run the script. Syntax highlighting, automatic indentation. Its a great piece of software. | |
Re: I used to do this is i wanted to restart the file: [code=python] exec file("File Name Here") [/code] That will re-open your python program again. | |
Re: If your using a GUI you may want to take a look at this piece of code: [url]http://www.daniweb.com/forums/post623822-10.html[/url] | |
![]() | Re: This is a sorting function. It grabs a number from the list, that is now the key. Then in the while loop it moves the values to the right if they are more then the key, so essentially, it gets a number from a list. It then compares it with … |
Re: You can also get it by using the class.__dict__ method. [code=python] >>> class tester(object): def f1(self): print '1' def f2(self): print '2' def HELLO(self): print 'Hello' >>> print tester.__dict__ {'f1': <function f1 at 0x00BB8AF0>, '__module__': '__main__', 'f2': <function f2 at 0x00BB8B30>, '__doc__': None, '__dict__': <attribute '__dict__' of 'tester' objects>, '__weakref__': … | |
Re: If you want help for syntax. There is an easy way to do it. you go something like this for your example: [code=python] # just type each line in the interpreter >>> import os >>>help(os.execv) #displays info [/code] in your case it shows this: [code=python] Help on built-in function execv … | |
Re: Well there might be a better way but you could go something like: [code=python] # lets assubme variable self.frame is your frame class Frame(wx.Frame) def __init__(self) wx.Frame.__init__(self,None,pos = (100,100)) self.Show() self.Dialog() def Dialog() d = wx.Dialo("arguments here") d.Position = (self.frame.Position[0]+(self.frame.Size[0]/2,self.frame.Position[1]+(self.frame.Size[1]/2 d.ShowModal() [/code] I think that should work. It takes the … | |
Re: okay, i know this is not exactly what you asked but in your code i noticed a lot of: [code=python] print "" [/code] You dont need to do that as just going [code=python] print [/code] Without the "" marks will do the exact same thing. Or you could use [code=python]print … | |
Hi I have been mucking around with VPython for a bit now and i can use it for basic 3D Python but i have not yet worked out how to do things that arent the usual, add square, add arrow, add sphere. So i was wondering if it was even … | |
Re: just wanted to say that i found that that [url]www.diveintopython.org[/url] was not down so you can use that if you want. | |
Re: Have you had a look at the wx.ProgressBar? Becuase in the Docs and Demos they show a way to do just that. You might have to decipher the un-needed code though. | |
Re: when you go. [code=python] if word in tuplelist: #do stuff [/code] That is a problem. The reason is your comparing something that looks like this: [code=python] "Hello" [/code] To something that looks like this [code=python] [("hello","something you say as a greeting")] [/code] Now those dont look quite the same right? … | |
![]() | Re: I cant get the link to work. It says this: [quote] You have attempted to access code for an article that does not exist. Create this article first. If the article used to exist, it may have been deleted. [/quote] Am i the only one getting this problem? |
Re: Really? This a parody, it sounds exactly like judge judy on a completly normal day! Ha ha ha, very good. :) | |
Hi Im pretty new to the whole C++ programming language but after learning python and java i decided to give it a go. I have been using tutorials at [url]www.cplusplus.com[/url] and that has been working fine but i came across a bit of code today i couldn't understand. It went … | |
Re: By tk you dont mean Tkinter do you? Because that is packaged with python. | |
Re: I think the best thing you can do for the first question is just ask us becuase i really dont think there is any IDE in python that will do that. | |
Re: another way to do it is to Destroy the image every time so the code would look like this: [code=python] if self.image: self.image.Destroy() self.image = wx.StaticBitmap(image, etc. etc.) [/code] | |
Re: couldnt you just import mod1 into your mod2? That way you could then access all methods. | |
Re: the asterix means a parameter that will catch all parameters that arent used in the first ones (if there are any) and all the left over parameters that are given to the method are then made into a list. For a reference see here: [url]http://www.pasteur.fr/recherche/unites/sis/formation/python/ch06s06.html[/url] | |
Re: The problem is that loop1 exists in two places. In the global scope and in the function scope. This means that the loop1 in the function is different to the loop1 in the main body. To get around this you can add [icode]global loop1[/icode] to your program. | |
Re: that just makes sure the program knows where to look to find the variables. So if more than one thing was in the formatted string you would use a tuple. | |
Re: This is a direct quote from [url]http://en.wikibooks.org/wiki/Python_Programming/Exceptions[/url] [quote] Custom Exceptions Code similar to that seen above can be used to create custom exceptions and pass information along with them. This can be extremely useful when trying to debug complicated projects. Here is how that code would look; first creating the … | |
Re: why are you using a list not a dictionary? | |
Re: Why use the getattr? I think gribs way of doing it probably is what you want. | |
Re: Are you using wxPython? In that case the event you are looking for is: [icode]wx.EVT_LEFT_DOWN[/icode] |
The End.