15,190 Topics
![]() | |
![]() | [CODE]from Tkinter import * root = Tk() tipwindow = None # Creates a tooptip box for a widget. def createToolTip( widget, text ): def enter( event ): global tipwindow x = y = 0 if tipwindow or not text: return x, y, cx, cy = widget.bbox( "insert" ) x += … |
I have made a simple game that I want to add sound effects to. I have the short clips and can get them to work with the following command: import os os.startfile("filename") It plays fine, but the problem is that it plays the file(s) with windows media player: effectively taking … | |
The idea is to have an HTML page that looks like this: PROJECT1 Send what goes into the web form below to a python script! _________________________________________________ ____ | Input some text! | | GO | |_________________________________________________| |____| When the user hits "GO", the text somehow goes into script.py that does … | |
Help! UnboundLocalError: local variable 'B' referenced before assignment. Thanks! if a >= 3: A = (3 ^(int(log((a/3), 2)* 3))) if b >= 3: B = (3 ^(int(log((b/3), 2)* 3))) if c >= 3: C = (3 ^(int(log((c/3), 2)* 3))) if d >= 3: D = (3 ^(int(log((d/3), 2)* 3))) if … | |
Hi all, I'm working on my python script as I'm pulling the data from the sqlite3 database. I'm trying to convert the string object to datetime object, but I have got a problem with the code as I get the error when I'm trying convert from the string object to … | |
Hi guys, I'm working on my python script to create the button for tv programs. I know how to create the variable to get the program title for the programs which I have to pull the data from the sqlite database. I can also create the variable for the height … | |
I'm using python to try and talk to my Arduino with pyserial. The code should wait for an input from COM5, (the arduino), and then sends a 1 and waits for the response. import serial connected = False ser = serial.serial("COM5", 9600) while not connected: serin = ser.read() connected = … | |
Hello, I am generating batch qr codes using the qrcode 5.0.1 package and the following code: from qrcode import * import os,dateutil import pandas as pd from PIL import Image #Importar base de dades pathFile = ('E:\Usuarios\Daniel\Documents\APNAE\QR\Llistat_socis_alta.csv') socisAPNAE = pd.read_csv(pathFile, delimiter = ';', encoding='ISO-8859-1') #generar codi QR for i in … | |
Hello, I have a code which generates QR codes from a csv file: #Importar base de dades pathFile = ('E:\Usuarios\Daniel\Documents\APNAE\QR\Llistat_socis_alta.csv') socisAPNAE = pd.read_csv(pathFile, delimiter = ';', encoding='ISO-8859-1') #generar codi QR for i in range(0,len(socisAPNAE.index)): soci = socisAPNAE.iloc[i,1:6] nom = socisAPNAE.iloc[i,1] nom = nom.encode('latin-1') qr = QRCode(version=20, error_correction=ERROR_CORRECT_L) qr.add_data(soci) qr.make() im … | |
There used to be a Python module called pyglet that allowed graphics and sound. I can't find it anywhere. | |
hi, i have written a function that can search through a folder and display a picture in a new window if the file is present but i always have to add the image file format or extension before the function can work. is there a way i can work around … | |
Write a program that reads n digit number. after reading the number, compute and display the sum of odd positioned digits,multiply all even positioned digits and add the two numbers. I have attempteed this problem like this a = input("Enter number") s = 0 p = 1 n = 1 … | |
Ok so I found this code online and though it looked interesting so I ran it but can someone tell me why it doesn't work? I have scapy installed btw #!/usr/bin/env python from scapy.all import * from scapy.error import Scapy_Exception m_iface="wlan0" filter_message="http" count=0 def pktTCP(pkt): global count if pkt.haslayer(TCP) and … | |
How might I gather all the songs in my music library (maintained in iTunes) on Mac OS X 10.8.5 with ID3 title tags (I guess? their titles in iTunes) that consist of 4 random capital letters. Or all the ones whose titles are 4 characters long, case insensitive, or mixed … | |
from xml.dom import minidom dict[1] = "country" xmldoc = minidom.parse('TestStep.xml') itemlist = xmldoc.getElementsByTagName('TestStepBody') print len(itemlist) print itemlist[0].attributes['Author'].value itemlist[0].setAttribute("Author",dict[1]); for s in itemlist : print s.attributes['Author'].value dict[1] value will be changing dynamically, So i need to dynamically change the attribute value of the Author in python. I this possible? if so … | |
I would like to break up a list into sublists of 3 elements each. I have this code, but it will give an index error when the length of the list is not divisible by 3. mylist = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] … | |
Inspired by violent python and some of the scripts in there, I would like to make a http request sniffer to sniff http requests on a network. In the book violent python there is a tutorial for a section to make a google keg logger (gets what people search on … | |
I'm having some trouble getting importing stuff from another class, I think I may be doing it wrong. I have a simple main class called Test and at the top I say: [CODE] from WordFixer import WordFixer import sys [/CODE] Then in the same folder (the src folder) I have … | |
Hello, I have few question regarding importing modules. I have created a folder for my python work [quote]/usr/home/pratz/pyfiles[/quote] I have exported this to set the $PATH. And now if I issue the command [code]echo $PATH [/code] I am getting the string the "/usr/home/pratz/pyfiles" in the list. If I am not … | |
def askopenfilename(self): filename= tkFileDialog.askopenfilename(initialdir='C:/..',title='Select File' , filetypes=[('Bitmap Images', '*.bmp'),('Png Images', '*.png'),('Gif Images', '*.gif'),("Jpeg","*.jpg"),("All files", "*")]) self.entryVariable.set(filename) if filename == None: return open(filename,'rb') self.entry.update(filename) self.image = Image.open(filename) self.img = ImageTk.PhotoImage(self.image) self.canvas.config(width=400, height=300) self.lab.img = self.img self.lab.pack() self.canvas.create_image(1,1, anchor=NW, image=self.img) self.scrollbar_vert = Scrollbar(self.canvas) self.scrollbar_vert.pack(side=RIGHT, fill=Y) self.scrollbar_hor = Scrollbar(self.canvas) self.scrollbar_hor.config(orient=HORIZONTAL) self.scrollbar_hor.pack(side=BOTTOM, fill=X) self.canvas.config(yscrollcommand=self.scrollbar_vert.set) … | |
Hi all, i am trying to write a mortgage amortization schedule calculator and am stuck. please see the code below. It appears that the principal is being counted twice before subtracting it from the balance. Any ideas on what the issue is? I am new to python: loanAmount = input("Please … | |
I have a class containing: class CounterList: __n_comparisons__ = 0 def __init__(self, data=None): if data is None: self.data = [] else: self.data = data self.__n_accesses__ = 0 def __getitem__(self, i): self.__n_accesses__ += 1 return self.data[i] def __setitem__(self, i, item): self.__n_accesses__ += 1 if type(item) != CounterNode: raise ValueError("Only Counter objects … | |
Hi, I have created one signal in python using pyside. I'm connecting with that signal 3 times with 3 different methods. when i emit this signal, it has to execute these 3 methods. It works perfectly fine. ValueChanged = QtCore.Signal(list) ValueChanged.connect(method1) ValueChanged.connect(method2) ValueChanged.connect(method3) valueChanged.emit([1,2,3]) But i would like to know … | |
I am updating an xml file and want to preserve multiple namespaces with same URI but different anchor tag using ET.register_namespace Following code is what I've tried : <code> ET.register_namespace('', "http://oval.mitre.org/XMLSchema/oval-definitions-5") ET.register_namespace('', "http://oval.mitre.org/XMLSchema/oval-definitions-5#windows") ET.register_namespace('', "http://oval.mitre.org/XMLSchema/oval-definitions-5#independent") ns = "{http://oval.mitre.org/XMLSchema/oval-definitions-5}" f = open ("def_ex.xml","ra") tree = ET.parse(f) root = tree.getroot() for defn … | |
Recently, I've been trying to find out how to make my computer think that a button on the keyboard has been pressed using python. I want the whole system to think the key has been pressed. I need this to be possible in windows 7 and 8, on the latest … | |
Hi everynone and Good Afternoon I am looking to implement a Program using Python for USB interfacing. How should i go for it.Any idea? | |
I have just figured out how to search for the element that im looking for in a xml file but now when I run it the code loops through i know 3 times maybe even more. I want to know what im missing that would cause it to loop like … | |
Can any one help me in, creating the Python code for the below XML.Please copy it in to notepad <?xml version="1.0" encoding="UTF-8"?> -<TemplateBlock SchemaVersion="(3, 6, 0, 313)" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">-<Block ConstructorType="dstt_framework.DSTT_TestStep" IsCallerBlock="False" CollapsedState="False" EnableMode="True" Guid="u'{79DDB3BE-30F2-4CC4-AE65-C47A39390F34}'" ModifyTime="1409059399.51" CreationDate="1409059390.1270001" ResultLevel="1" ProtoType="''" DevelopmentNode="u''" LibraryDescription="u'To add a functional unit to the test sequence.'" Author="u't8187sa'" _CustomAttributes="{}" Description="u''" … | |
So I was learning python from "Learn python the hard way" in python3 (my preferance) (I also tried everything in the 2nd python) and when I came across "Parameters, Unpacking, Variables" I was stuck for good. When I type in exactly the same thing as he does: from sys import … | |
Hi all, I am working on simplest web browser import socket mysock=socket.socket(socket.AF_INET,socket.SOCK_STREAM) mysock.connect(('www.py4info.com',80)) mysock.send('GET http://www.py4inf.com/code/romeo.txt HTTP/1.0\n\n') while True: data=mysock.recv(512) print data mysock.close() It's returning error 408:Request timeout at one time and at other runs smoothly but with incomplete output as: HTTP/1.1 200 OK Date: Sun, 14 Mar 2010 23:52:41 GMT … |
The End.