15,175 Topics
| |
Hi! I'm working on program with a lot of buttons and I would like to use For loop to make all of them instead of writing every each one of them. so, can anybody help me? here is example of code [CODE] import tkinter as tk def klik_1(): button1.config(image=s1) def … | |
Okay, so I am creating a battleship game, I posted a thread here earlier to figure out how to place the ships, but know I'm back, because I am curious as to how I should program the AI for it. Here's my base code now, and I'll explain how the … | |
[CODE] startup = 0 r = rock p = paper s = scissors if startup == 0: weapon = str(input("Please enter your weapon: Rock, Paper, or Scicors") while weapon =! r: print("Incorrect choice, please choose again")[/CODE] Im running python 3.2.2. Im trying to make rock paper scissors. I am trying … | |
i got a working highlight code example that works in python 2.7.2 [CODE] import Tkinter """ Edit a file and save the text. """ textFont1 = ("Courier New", 16, "normal") class ScrollbarX(Tkinter.Scrollbar): def set(self, low, high): if float(low) <= 0.0 and float(high) >= 1.0: self.grid_remove() else: self.grid() Tkinter.Scrollbar.set(self, low, high) … | |
Title says it all. I am looking for a way to find the values of a column within a row. I am unsuccessful at being about to create a for loop that searches each value in the row and inputs a value if it is x. For example: [CODE] there … | |
Here is the problem: a function that takes two strings and removes from the first string any character that appears in the second string. eg. if the first string is “[B]IamLearningPython[/B]” and the second string is “[B]aeiou[/B]” the result is “[B]mLrnngPythn[/B]”. I've written the code for this, but I can … | |
Hi, I have the a situation here . My motive : Hiding one panel and showing another. Whats Working :Layout wise , my app is behaving like i want it to . The Problem : After the I hide one panel and show another , the button in this panel … | |
Hi, I'm trying to find a way to solve this equation with two unknowns using Python: [QUOTE](a * b) = (x * c) + (y * d) + e [/QUOTE] Where a, b, c, d and e are all floating numbers provided by the user and x and y are … | |
Hey all I need some help with Jython. In Python I'm given the easy option to read a file with [CODE]file = open('/dev/input/js0')[/CODE] Then I can put it into a non blocking mode with something similar to [CODE] import os, fcntl file = os.open('/dev/input/js0', os.O_NONBLOCK) [/CODE] But in Jython I'm … | |
Okay, so for some practice problems from a friend, he asked me to take some previous code, and define a function called parseName? I'm not familiar at all with what it is/does. The objective he gave me was to use this parseName function and to return the firstname, middlename, and … | |
| apparently my data is too big to be split at every newline.. any idea how to split every 4th newlien? |
Hello, I need your help to get my Python program running please. Thank you so much. This is the assignment: Highway Robbery! Use skills learned in Units 1 - 4 and include: • input functions, calculation functions and output functions • passing variables between functions • elif statement (if/else for … | |
Hi, I have several tkinter entries created within a loop, where users input numbers. I wish to create a reset button to set all entries to zero. On the following code the reset button will just reset the last entry. How is possible to call each of the entry and … | |
I'm doing some research to determine the most efficient way to copy files. I've got 3 candidate functions: #1 [CODE=python] # uses generator to load segments to memory def copy(src, dst, iteration=1000): for x in xrange(iteration): def _write(filesrc, filedst): filegen = iter(lambda: filesrc.read(16384),"") try: while True: filedst.write(filegen.next()) except StopIteration: pass … | |
I'd like to ask the user if he/she wants to rerun a script. I've thought of doing that with a while. My problem is that both [CODE] import sys rerun = "y" while rerun == "n": sys.exit() else: print("do some stuff") rerun = str(input("Would you like to start again? [y/n]: … | |
Write a function named walkingMan() that simulates a person walking a specified distance, taking steps of varying length. The length of the steps varies at random within a specified range. (Use the function in the Python random module, random.randint(a, b), which returns a random integer N such that a <= … | |
Hi guys, converting .ui to .py to .exe using Qt Designer (PyQt4), Python 2.7, and py2exe Ive been able to do this with Tkinter gui's but having problems with gui's from Qt Designer? First error was due to missing msvcp90.dll which ive downloaded and copied into the python dll directory, … | |
Hello Everyone! So ive done some searching and havent been able to find what i need. Partly because i'm not sure exactly what words i should be googling! I am wanting to download gmail emails, and then display them in a spreadsheet like format. I know that emails have unique … | |
Guys I installed mySQLdb in Ubuntu with: [CODE]mydeskt@mydeskt-desktop:~$ sudo apt-get install python-mysqldb[/CODE] but when I go to the python interpreter and type: [CODE]>>> import mySQLdb [/CODE]I get: [CODE] Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named mySQLdb [/CODE]It is installed though, because when … | |
I'm just going to put this out there. I was asked to create a spreadsheet with data extracted from MARC records. I have looked at pymarc and cannot get this to work. To be honest I'd rather do this myself and lean something in the process. I have another similar … | |
For My basic programming are using python. I want to create a game called rocket race where two rockets are racing side by side dodging meteroids. I just need some help knowing where to start. I made the rockets and the meteroids in paint already. So could you give me … | |
I have been asked to look into getting a web framework up and running here at work. I come from a PHP background and have developed a few tools various people use around the office. I have recently become part of a small team of developers who only use Python, … | |
Hi team. I am battling to convert a string to date. I currently manually pass a string date to my program(cobdate = string.replace(sys.argv[1], '-', '')) which will be used by a lot of things. The date will be in this format. "2012-02-02". I need to convert this to a proper … | |
Hey everyone, I'm trying work on a text based game and I'm a little stuck with navigating the rooms. So let's say I'm in a room with another room to the north, east, south, and west. I wanted to create a "navigation" function which takes four parameters, which are the … | |
I created a program awhile back to translate a phrase into pig latin. Pretty simple program, but now I am trying to figure out how to get it to read from a file and process it that way. Here is my old program; [CODE] def main(): enter = raw_input("Enter a … | |
im trying to make a simple calculator: [CODE] loop = 1 while loop == 1: print "Welcome to Jakes' Calculator" print "1) addition" print "3) multiplication" choice = raw_input("Enter a number 1-4: ") break if choice.strip() == "1": a = input("enter the first number: ") b = input("enter the second … | |
Hello pythonistas, am still some months new to python and i've decided to go with the web2py framework. I love its simplicity but unfortunately, it lacks study resources. The only available book i could get was the official book written by MASSIMO DI PIERRO. id be greatly appreciated if i … | |
Hey, Is there a way, by using find, to create a method that finds the last occurrence of a character in a string? I know how to use the find method to find the first occurrence but have no idea how to do it backwards. Basically this is what I … | |
Not sure if it is possible but is there a way to multiply,add,or subtract values in a tuple? Say for example I have: [CODE] a=raw_input("enter 2 numbers separated by a /: ") #5/2 entered b=a.split("/") c=a[0]+a[1] print c [/CODE] The value comes out to 52 which is obviously wrong. Is … | |
Hi all. I am having trouble with one of midterm practice problem questions again. I need to be able to get the First, Middle, and Last Name using the count function. However, my professor wants us to be using a name with more than one middle name, and I am … |
The End.