15,406 Topics

Member Avatar for
Member Avatar for krystosan

I am trying to move the items up and down depending on the call made, so I have came up with this def changePriority(self,*args): crntRow = self.listWidget.currentRow() total=self.listWidget.count() if args[0]=='up': if crntRow > 0 : crntItem= self.listWidget.takeItem(crntRow) self.listWidget.insertItem(crntRow+1,crntItem) if args[0]=='down': if crntRow + 1 < total: crntItem=self.listWidget.takeItem(crntRow) sel.listWidget.insertItem(crntRow-1,crntItem) else: print …

Member Avatar for vegaseat
0
149
Member Avatar for satsujin

Hi folks, I'm trying to use the subsample method in the PhotoImage class to resize an image I have in a list that links to a Label widget in Tkinter but python says there is no such method. I know I could use Image.resize before calling Photoimage but since I'd …

Member Avatar for satsujin
0
3K
Member Avatar for MissAuditore

Hi, My code: Print Y fig = plt.figure(figsize = plt.figaspect(0.5)) ax = fig.add_subplot(1, 1, 1, projection='3d') surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap = cm.gist_rainbow, linewidth=0, antialiased=False) print Y ax.yaxis.set_major_formatter(matplotlib.dates.DateFormatter('%H:%M:%S\n%m/%d/%Y')) #ax.yaxis.set_major_locator(dates.MinuteLocator()) fig.colorbar(surf) plt.show() Result: [[ 1.34503975e+09 1.34503975e+09 1.34503975e+09 ..., 1.34503975e+09 1.34503975e+09 1.34503975e+09] [ 1.34503980e+09 1.34503980e+09 1.34503980e+09 ..., 1.34503980e+09 1.34503980e+09 …

0
84
Member Avatar for jkembo

Hello everyone, I need some help, I would like to merge two cells together within a row only (e.g) in a CSV file using python. So far, I have 4 columns in the file, but now I would like to merge two cells in one, but I don't have any …

Member Avatar for jkembo
0
13K
Member Avatar for SoulMazer

Hi all, I'm working on a (Python) program which, in short, is a threaded TCP socket server which creates a new "tab" in a wx.Notebook widget for every incoming connection it sees. I've run into a strange problem where when I call notebook.AddPage(...), one of three things happens: 1. A …

Member Avatar for Gribouillis
1
741
Member Avatar for hotblink

Hi, I'm studying for a final exam and I just wanted to ask if you could be so kind to explain how you get these answers from these questions. I'm really confused on them. Thanks! 1) What is the output of the following program? def f(x, y): if y == …

Member Avatar for Xantipius
0
142
Member Avatar for dp121307

I tried to use a different forum but I was completely out of my league with the responses. I am extrememly new to python. As a project, I'm supposed to ask the user to input a file name, check that the file exists, output the numbers in the file, and …

Member Avatar for vegaseat
0
20K
Member Avatar for Jezza25

Hi I know how to import a individual file def cvt(s,default=-1): try: return float(s) except ValueError: return default import csv with open("Dealer1.txt", "rb") as csvfile: reader = csv.reader(csvfile, delimiter="\t") data = list(reader) I have a folder that contains 50+ files, using Glob, I created the following code import os import …

Member Avatar for Gribouillis
0
228
Member Avatar for Jezza25

Hi I have a script that is looking up multiple files, the files have a consistent layout they are a notepad from a CSV file. In some files there is a number and in some files there is a text. i have created a dictionary that one of the items …

Member Avatar for TrustyTony
0
112
Member Avatar for woooee

The problem is explained by the comments in the code. It is a fundamental question about the method call...every time I try text_box_name.tk_textBackspace() I get the TclError message. That's why I asked the question without the code... # When user enters a search word in the +search_box' text widget and …

Member Avatar for woooee
0
287
Member Avatar for aVar++

Hello, i have my naughts and crosses code as pasted below. Can someone help me with code to recognise if the game has come to a draw and recognising any invalid moves. Row1 = [" "," "," "] Row2 = [" "," "," "] Row3 = [" "," "," "] …

Member Avatar for slate
0
179
Member Avatar for MissAuditore

Hi guys, Trying to learn more about pandas csv reading. I have a file, with date and time on first row and a lot of data below. I want to be able to slice the data from T1 to T2 and use it for something. fname = "C:\Users\zana.pepaj\Desktop\Temperature.csv" data = …

Member Avatar for MissAuditore
0
190
Member Avatar for Jezza25

Hi Can I get some assistance with the following Code: Letter = raw_input("Enter Letter") A = 7 B = 8 C = 9 print Letter I have left the basic info but if the Letter A is entered in the print Letter it results A, I want it to give …

Member Avatar for Jezza25
0
104
Member Avatar for efwon

so I am new to python and I am trying to generate a 100 numbers from 0 to 10 and find out how many times a three appears. I'm not sure exactly how to get it to work. I basically just want to be able to count how many times …

Member Avatar for snippsat
0
234
Member Avatar for ultracoder

