153 Posted Topics
How would I define the command of a given button in a messagebox window? i.e. if I were using askokcanel how would I make the ok do a certain action and cancel another? | |
How would I access the string that is in the [1] position of a tuple at a given index of a listbox. What I'm trying to do is something like this:[CODE] a=Lb1.curselection()[1] a=int(a) print(Lb1[a])[/CODE] Lb1 is obviously the listbox. This particular attempt claims 1 is out of range "although I … | |
Re: CLOSE THAT FILE!!! Also, did you notice the stray else at the end? | |
Re: [QUOTE]I just finished a program[/QUOTE] Well actually you copied the program out of the book, which with no offense to the author, isn't the greatest. I've found a large amount of the code in that book to be a bit buggy, or unclear. The way I got over that was … | |
I'm having an issue displaying images in tkinter, I've tried the methods suggested by effbot and a couple other sources to no avail. Here are a couple ways I've tried so far:[CODE] gmail=PhotoImage('gmail.gif') self.glab=Label(self,image='gmail.gif') self.glab.image=gmail self.glab.grid(row=3,column=4) gmail=PhotoImage('gmail.gif') self.glab=Label(self,image=gmail) self.glab.image=gmail self.glab.grid(row=3,column=4) self.glabim=PhotoImage('gmail.gif') self.glab=Label(self,image=self.glabim) self.glab.grid(row=3,column=4) gmail=PhotoImage('gmail.gif') self.lab=Label(self,image=gmail) self.lab.image=gmail self.lab.pack() [/CODE]the last one … | |
Re: what's the specific problem with the code? Also have you tried livewires? It's a module for pygame and I prefer the simplicity. My first "game" I wrote in it is below, the only thing that would need to be modified would be collision detection on the sprites, and the event … | |
I hate to complain, but I'm not terribly impressed at the documentation for utilizing binding, it covers quite a bit but not common stuff, or maybe I'm just missing it. I was wondering how I could make the <RETURN> key equivalent to a <BUTTON1> click when a button is highlighted … | |
Re: Maybe because of the print imp? I'm not sure, this worked fine for me:[CODE]while True: oinp = open('open_inputs.txt','r') for line in oinp: print(line) oinp.close() print('')#I just needed to make it prettier inp = input('Enter text, or "Enter" to quit: ') if inp == "": break else: oinp = open('open_inputs.txt','a') oinp.write(inp,) … | |
Re: @Valex, start your own thread. | |
I was just wondering if anybody has any ideas on how I could allow a users input to be disguised on the screen when they're entering their passwords (such as the case about everywhere on the internet) i.e. gmail's black dots in place of the actual text of a password. … | |
Re: Post the code here next time, and if you feel it's a good quality code post it as a snippet! | |
Re: have you seen [URL="http://www.ideone.com"]this[/URL]? | |
Re: are you suppose to be using a tkinter window to display the output? | |
Re: Both of the above are much better ways to go, but for a simple, not so easy to read solution you could also pickle the dictionary of {username:password} "I'm assuming that's what you're doing pardon me if I'm wrong" to a .dat file. But as I said, this is just … | |
I'm trying to figure out how to deal with multiple matches in my address book, say the user has two people by the name of Bob; one is Bob Lastname and the other is Bob Namelast, how would you approach dealing with telling them to specify, and then allowing them … | |
Re: Nice Tony, it works great! Exactly what I needed, and furthermore, thanks for the link so I could better understand the mechanics. | |
Re: I would do something like:[CODE]depth=int(input('Depth: ')) def depther(): global depth try: if depth <=50 and depth>0: print(depth) else: while depth>50 or depth<0: print('Incorrect range') depth=int(input('Depth: ')) print(depth) except: print('Invalid input') depth=int(input('Depth: ')) if depth <=50 and depth>0: print(depth) else: while depth>50 or depth<0: print('Incorrect range') depth=int(input('Depth: ')) print(depth)[/CODE] I defined … | |
Re: First of all I would personally use pygame for that and livewires(just because) and I would think you'd need to have those parts of the image as separate images, place them on the frame so that they appear to be one image, then you could manipulate them as sprites individually. | |
I'm having issues with a third level Toplevel in tkinter, that is to say having a toplevel popup from another Toplevel. [CODE] self.emailbttn= Button(self, text='Email', command=self.clientchooser) def clientchooser(self): showing.withdraw() client_choose() def client_choose(): global client client=Toplevel() client.title=('Choose Email') client.geometry=('800x600') Client(client) class Client(Frame): '''Choose Email Client''' def __init__(self,master): super(Client, self).__init__(master) self.grid() self.create_widget() … | |
After marking gofish up to a temporary loss I've moved back to my address book. The issue I'm currently having is that webbrowser is opening the wrong broswer. I've set my default browser to firefox (currently using windows vista), and yet the program is still opening IE, however when I … | |
Re: utilizing modules like that may be a little above your "pay-grade" at the moment, I don't mean that offensively, I'd just stick with running the script. I'm not sure why you want to turn it into an .exe right now anyways, any reason? | |
Re: my netbook is a piece of crap. The charger port has pushed in so far the charger needs to be held in, the battery is shotty and I need a new one. I respect the power of them however, and because they're so inexpensive they're great for tinkering around with … | |
I have no idea what went wrong with my most recent code, but I suspect it has something to do with the following so I'll start there. Did I do something wrong in this? [CODE]cards=['1','1','1','1','2','2','2','2','3','3','3','3','4','4','4','4','5','5','5','5','6','6','6','6','7','7','7','7','8','8','8','8','9','9','9','9','A','A','A','A','K','K','K','K','J','J','J','J','Q','Q','Q','Q'] import random random.shuffle(cards) h1=[] for card in cards[1:7]: h1.append(card) cards.remove(card)[/CODE] | |
I've been on here for a few weeks now and I [B]JUST[/B] found this CI forum, so let me apologize for the late start, "been too busy on Python". I'm a college student, but not in an IT field. Actually I've switched majors so many times it's ridiculous, Elementary Education, … | |
Re: While I feel it's probably not necessary as some of the best code in the world is open source and have several other reservations about it, I'll still do the nice thing and answer your question. You could register your work with the U.S. Copyright Office if you wanted to … | |
I've been working on getting tkinter to open a window for all dictionary items with keys matching a query. Below is a [B]VERY RAW[/B] piece of code to show what I'm talking about. show() makes the toplevel windows. Also, not that it has so much going on because I isolate … | |
Re: it might help to just show us the line of code you're talking about, to be honest it 176 lines is a bit much when you're talking about one section. | |
Re: I agree with Enalicho. However I can suggest that you write out in pseudo-code what you want the program to do. Pay close attention to using the words input and while. Also, think about the number(s) that need to increase and how they may do that. Post some code and … | |
Is there a way to hide or at least automatically minimize the "shell-like" tkinter window, while running it? | |
Re: I'm sorry, could you explain the resolution? | |
I'm having a terrible time with regular expressions, possibly because I'm using a python2 reference, but maybe not. For example how would I find \s\w within a string and then change that character? | |
Re: Just so you know it's considered polite to mark the thread as solved so people can use it for future reference, and I'm sure pyTony wouldn't mind an upvote for his help if you feel it's in order. | |
Has anyone tried Microsoft's Python Tools for visual studio? I read on /. that it's suppose to support any interpreter not just Ironpython, but I'm only seeing Cpython and Ironpython. Any feedback? [URL="http://pytools.codeplex.com/"]http://pytools.codeplex.com/[/URL] | |
In version 3.0 of my address book I'm utilizing tkinter. The only problem thus far I'm having is that I have a very ugly display on a child window that shows the search result for a query. I'm getting {['Email: [email][email protected][/email], Phone: (111)555-2222, Address: 122 C---- Ct., Essex, VT']} The … | |
Re: woooee's list of tuples is quite similar to what I went with, another method would be to create a hand class and have a method to check the hand for face cards and add their values to some variable and check that total maybe something like:[CODE]class class Hand(object): """A black … | |
I'm working on learning GUI development, I'm attempting to utilize the GUI for a user to search the dictionary: my code so far is[CODE]from tkinter import * class Interface(Frame): def __init__(self, master): super(Interface, self).__init__(master) self.grid() self.create_widget() def create_widget(self): self.pwrd= Label(self, text='Address Book') self.pwrd.grid(row=0, column=2) self.searchlbl= Label(self, text='Enter Search Query:') self.searchlbl.grid(row=2, … | |
Re: @PyTony do you just write your code in the message body from your mobile or do you have an application for writing code on your mobile? Sorry to digress. | |
is it possible to use the Fkeys, i.e. F1, F2,...F12, as input in any way? | |
In one of the books I'm using to study Python I keep seeing things like: [CODE] class Application(Frame): super(Application, self).__init__(master): self.grid() self.bttn_clicks=0 self.create_widget"""which is another function in the class"""[/CODE] Why is the super necessary for the class if the class it's calling is itself? | |
Re: Gribouillis is right, using classes and creating instances would dramatically cut down on bugs like whether the variable your calling is within global scope or not as it would eliminate the need for several global variables. Just in case you're very new and not aware, to utilize a global variable … | |
I'm trying to understand utilizing classes and their methods. I made a simple program to exit or print 'Will continue' given a word. however I keep getting a TypeError for self and through reading my books and searching online I'm still not quite sure why. the code is: [CODE]class OffSwitch(object): … ![]() | |
Re: well first of all what is going wrong when you try to run it? | |
So I've finally fixed up the functionality of an address book I've been writing (not on to utilizing a GUI yet of course though.)However to save or reclaim the data from the last use of the address book I, obviously, need to write and reclaim it from a .txt file, … | |
so I recently wrote a function that sorted using the last value in a tuple. Obviously this couldn't be done simply say sorted(tuples, key=tuples[-1]) because that is not a "legal" call. However I did run across, while trying to figure out how to make things like this work, the utilization … ![]() | |
if I wanted to remove all of the strings within a given list that met a certain criteria, such as having the str'a' in them, how would I go about doing that? the only way that's intuitive to me a for/in loop, but that can't be done. any ideas? Using … ![]() | |
I'm doing the google code U python class and came across a problem trying the following problem, which is the commented out region, the solution needs to be a function. I'm on the second part and trying to find a way to count the values which meet the requirement,i[0:2]==i[-2:]. I … | |
I got this snippet out of my text book but it's giving me a type error, I'll just give you the whole code, tell me if you get it too, if you would. [CODE]import urllib.request import math whips=int(0) rate=float(4) while rate <= float(20): improve= rate*float(.15)+rate rate= improve whips=whips+1 print(whips) def … | |
Re: try [CODE]flip=flip+1[/CODE] and remember to hit the code button before you insert your code, it's terrible to read. | |
The End.