15,190 Topics
![]() | |
from tkinter import * from random import randint #Return random color #RRGGBB def getRandomColor(): color = '#' for j in range(6): color+= toHexChar(randint(0, 15)) return color #Convert an integer to a single hex digit in a character def toHexChar(hexValue): if 0 <= hexValue <= 9: return chr(hexValue+ord('0')) else: return chr(hexValue … | |
i am trying to make a checkerboard that centerss automaticly no matter what the sideLength is. also i am tryiing to put the checker in the squares...im only a beginner!!!! have mercy heres what i have [code] def drawCheckerBoard(myTurtle,sideLength): myTurtle.speed(0) for i in range (8): myTurtle.forward(sideLength) myTurtle.right(90) myTurtle.forward(sideLength) myTurtle.right(90) myTurtle.forward(sideLength) … | |
as the title states, I know runpy can run a module's code w/o importing it, but what I'm trying to do is send the module object to a... function supplied by my interface which is directly called by the module. what I'm talking about is: my interface provides these functions … | |
Hi, I'm trying to compare two CSV files (and many more like these below). I tried many ways, using lists, dictreader and more but nothing gave me the output I require. I want to compare all those rows that have same !Sample_title and !Sample_geo_accession values (whose positions vary). I've been … | |
import tkinter top=tkinter.Tk() t=tkinter.Text(top,height=1,width=1,bd=2,font=10) t.grid(row=0,column=0) b1=tkinter.Button(top,height=2,width=8,bd=2,text="MC",fg="Red") b1.grid(row=1,column=1) b2=tkinter.Button(top,height=2,width=8,bd=2,text="Backspace",fg="Red") b2.grid(row=1,column=2) b3=tkinter.Button(top,height=2,width=8,bd=2,text="CE",fg="Red") b3.grid(row=1,column=3) b4=tkinter.Button(top,height=2,width=8,bd=2,text="C",fg="Red") b4.grid(row=1,column=4) b5=tkinter.Button(top,height=2,width=8,bd=2,text="MR",fg="Red") b5.grid(row=2,column=1) b6=tkinter.Button(top,height=2,width=8,bd=2,text="7",fg="Blue") b6.grid(row=2,column=2) b7=tkinter.Button(top,height=2,width=8,bd=2,text="8",fg="Blue") b7.grid(row=2,column=3) b8=tkinter.Button(top,height=2,width=8,bd=2,text="9",fg="Blue") b8.grid(row=2,column=4) b9=tkinter.Button(top,height=2,width=8,bd=2,text="/",fg="Red") b9.grid(row=2,column=5) b10=tkinter.Button(top,height=2,width=8,bd=2,text="sqrt",fg="Blue") b10.grid(row=2,column=6) b11=tkinter.Button(top,height=2,width=8,bd=2,text="MS",fg="Red") b11.grid(row=3,column=1) b12=tkinter.Button(top,height=2,width=8,bd=2,text="4",fg="Blue") b12.grid(row=3,column=2) b13=tkinter.Button(top,height=2,width=8,bd=2,text="5",fg="Blue") b13.grid(row=3,column=3) b14=tkinter.Button(top,height=2,width=8,bd=2,text="6",fg="Blue") b14.grid(row=3,column=4) b15=tkinter.Button(top,height=2,width=8,bd=2,text="*",fg="Red") b15.grid(row=3,column=5) b16=tkinter.Button(top,height=2,width=8,bd=2,text="%",fg="Blue") b16.grid(row=3,column=6) b17=tkinter.Button(top,height=2,width=8,bd=2,text="M+",fg="Red") b17.grid(row=4,column=1) b18=tkinter.Button(top,height=2,width=8,bd=2,text="1",fg="Blue") b18.grid(row=4,column=2) b19=tkinter.Button(top,height=2,width=8,bd=2,text="2",fg="Blue") b19.grid(row=4,column=3) b20=tkinter.Button(top,height=2,width=8,bd=2,text="3",fg="Blue") b20.grid(row=4,column=4) b21=tkinter.Button(top,height=2,width=8,bd=2,text="-",fg="Red") b21.grid(row=4,column=5) b22=tkinter.Button(top,height=2,width=8,bd=2,text="1/x",fg="Blue") b22.grid(row=4,column=6) b23=tkinter.Button(top,height=2,width=8,bd=2,text="M-",fg="Red") … | |
![]() | Has anyone ever used tkdocs... http://www.tkdocs.com/ And if so what have been your opinions thanks. |
x = 25 epsilon = 0.01 numGuesses = 0 ans = 0.0 while abs(ans**2 - x) >= epsilon and ans <= x: ans += 0.00001 numGuesses += 1 print 'numGuesses =', numGuesses if abs(ans**2 - x) >= epsilon: print 'Failed on square root of', x else: print ans, 'is close … | |
Hello. I'm using Linux OS, Python 2 and the last version of Kivy framework. Here i have 2 files that i have typed them exactly as what i watched on a kivy tutorial video. Fist file is "main.py": from kivy.app import App from kivy.uix.scatter import Scatter from kivy.uix.label import Label … | |
Good Day:) I'm trying to figure out how to remove the % sign that is returned from scraping Yahoo Finance **without** removing the decimal point (or a possible negative sign in front of number returned as netProfit). My goal is to convert the string without the % sign a float … | |
For example the 'x'in if ans*ans*ans != abs(x): | |
Hi. How can i open a mp3 file and play it in python? There is a mp3 file on my Linux desktop and i want to open it from a python file and play it. What should i do? | |
Hi everybody. I have problem with .pack() and .grid(). I have to use this line: mywin.pack(fill=BOTH, expand=YES) I have used .grid every where on my file but now here i have copied a pice of code from some where and have pasted to my file, as you see it has … | |
Hello. When we want to insert a vlue into a table in sqlite, we use this line, right? cursor.execute('INSERT INTO colors Values ("red", "blue")') As we can see above, we want to insert 2 words and we type them as when we are typing whole the codes. But i want … | |
memoryc = open("cipher.txt", "a") memoryd = open("decipher.txt", "a") #------------------------------------------------------------------------------- choice = input("cipher, decipher or memory") #------------------------------------------------------------------------------- if choice == "cipher": message = input("What is your message?") key = int(input("What is your key?")) coded_message = "" for ch in message: code_val = ord(ch) + key if ch.isalpha(): if code_val > ord('z'): … | |
https://friendpaste.com/mTdjXilQ0bVQJpsoCu1Wf i am having the error (float' object has no attribute 'insert').I am getting the same error with append. any solutions??? I am using python 3.4.2 .Thanks in advance. | |
Hello i am new to programming i trying to solve the follwing Allow 6 different players to throw dice 100 times The results sholuld be stored in the collection SCORES. Read the contents of SCORES and output many times in total each number was thrown. Also output whether or not … | |
I cant figure out what arguements to use or really even what arguements are. #Template for Program 2 #The keyword "pass" is a placeholder that does nothing #Move each line of original code into the appropriate module #Add arguments to calcBMI() and displayResults() as needed #original code -- not in … | |
Hi, I have two dictionaries and what I would like to do is to search if an item from dict1 is present at least 3 times in dict2. If so, do something. At the moment, I have something like this for line2 in list2: to_find=line2[3]+line2[4] if to_find in dic1: new_string=((" … | |
if I have something like the following file = open(filename, 'rb') for line in file: #do stuff Once I find what I'm looking for in file and it's placed in the line variable, how could I then capture that position withing file, not just line? | |
Greetings: I've noticed that many people on these boards have experience using PyGame, so I thought it would be cool if i shared a creation I am currently developing. This creation is called **PyDark**. Basically, PyDark is a *2D game framework* built on-top of Python and PyGame. What makes PyDark … | |
I'm making a shooting game, how would I make the gun point towards the mouse cursor? Here's part of my code: y = 100 x = 100 screen = pygame.display.set_mode((800,600)) p = pygame.image.load("Person.png") player = pygame.transform.scale(p, (34, 86)) pygame.key.set_repeat(1, 1) mx, my = pygame.mouse.get_pos() while True: screen.fill(white) for event in … | |
![]() | Hi, is that possible Tkinter to play a video? And if not possible so what GUI programming that you can recomended? I already search in google, find a few but there's dead link.. I need to show 2 windows, first the original video, and the second is video after processing ![]() |
I used csv data readily available from http://www.weatherdatadepot.com/ to create a multiline plot of the average monthly temperatures of a given location. | |
![]() | If I have an array >>> a=np.array([[1,2,1],[3,4,2],[6,5,3],[7,8,4]]) >>> a array([[1, 2, 1], [3, 4, 2], [6, 5, 3], [7, 8, 4]]) and I want to find if first column which have value=6 and if second column have value=5 using "IF" "ELSE" I try with: b=6 c=5 if (b in a[:,0]) … ![]() |
I am doing my homework and am having trouble on a certain problem. [I]4) A certain CS professor gives 100-point exams that are graded on the scale 90-100:A, 80-89:B, 70-79:C, 60-69:'D, <60:F. Write a program that accepts an exam score as input and prints out the corresponding grade.[/I] We have … | |
Hi everyone, I am having trouble comprehending or digesting the programming mentality. I'm learning Python and while I completely understand the syntax as well as the language itself, my problem is more toward the comprehension of thinking like a programmer. For example, once a programming exercise is explained, it all … | |
def fileToString(filename): myFile = open(filename, "r") myText = "" for ch in myFile: myText = myText + ch return myText def countVowels(text): vcount = 0 vowels = ['a','e','i','o','u'] for letter in text: if (letter in vowels): vcount = vcount + 1 return vcount write a program to calculate the following … | |
Hi, I am working on a GUI (more correctly, trying to), but I just don't really get it to work the way I want. The idea is to have a first list, where the user chooses one of the choices. Then depending on that choice, a new window pops out … | |
| |
The code that has been attatched (i couldnt post it for some reason) produces the error message: Traceback (most recent call last): File "filename", line 36, in <module> for i in range(len(bytesmessage)/7): TypeError: 'float' object cannot be interpreted as an integer In this line for i in range(len(bytesmessage)/7): The variable … |
The End.