Are you a freelancer or programmer for hire? Join, post & bid for projects free. Thousands of skilled programmers, skilled freelancers to choose from. Ultracoder is a developer oriented outsourcing site. Skilled programmers will bid to complete your project right now. Computer Based programs, Training, Web Services, Language Specific programs, …

Member Avatar for LastMitch
0
234
Member Avatar for runlevel3nut

I'm returning to college after a 21-year absence and am starting fresh in a science stream. My first course in January will be the introductory Python course. In the meantime, I'm doing the Codeacademy tutorials and have completed the basic ones on variables, strings, comments, conditionals, some functions, and a …

Member Avatar for runlevel3nut
0
248
Member Avatar for slasel
Member Avatar for Lardmeister
0
110
Member Avatar for aVar++

I have got a simple naughts and crosses game working, can someone tell me a simple def blah(): .. command to check if the player has already moved to a place on the board already taken.. E.G Player's first go = top left Player's second go = top left.. (message …

Member Avatar for aVar++
0
122
Member Avatar for aVar++

Hey guys, i have been working on this for a while and global doesnt seem to be doing anything; help? Row1 = [" "," "," "] Row2 = [" "," "," "] Row3 = [" "," "," "] Grid = [Row1,Row2,Row3] x = False def NAC(): def check(): #only using …

Member Avatar for aVar++
0
290
Member Avatar for krystosan

I want to know how to check if the string given is a path with a file name or not , the file name with extension is not on disk but will be created later, but since its not created I cannot use os.path.isfile(filepathsupplied) so how should i check if …

Member Avatar for Gribouillis
0
129
Member Avatar for Gribouillis

This snippet is easy: it defines an immutable wrapper around a sequence type (list, deque, etc) which allows a class, function or module to expose a read only version of a sequence to the outer world. A constant wrapper around mapping types could also be defined in a similar manner.

Member Avatar for Gribouillis
2
578
Member Avatar for biscayne

I'm trying to find a record in a csv file in a nested stucture: for elem in lstLine[1:]: for item in open(fname): lstData = item.rstrip('\n').split(';') andexfield = lstData[0] if andexfield == elem: do bladibla Now I want ot add error handling: if no record in fname is found where andexfield …

Member Avatar for Gribouillis
0
279
Member Avatar for satsujin

Hi folks, I was wondering if there was some way to delete all Labels from a Tkinter canvas in one go. I'm not even sure if the labels are being drawn on the canvas since you only use the master(self.root) when creating it but I do the same for buttons …

Member Avatar for satsujin
0
2K
Member Avatar for jlh070945

I'm working through Python Programming by Zelle. I've entered the code for the racquetball problem in Chapter 9 exactly as written in the text. (At least I think so.) The program returns one game only then quits. I've prototyped and unit tested but can't find my mistake. Any insights would …

Member Avatar for woooee
0
147
Member Avatar for WhiteTulip

Hi! I'm writing a program that will take a an inputed phrase, assigns each letter to a picture of the letter from a file, and outputs the given phrase, looking like a ransom note. I have a start, but I'm not really sure where to go next. I've only just …

Member Avatar for woooee
0
312
Member Avatar for vegaseat

This Python code allows you to get selected statistics of a story text. It will count lines, sentences, words, list words and characters by frequency, and give the average word length. It should be easy to add more statistics using the dictionaries created.

Member Avatar for Ene Uran
3
804
Member Avatar for satsujin

I am trying to write a python app that will switch between two views when I click on the canvas in Tkinter. I have written the views and main app as seperate objects with binds linked to the opposing view through the left mousebutton. When I run the app in …

Member Avatar for satsujin
0
190
Member Avatar for krystosan

print "Maya Data Out > %s ",pickle.loads(process.stdout.read()) File "C:\Python26\lib\pickle.py", line 1374, in loads return Unpickler(file).load() File "C:\Python26\lib\pickle.py", line 858, in load dispatch[key](self) File "C:\Python26\lib\pickle.py", line 994, in load_tuple k = self.marker() File "C:\Python26\lib\pickle.py", line 874, in marker while stack[k] is not mark: k = k-1 IndexError: list index out of …

Member Avatar for Gribouillis
0
750
Member Avatar for sym366

I'm not really good wih the Big O notation so I was wondering if any one can help me find the Big O notation of this code for each of its function when they are best , worst, and adverage case and a brief explantation of why it's that. Sorry …

Member Avatar for TrustyTony
0
175
Member Avatar for giancan

Dear friends, I need our help for a new task. I have a gps track (sequence of lat long and altitude) and I would like to know if there is a way to make an offset (or a parallel line if you prefer) of this line to its right and …

Member Avatar for giancan
0
401
Member Avatar for Cosmo_Kramer

I am writing the following functions I cannot tell where I should leave off with the "bootstrapping" that the first function searchMaze() is supposed to be doing, the wording is not getting through my dense head. searchMaze(maze, start_pos, finish_pos) This function takes a maze data structure as created by readMazeFile(), …

Member Avatar for Cosmo_Kramer
0
278
Member Avatar for jrcagle

Generators are essentially dynamic sequences, making their official debut in Python 2.5. That got me to thinking: can we make a circular list with them? Why yes, we can...

Member Avatar for vegaseat
2
191
Member Avatar for vegaseat

You can alternately show one of two lines drawn on the Tkinter canvas by simply moving them on and off the canvas screen. This beats a cumbersome create and delete cycle.

3
535
Member Avatar for lewashby

Below is a short program I'M working of from udacity.com but I can't figure out why I'M getting the value 6 from the first call to the function. # Define a procedure, biggest, that takes three # numbers as inputs and returns the largest of # those three numbers. def …

Member Avatar for woooee
0
237
Member Avatar for tizzqman

I need help with a program i am doing. it is a cryptography program. i am given a regular alphabet and a key. i need to use the user input and use the regular alphabet and use the corresponding letter in the key and that becomes the new letter. i …

Member Avatar for woooee
0
110
Member Avatar for slasel

I am using turtle graphics with Tkinter however the problem is that the turtle graphics window comes over my root window and covers it! Is there a way to solve this? Note: i am using turtle inside functions if that makes any difference... import ImageTk import tkMessageBox from Tkinter import* …

Member Avatar for vegaseat
0
2K
Member Avatar for vegaseat

A closer look at the Tkinter GUI toolkit Toplevel Window and how to lift and lower it respective to other windows.

0
6K
Member Avatar for slasel

If u run this code then click on the button helicase, u'd notice that there is a space btw radiobutton 1 and the rest! why? how can i fix this? I am sorry i know my code is too long but i don't know which section of it was causing …

Member Avatar for slasel
0
590
Member Avatar for elbert.leach

# This program reads numbers from a file into a list. def main(): # Open a file for reading. infile = open('text.txt', 'r') sentences = infile.readlines() # Read the contents of the file into a list. infile.close() # Close the file. index = 0 # Convert each element to an …

Member Avatar for Ene Uran
0
343
Member Avatar for silversonicaxel

hi, just a simple question on a wx.TextCtrl element. i have this text field where on an application, where the user can add a string on it. i want a text field with a red text on it. so i've generated this code: self.hRepositoryTextfield = wx.TextCtrl(self.hPanel) self.hRepositoryTextfield.SetDefaultStyle(wx.TextAttr(wx.RED)) if the user …

Member Avatar for Ene Uran
0
341
Member Avatar for slasel

I want one picture to be displayed in the canvas then the another to be displayed in the canvasafter 2 seconds. i used time.speed(2) and canvas.delay(2000) but nothing works! Any help please?! import ImageTk import tkMessageBox from Tkinter import* from turtle import * import time root = Tk()#main window canvas …

Member Avatar for Ene Uran
0
439
Member Avatar for krystosan

I implemented whole UI and logic into one py file now I thing it would be good if I separate the UI file from the logic, and to run the UI I shoud run the file that contains logic that inturn loads the UI... I have `RenderUI.py` module that contains …

Member Avatar for krystosan
0
961
Member Avatar for slasel

Hello, I need help with creating 6 buttons can I do that using some loop and how can that be done? each button has a different image and different text...their bg, and dimensions are the same Also after creating all the buttons I want to make a callback function for …

Member Avatar for slasel
0
286
Member Avatar for slasel

I have a problem...how can i arrange widgets inside a frame using grid? I get all sorts of weird results with widgets coming over each othe

Member Avatar for slasel
-1
79
Member Avatar for pinbustersrule

I've just started using python in my computer technology class. One thing I can't figure out is how to have python put the lists inside a string into alphabetical order. If anyone has any easy answer, it will be much appreciated. Also, my teacher told me he would give extra …

Member Avatar for noonecares
0
889
Member Avatar for giancan

Dear friends, sorry for my ignorance about python containers but I have the need to store (and access) 4 different values per file in folder, namely the filename (with its path) and 3 other values (string or None). When I access the database, I will need to know the 3 …

Member Avatar for ZZucker
0
326
Member Avatar for vegaseat

Comparing a number of different approaches to finding the closest pair of numeric elements in a list. The timing is done with the mpmath module, but you can also use Python module timeit.

Member Avatar for Lardmeister
5
757
Member Avatar for biancairis93

I have to create a class of Persons that will hold information about their name,age,NI number.These details are read from a file that would look like : 55512 Bart Simpson 45 45622 John Smith 58 46231 Alicia Sands 27 My duty is to read each line from this file and …

Member Avatar for Lardmeister
0
127
Member Avatar for elvis1

Hi I am a Pyth noob and wanted to import a text file .To each line of the text file , assign a (fixed) name and sum a number (in increments of 1 from the first line to the last)using the while command for an assigned name. Lets say I …

Member Avatar for noonecares
1
3K
Member Avatar for rmbrown09

I'll keep the story short here but to sum things up: I have always liked computers. Hardware has always been my thing. I have my own custom built desktop and love changing and messing with it every day. I also work (part time) as an IT guy for small business. …

Member Avatar for rubberman
0
238

The End.