14,946 Topics

Member Avatar for
Member Avatar for kiddo39

Hi, If I have a sentence like this: "I now have a total of % yellow bananas!" but I need it to change the number 2 to a 3, print, then a 4, print, etc until it reaches a set number like 10, how can I go about that? sentence …

Member Avatar for kiddo39
0
271
Member Avatar for silverdust

On line 21 of this code where I have self.greetWelcome() . I'll love for that function to be called after the GUI is loaded. What event do I have to listen for and on what object to call it after the GUI is loaded. As of now, it works before …

Member Avatar for silverdust
0
3K
Member Avatar for vegaseat

Similiar to the snippet posted at: http://www.daniweb.com/software-development/python/code/449036/display-an-image-from-the-web-tkinter but this time we use PIL to resize the image from the internet keeping its aspect ratio to fit a specific display area/box.

Member Avatar for HiHe
3
2K
Member Avatar for vegaseat

The Pyside GUI toolkit (public PyQt) lets you bring up an interactive web page with its QWebView widget. Here is a simple example.

2
684
Member Avatar for EDWIN_4

Hello, in which senario do we normaly use this (*args,**kwargs)type of arguments in python.

Member Avatar for snippsat
0
149
Member Avatar for masterofpuppets

[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 += …

Member Avatar for richard.grigonis
1
353
Member Avatar for dani_boy

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 …

Member Avatar for HiHe
0
3K
Member Avatar for amraam

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 …

Member Avatar for amraam
0
6K
Member Avatar for psichoman5

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 …

Member Avatar for woooee
0
462
Member Avatar for mark103

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 …

Member Avatar for vegaseat
0
1K
Member Avatar for mark103

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 …

Member Avatar for chriswelborn
0
180
Member Avatar for entropicII

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 = …

Member Avatar for woooee
0
2K
Member Avatar for acrocephalus

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 …

0
108
Member Avatar for acrocephalus

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 …

Member Avatar for acrocephalus
0
344
Member Avatar for sneekula

There used to be a Python module called pyglet that allowed graphics and sound. I can't find it anywhere.

Member Avatar for sneekula
0
251
Member Avatar for mcroni

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 …

Member Avatar for vegaseat
0
275
Member Avatar for Jai_4

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 …

Member Avatar for sneekula
0
735
Member Avatar for QwertyFish

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 …

Member Avatar for QwertyFish
0
812
Member Avatar for cilla

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 …

Member Avatar for chriswelborn
0
193
Member Avatar for racigan

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 …

Member Avatar for chriswelborn
0
3K
Member Avatar for sneekula

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] …

Member Avatar for sneekula
0
258
Member Avatar for QwertyFish

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 …

Member Avatar for QwertyFish
0
1K
Member Avatar for jcafaro10

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 …

Member Avatar for snippsat
0
153
Member Avatar for pratz

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 …

Member Avatar for Amigodornot666
0
514
Member Avatar for La

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) …

Member Avatar for vegaseat
-1
668
Member Avatar for rednose00

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 …

Member Avatar for vegaseat
0
2K
Member Avatar for BingityBongity

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 …

Member Avatar for snippsat
0
355
Member Avatar for Ravi_exact

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 …

Member Avatar for woooee
0
199
Member Avatar for kumarswamy_10

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 …

0
101
Member Avatar for entropicII

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 …

Member Avatar for Gribouillis
0
2K

The End.