15,181 Topics
| |
This demonstration was originally proposed to be posted as a Python tutorial but with further inspection it was deemed more of a "how-to" guide, in this case, how-to create simple animation via Tkinter (Tool Kit Interface) All the necessary elements are included in the attched zip file. This includes: [LIST] … | |
How would you count how many opening HTML tags there were & then closing tags in a line? eg [CODE] for line in something: for match in re.match("[I]opening_regex_here[/I]",line): # will match <H1> or <html> or whatever opentags += 1 for match in re.match("[I]closing_regex_here[/I]",line): # will match <H1> or </html> or … | |
| I have a string, say for example: [CODE]str="aasd<script>"[/CODE] How do I make Python to note down one character at a time until it encounters the '<'? I know it has to be a loop, but which function? Thanks |
| Hey guys.... I use Python 2.6.2. I recently created a program which accepts commands from my website, here's the code I used: [CODE]import urllib import subprocess import time open_site=urllib.urlopen("http://www.sravan953.webs.com/command_python.htm") read_site=open_site.read() def run_program(): current=time.asctime() print 'Runnning program'+' ['+current+']' subprocess.call(read_site) def check_argument(): current=time.asctime() if read_site=='': print 'No command given'+' ['+current+']' timer() else: … |
I am using pygame I want my program to read an image file that only has black on it and whenever the character moves over a part that has black on it, he stops moving, any ideas on how to get started? The black image is not to be shown. | |
I have the following script: [CODE] import sys import os import re pages = [] if len(sys.argv) > 1: for root, dirs, files in os.walk(sys.argv[1]): for f in files: filename = os.path.join(root, f) if (filename.endswith('.html')) or (filename.endswith('.htm')): pages.append(filename) for page in pages: f = open(page, "r") count = 1 for … | |
| Hi, is there an internal module / method to change the colour of the text in the pythonwin? I am asking this so that I can make more exciting text based games |
Hi, I'm trying to build a web server in Python, and here is what I have so far: [CODE] Code: from http.server import HTTPServer, BaseHTTPRequestHandler class RequestHandler(BaseHTTPRequestHandler): def _writeheaders(self): self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() def do_HEAD(self): self._writeheaders() def do_GET(self): self._writeheaders() self.wfile.write("""<HTML> <HEAD><TITLE>Sample title</TITLE></HEAD> <BODY>sample text</BODY> </HTML>""") serveraddr = ('', 8080) srvr … | |
I'm stuck trying to get mechanize working as part of a larger project I'm working on. I'm trying to logon to the following website which I am registered at (but not as "bob" as below obviously): [url]http://www.morningstar.co.uk/uk/membership/signup.aspx?loginType=1&lastvisit=%2fuk%2fportfoliomanager%2fportfolio.aspx%3fSite%3duk%26lang%3den-GB[/url] I think I've managed to select the correct form (?) but I'm getting … | |
Hey I'm new here registered today. I've been trying to import some definitions from other .py files in the same folder, but for some reason IDLE wont recognize/ import them and keeps telling me they arent defined. I have tried From file import * and was wondering if my syntax … | |
I'm brand new to python, so i need a bit help parsing. Why i need parsing? so my irc bot can reconignise me. here is my code: [CODE]#### # Made by Fellixombc # pythonbots.no-ip.org:8080 (coming soon) # Contact: Fellixombc@hotmail.com (add me on msn, I don't check my email's) # Copyright … | |
Hello! I recently started learning Python, and I'm trying to install the package GASP ([url]http://pypi.python.org/pypi/gasp/0.4.5[/url]) in order to be able to code some graphics. However, the file is of type EGG. I found that I need to install EasyInstall in order to be able to install EGG files. (The download … | |
Hi all, I'm trying to write a video player with wxpython and pygst. The main Frame has one panel and one notebook. On one page of the notebook, I need to play multiple videos at the same time. On this page, I declare two CameraPanel instances (code below) and put … | |
| Hi, I have this code: [code=python] def yn(input): if input.lower == 'y': return True else: return False def limestone(): I = raw_input("are there shelly fragments? (y/n)") if yn(I): print "Shelly limestone" else: print "chalk" def crystals(): I = raw_input("Are the crystals big?(y/n)") if yn(I): big_crystals() else: print "Basalt" def big_crystals(): … |
I'm having a simple problem. I'm using this class to do some stuff with another module. Now, for some reason the self.database and other variables are not able to be accessed by the other methods. I thought _init_ was suppose to work as a constructor, thus the other methods should … | |
How do I search a string for anything? What I mean is, I need to say: [code=python] if line == 'playername = (any name)': temp = line.strip().replace('playername=', '') return temp [/code] Any ideas? | |
Ok, so this is kind of a complicated question... but... Ok so I have a python script, you enter some numbers it gives you some numbers back that sort of thing. But of course right now it just looks like a black window with text. kind of like [URL="http://blog.benhall.me.uk/images/InstallingWindows2008EnterpriseCoreServe_F3A1/6Cmd.jpg"]this.[/URL] But … | |
Hello everyone,i am pretty new to GUI programming,am currently playing around with PyQt4.I would like to know how the ui for yahoo was created.Because the controls provided by pyqt are just normal gray-colored stuffs.Could it be that those fancy control or widgets are graphical images done with photoshop,gimp etc? Please … | |
I need to take a text file of a number of gene sequences in fasta format eg >geneA agctactactacgatcgaacgtagctactactacgatcgaacgtagctactactacgatc gaacgtagctactactacgatcgaacgtagctactactacgatcgaacgtagctactact acgatcgaacgtagctactactacgatcgaacgtagctactactacgatcgaacgtagct actactacgatcgaacgtagctactactacgatcgaacgtagctactactacgatcgaac gtagctactactacgatcgaacgtactacgatcgaacgta and put it into: geneA agctactactacgatcgaacgtagctactactacgatcgaacgtagctac where all of the sequence is on one line. I can concatenate it in excel for one sequence but i have … | |
Hi, I have never been into sockets, so I decided to dive in. With some help from devshed, I managed to make a server as shown below. But I cant get it receive data from client. Please correct me :) ERROR: socket.error: (10057, 'Socket is not connected') [CODE=python] import socket … | |
[CODE]def who_knows(a, b): """ a and b are lists """ c = [] for i in a: if is_mem(b, i): c.append(i) return uniqify(c) def is_mem(a, elem): for i in a: if i == elem: return True return False def uniqify(arr): b = {} for i in arr: b[i] = 1 … | |
this is another pretty simple question, but i've been trying to do it, and cant get it basically what i need is pretty simple, its like say you have a list of 5 numbers. now you need to print out all the lists of possible 3 numbers from those 5 … | |
im sorry this is kind of a silly question i know, but does anyone know any succesful ways to change a .py into a .exe? like so that someone without python installed on their computer can run it? i've seen this topic in a couple places but everything i've tried … | |
I am working on a script that will eventually run as scheduled via chron. This script will access ftp site and download most recent file added to directory. As I want this to be automatic, I wont have a file name to pass. How do I tell python which file … | |
Hello, I am trying to embed a html file (a report from sql) in to a word document in a particular location. I am trying to get this done using the Office Interop. 1) How can I embed a html file in to a word document ? 2) How can … | |
So, I always thought that it was possible to return dictionaries in Python. I was wanting to do this because I would prefer not to use globals. However, I am having trouble with returning my dictionary. Code: [code=python] #!/usr/bin/python # 6/9/09 def loadWords(): pathstart = "/home/foo/Documents/PyScripts/Vocab/Lists/" print "What is the … | |
I've been tearing my hair out for 2 days over this, hopefully someone here can help me. I'm trying to scrape the price data off the following webpage: [URL="http://www.morningstar.co.uk/UK/snapshot/snapshot.aspx?lang=en-GB&id=F0GBR04S4X"]http://www.morningstar.co.uk/UK/snapshot/snapshot.aspx?lang=en-GB&id=F0GBR04S4X[/URL] The value I want currently stands at 6.19 (i.e. the NAV value on the right hand side). I currently have a … | |
Hi all, I'm developing a system in Python. When the app has been a time running, its CPU consumption goes from 10% to 96% and stays there until I close it. Has anyone been in this situation and has a clue to solve it? My program uses Threads, pyserial and … | |
I am using the OptionMenu with Tkinter. I have found that sometimes when I use the OptionMenu widget, I encounter a problem. After the user clicks on the OptionMenu and selects an option, sometimes other widgets such as buttons in the window will not work until the user clicks somewhere … | |
Hello. I'm having trouble about drawing a border around a listctrl [code]"""Main module for psutils GUI""" __version__ = "$Revision: 8 $" # $Source$ import random import wx import psutil ID_EXIT = 110 class MainGUIFrame(wx.Frame): """Main frame. Shows processes and graph""" def __init__(self): """Initialization of the frame""" wx.Frame.__init__(self, None, -1, "psutils", … |
The End.