15,175 Topics

Member Avatar for
Member Avatar for Vkitor

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 …

Member Avatar for Gribouillis
0
23K
Member Avatar for hondros

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 …

Member Avatar for woooee
0
2K
Member Avatar for layneb131

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

Member Avatar for layneb131
0
195
Member Avatar for moroccanplaya

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

Member Avatar for moroccanplaya
0
159
Member Avatar for straylight

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 …

Member Avatar for woooee
0
167
Member Avatar for jone kim

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 …

Member Avatar for TrustyTony
0
200
Member Avatar for arindam31

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 …

Member Avatar for arindam31
0
191
Member Avatar for KatseasSAvvas

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 …

Member Avatar for TrustyTony
0
280
Member Avatar for woodenduck

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 …

0
218
Member Avatar for minimee120

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 …

Member Avatar for minimee120
0
163
Member Avatar for apeiron27

apparently my data is too big to be split at every newline.. any idea how to split every 4th newlien?

Member Avatar for woooee
0
96
Member Avatar for bebedjou

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 …

Member Avatar for woooee
0
2K
Member Avatar for paul.hahn

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 …

Member Avatar for paul.hahn
0
10K
Member Avatar for ihatehippies

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 …

Member Avatar for ihatehippies
0
6K
Member Avatar for KatseasSAvvas

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

Member Avatar for KatseasSAvvas
0
2K
Member Avatar for unigrad101

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

Member Avatar for slate
0
127
Member Avatar for xopenex

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

Member Avatar for xopenex
0
1K
Member Avatar for xopenex

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 …

Member Avatar for xopenex
0
206
Member Avatar for HoneyBadger

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 …

Member Avatar for HoneyBadger
0
180
Member Avatar for roe1and

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 …

Member Avatar for woooee
0
299
Member Avatar for Bungie

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 …

Member Avatar for slate
0
165
Member Avatar for 4evrmrepylrning

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

0
112
Member Avatar for Matjame

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 …

Member Avatar for Matjame
0
702
Member Avatar for ohblahitsme

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 …

Member Avatar for woooee
0
166
Member Avatar for python-noob

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 …

Member Avatar for python-noob
0
426
Member Avatar for pythoner

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 …

Member Avatar for pythoner
0
178
Member Avatar for Netcode

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 …

Member Avatar for Netcode
0
100
Member Avatar for nickecarlo

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 …

Member Avatar for nickecarlo
0
140
Member Avatar for straylight

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 …

Member Avatar for straylight
0
347
Member Avatar for minimee120

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 …

Member Avatar for minimee120
0
245

The End.