1,175 Posted Topics
Re: Will something like this do? [code=python]import Tkinter as tk def set_text_newline(s): """start text s on a new line""" text1.insert(tk.INSERT, '\n' + s) root = tk.Tk() # width=width characters, height=lines of text text1 = tk.Text(root, width=50, height=12, bg='yellow') text1.pack() set_text_newline("line one") set_text_newline("line two") set_text_newline("line three") root.mainloop() [/code] | |
Re: Something like this could do it: [code=python]mystr = 'Hello everybody. Some times THERE ARE upper case words' mylist = mystr.split() #print mylist newstr = '' for word in mylist: if word[0].isupper(): word = word.capitalize() newstr += word + ' ' print newstr """ my output --> Hello everybody. Some times … | |
Re: Talking to my physics professors and fellow students, lithium ion battery electric cars or compressed air powered cars are much more feasible than hydrogen cars. They use electricity more directly. Hydrogen fuel is a convenient buzzword for politicos. An easy thing to sell to an uneducated public. Oh, we have … | |
Re: If you would write range() in Python you would have to do something like this: [code=python]def range(start, stop=None, step=1): """if start is missing it defaults to zero, somewhat tricky""" if stop == None: stop = start start = 0 # rest of the code here ... [/code] | |
Re: When you make matriz global to the class it just keeps appending to it. Change your code this way: [code=python]# Square matrix import random class Matriz: """Math operations with matrixes""" #matriz = [] # don't make this global!!!! grau_matriz = 0; def __init__ (self, grau_matriz, inicio): self.grau_matriz = grau_matriz #Decides … | |
Re: I streamlined your code a little: [code=python]import random print "Enter 3 integer numbers and i'll choose 1 at random" while True: a = input("first number? ") b = input("second number? ") c = input("third number? ") # put your numbers in a list nmlist = [a, b, c] if type(a+b+c) … | |
Re: On your class and Tkinter GUI code, I would recommend that you first get your feet wet on some smaller sample code. As it is now, it makes not much sense. | |
Re: In this case you are better off to use just Python. Actually, regular expressions aren't necessarily faster. I added plenty of comments to help you: [code=python]ts = 'xyz abc mno def' # separate at space to create a list space = ' ' qs = ts.split(space) # search for these … | |
Re: This article needs somebody playing the violin in the background. | |
Re: Vista is a bitch isn't it? If I get a chance, I will try it on my friends Vista box. | |
Re: [QUOTE=Ancient Dragon;621781]Of course that is true -- In the USA they are called senators, congressmen, and lobbyists.[/QUOTE]Nope, they are called moneybag bankers. | |
Re: Use wx.DisplaySize(), it gives width, height tuple of the display screen | |
Re: I find that PyScripter is more ornary with errors on Widows Vista than it is on Windows XP. Might be the OS that causes the problem. Look at the popup window title when it it is forced to shut down under Vista! It is an OS window not a PyScripter … | |
Re: Here is a wxPython tutorial that I have used: [url]http://wiki.wxpython.org/index.cgi/AnotherTutorial[/url] | |
Re: The Python function eval() will take a string and try to evaluate/interpret it. BTW, the PyScripter IDE allows you to interpret your source code without having to create an official file. I hate the Python shell, it's okay for one liners only! If I were stranded on an island and … | |
Re: First, welcome to the forum! What 'slate' is really telling you is that input() is for numbers and raw_input() is for strings. Using input() has certain risks since you can also enter a command and it will excute it. Anyway, if you want to use op = input(">") then op … | |
Re: Fuse, very nice code ad explanation! Python has a few string functions that make your code even easier. Simply use line.rstrip(). The default removes any trailing whitespace characters like '\n': [code=python]line = '0.00\t2.869e-12\t7.715e-08\t0.000e+00\t0.000e+00\n' # remove any trailing whitspace characters (default) line = line.rstrip() line_list = line.split('\t') print line_list # ['0.00', … | |
Re: On Windows you are looking for is a DLL called pyuno.dll. On my installation it is in: C:\Program Files\OpenOffice.org 2.4\program\ You may have to copy that DLL into a folder mentioned in PYTHONPATH, so Python can find it, or you can start your program with: [code=python]import sys # appends to … | |
Re: It would be nice to have an actual example of the HTML source code or at least the web site's URL. As Jeff said, the BeautifulSoup module (an HTML scraper) is great, but a has a steep learning curve. An interesting project, so let us know any progress. | |
Re: There are a few things the frame builder does not do, you have to do those in the Boa editor yourself. Here is an example: [code=python]#Boa:Frame:Frame1 import wx import wx.grid def create(parent): return Frame1(parent) [wxID_FRAME1, wxID_FRAME1GRID1, ] = [wx.NewId() for _init_ctrls in range(2)] class Frame1(wx.Frame): def _init_ctrls(self, prnt): # generated … | |
Re: I am not smart enough to take this test, so I will never know if I am stupid. | |
Re: There a re so many pretty girls knocking at my door all the time, I would like 24 hours without them. | |
Re: I have never seen Carl Rove on Fox News, but he should fit right into the motley crew of characters there. With a face like that what would you expect to come out of it! I watch the Fox News Channel, get my laughs, and leave before permanent brain damage … | |
Re: If you start to die in an elevator, be sure to push the Up button. | |
Re: Welcome to the often childish world of Vista's enhanced security. The latest stable release (build 210) is dated September 22, 2006, most likely pre Vista. You could post this question on: [url]http://python.net/crew/mhammond/win32/FAQ.html[/url] | |
Re: rJ[i,1] is a float and most like never exactly equal to zero, but within a narrow range of zero. | |
Re: Python has a module csv that will make your life easier handling csv files. | |
![]() | Re: You are not the only one, python-forum.org comes up sickly and unusable. Judging from past periods of administrative neglect, this may take a long time to fix. Wonder where 7stud went to? |
Re: A slenderizing dress, absolutely good for most any mom! | |
Re: [QUOTE=Lardmeister;528869]Well, it's a market. Some other stall offers cheaper goods, people will buy there. That's about all the logic there is.[/QUOTE]Not totally true, in this market you most often have to sell something first before you can buy. | |
Re: Your initial problems stem from the fact that you are mixing tabs and spaces in your indentations. It really loused up the code on my editor. Stick with spaces (4) only! Also, when you click the stop button during sleep(1), it most likely will not respond. You may need to … | |
Re: If you are using Windows you can do this: [code=python]# get the character of a key pressed (no return key needed) # works only in the command window and with Windows OS from msvcrt import getch print "press a char key (escape key to exit)" while True: z = getch() … | |
Re: When I grow up I would like to be more like my hero, the actor and writer James Earl Jones. I have to practice on my deep voice though. | |
Re: In your case I would worry a lot. If your wife gets interested in computer programming, she could turn into a 'computer nun' and totally neglect you! BTW, your wife wouldn't be a chain saw enthusiast, would she? | |
Re: If your code gets a little longer and more complex, you need to establish a namespace for the different imported functions. It helps you understand the code better and avoids collisions. For instance Tkinter and PIL both have Image. For example, to save on typing I always use: [code]import Tkinter … | |
Re: My passion is cars. I always have the hood up fixing something. Of course, all I can afford is some old clunker. | |
Re: The Flintstones and Jetsons were neat, looking into the past and the future as only cartoons could do. Love those reruns and old DVDs. | |
Re: You could do one on volumes and surface area calculations of boxes, cylinders, spheres, or cones. | |
Re: It could be as simple as this: [code=python]text = """\ Hello all. I have a text file which has a number of links ... """ html = "<title></title><html><body>" + text + "</body> </html>" print html fout = open("test_html.htm", "w") fout.write(html) fout.close() [/code] | |
Re: Somewhere in your loop you have to build up your encrypted phrase. Also, a phrase will contain spaces, so you need to take care of that. | |
Re: Please use code tags with your code to preserve the indentations. Otherwise the code is very difficult to read and not too many folks will help. [noparse][code=python][/noparse] your Python code here [noparse][/code][/noparse] | |
Re: Please use code tags with your code to preserve the indentations. Otherwise the code is very difficult to read and not too many folks will help. [noparse][code=python][/noparse] your Python code here [noparse][/code][/noparse] This code will not work: [code]if response == "yes" or "OK" or "Yes" or "ok": [/code]I has to … | |
Re: I grew up in a very poor neighborhood and went to a very poor public school in the Detroit area. Most of my education I got from my uncle who was a professor at the University of Detroit. This way I didn't have to learn to squirt milk out of … | |
Re: @briansmall: Well thought out! One subject that does not fit one liners. Darn, and I like those. | |
| |
Re: Some people in the US sit in front of a turned off TV and find it more entertaining than turning it on. | |
Re: Let's see if I understand that right: [code]A |:---------------| Bb |-[]-------------| C |----------------| Db |---:------------| D |----[--]--------| Eb |--------::------| E |----------::----| F |------------::--| Gb |----------------| G |----------------| [/code]Where the ':' is a certain instrument from a wave file would play that note? |
The End.