JoshuaBurleson 23 Posting Whiz

If you want it to continue, regardless of under what circumstance, you need to create a loop.

JoshuaBurleson 23 Posting Whiz

Well if you do ever get one of these up and running let me know how you did it, it looks like I might need to compile the C files or something along those lines

JoshuaBurleson 23 Posting Whiz

Do you know how to set this up?

JoshuaBurleson 23 Posting Whiz

Well it looks like some of the code the error is referring to isn't here, however it could be if event.WindowName != self.stroke.current_window: and before that I don't see self.stroke.current_window defined at all, so it's plausible that there's nothing to check it against so it's throwing the attribute error "because the attribute does not yet exist". Not positive, but it would be the first thing I would check.

JoshuaBurleson 23 Posting Whiz

are jpg images completely unsupported for tkinter without PIL?

JoshuaBurleson 23 Posting Whiz

I haven't used pyhook, but what's the error?

JoshuaBurleson 23 Posting Whiz

lol I'm far from professional my friend. I was at about your level last month. But thanks to Daniweb and hard work I'd say I've advanced pretty far, pretty fast.

JoshuaBurleson 23 Posting Whiz

the decision part is just a matter of preference, I don't like writing transactions as negative numbers, some do, that's fine. Python has dynamic typing so you don't NEED to use str() anywhere in your list because Python already knows that the bank_event that went into the list is a str. However if it's required for some ridiculous reason you could "though I and almost all pythonistas discourage it" do something odd like

transactions.append(str(bank_event))

But I have to tell you, that looks pretty dumb.

JoshuaBurleson 23 Posting Whiz

In the mean time I'm committing a horrible offense by assuming the user won't mess with the location of their image files "and that they only use gifs but that's another story altogether" and doing:

###Save Image###
        contact_image={self.name1.capitalize(): self.file1}
        pics.update(contact_image)
        f=open('piclocs.dat','wb+')
        pickle.dump(pics,f)
        f.close()

where pics is a dictionary of the key "names" and their respective getfilename() locations "also know as self.file1 in this case"

JoshuaBurleson 23 Posting Whiz

Hello mates,
I was wondering if in that vast amount of knowledge floating around here if any of you knew how I could save an image using Python 3.x. I know that PIL is a great, and easy option for Python 2, but I assume there must be some way to do this with 3. Ideas?

JoshuaBurleson 23 Posting Whiz

So can I not add a new widget onto a window that's already up? Only change an existing one?

JoshuaBurleson 23 Posting Whiz

Yeah, I often get very frustrated with the lack of documentation, or at least quality documentation on things. It seems like this would be pretty easy to write in python, but I guess the answer to whether or not you could directly run the tcl code in the python interpreter is no. However, and I have no experience with it, there is a jacl (javatcl) to jython converter I found on bytes:http://www-1.ibm.com/support/docview...id=swg24012144, unfortunately I don't know of any other direct converter/translator. Just out of curiosity, why did you write something in tcl?

JoshuaBurleson 23 Posting Whiz

This was not a real thread... I'm going to go cry

JoshuaBurleson 23 Posting Whiz

<DANIWEB> /es /. to pieces

or for pythonistas

while true:
   print('<DaniWeb> rocks')

>>><DaniWeb> rocks
>>><DaniWeb> rocks
>>><DaniWeb> rocks
>>><DaniWeb> rocks
>>><DaniWeb> rocks
>>><DaniWeb> rocks

and it has to show in the code format of course.
...

JoshuaBurleson 23 Posting Whiz

Well in that case I'll just have to donate as soon as I can. Thanks for all your hard work Dani!

^^That sounds sarcastic, but it's not^^

JoshuaBurleson 23 Posting Whiz

I just had to get this one out there. I love daniweb, and I'm sure the VAST majority of the users here do as well. And, unlike many other websites this one's community is made up of some of the greatest IT and Development minds around "as well as noobs trying to learn how to climb the ladder such as myself". In my humble opinion I believe it would be possible, maybe even a good idea to outsource some IT or Development related tasks to volunteering community members to reduce some costs "and likely make both a tighter community and an even higher grade site.

I know if I were skilled enough to actually help out I'd love to. Thoughts, comments, ideas, rebuttals?

jingda commented: Nice thought +0
JoshuaBurleson 23 Posting Whiz

It seems to me that raw_input was more for strings whereas input was for numeralsokay, so for python 2.7, which apparently is what you're using you could do "assuming the user knows the ticker code:

stockname=raw_input('What stock would you like to purchase?: ')
'''we are going to pretend you have a dictionary of prices for the ticker names'''
prices={'pep':62.07}
if stockname in prices.keys():
   stock_unit_price=prices[stockname]
amount=input('How many shares would you like?: ')
total_price=float(amount)*float(stock_unit_price)
'''I used float() because we are talking about stocks which often can be like 58.29, which is a floating point number'''
print('Your total is $',total_price)
JoshuaBurleson 23 Posting Whiz

raw_input is used for user input on the command line, or in IDLE for example:

word=raw_input('Enter a word: ')
print word

it is important to note that raw_input does not work in python 3.x it was combined with input() after python 2.

If you're not sure which one you are using, if you try to use raw_input and get an error regarding the raw_input, you are probably using python 3. In which case the code above would look like this:

word=input('Enter a word: ')
print(word)

Also, post code to show effort in. Effort in effort out, more specifically as Pytony would say http://www.daniweb.com/software-development/python/threads/359823

JoshuaBurleson 23 Posting Whiz

Well Mike, welcome to Python, I'm sure you'll love it. Here's a snippet by Vegaseat regarding TG http://www.daniweb.com/software-development/python/code/216557 Also there are tons of free ebooks on learning python, some handy tutorials at http://thenewboston.com "I didn't use them, but I viewed them after I learned the material and wished that I had had them before." As well as other tutorials, just google Python or check out Youtube.

Remember that there are currently 2 main versions of Python: Python 2 "Specifically Python 2.7" and Python 3, the current version of which is Python 3.2.2. Python 3 is the only one that is still being upgraded, to my knowledge there are only bug-fixes being supported on python 2. So choose one "or both" and make sure you're aware that there are difference as you go along. Good luck and we'll be here with you. Also remember, it's effort in effort out around here so if you want help with something you better show us that you're trying! :icon_cheesygrin:

JoshuaBurleson 23 Posting Whiz

You get one chance to justify why you would want to do that.

JoshuaBurleson 23 Posting Whiz

I'm trying to figure out how to allow users to upload images, I'm starting easy with something I know tkinter can handle with no coercion, gif files. I've figures a bit out, but I'm having issues getting the image to actually SHOW.

from tkinter import *
from tkinter.filedialog import askopenfilename

root=Tk()
def get_image():
    file_name=askopenfilename(filetypes=[('GIF FILES', '*.gif')])
    print(file_name)
    the=PhotoImage(file=file_name)
    show(the)
def show(imaj):
    Show=Toplevel()
    Show.grid()
    the_image=Button(Show,image=imaj)
    the_image.grid()
    
root.upbutn=Button(root,text='upload an image',command=get_image)
root.upbutn.grid()
root.grid()
root.mainloop()
JoshuaBurleson 23 Posting Whiz

I figured it out, it's just...kind of strange and ugly.

import tkinter.MessageBox as tkm
if not tkm.askokcancel('Invalid Login', 'Either your username or password was invalid\n\t\tPlease try again'):
   logend()
JoshuaBurleson 23 Posting Whiz
JoshuaBurleson 23 Posting Whiz

Why wouldn't you be able to? Post the source.

JoshuaBurleson 23 Posting Whiz

well there are a couple bugs with that, I haven't tested it, but I can see them.

okay so if you used the general idea of the format I have above and add in the need for the number of transactions then how do you think you could do that? It actually would work pretty smoothly once the bugs are squashed.

JoshuaBurleson 23 Posting Whiz

Why are you having the user input the number of transactions? It just seems to me like that would become repetitive since most transactions in a month are only made once. To subtract the amount from the total balance you should - from current balance. I'll give you a hint as to how I would've started it, assuming you don't know how to do exception handling.

transactions = []
initialb=input("Enter the initial balance of your account: ")
currentb = initialb
def decision():
    decide=input('Transaction deposit or withdrawal?: ')
    decide.lower()
    if decide[0]=='w':
        withdrawn()
    elif decide[0]=='d':
        deposited()
def withdrawn():
    tran=input("Enter the amount of transaction: ")
    currentb-=tran
    bank_event='%s taken from account. Balance after transaction %s' % (tran,currentb)
    transactions.append(bank_event)
def deposited():
    tran=input("Enter the amount of transaction: ")
    currentb+=tran
    bank_event='%s deposited into account. Balance after deposit %s' % (tran,currentb)
    transactions.append(bank_event)
decision()
JoshuaBurleson 23 Posting Whiz

looks like someboy's tryin' to make a keylogger :icon_wink:

JoshuaBurleson 23 Posting Whiz

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?

JoshuaBurleson 23 Posting Whiz

hmm, would I need to do multi-threading to have a loop continuously looking through what's in the entry field of the combobox? I really like the listbox that drops when you take a moment to think of what you're trying to type in tkinter, specifically I like how it goes directly to the closest match to what you've typed in. That's not the autocomplete is it?

JoshuaBurleson 23 Posting Whiz

That was extremely helpful. However I'm still having a hard time figuring out how to use the -autocomplete option and if I can make commands directly to the entry widget of the combobox separately.

JoshuaBurleson 23 Posting Whiz

CLOSE THAT FILE!!! Also, did you notice the stray else at the end?

JoshuaBurleson 23 Posting Whiz

I think it's pretty important to incorporate functions, ESPECIALLY since you're a newbie. It wasn't that long ago that I was wrapping my head around functions. They're great because the can be used more than once, it's also a quick concept to begin to understand, it's simply a way of doing a given task. For example if I wanted to print out the same ending to a string for different strings I could write something like

def grade_name(name):
    name=name.capitalize()
    if name[0:4]=='Josh':
        name+=' is awesome.'
        return name
    elif name[0:4]=='Tony':
        name+=' is a great teacher'
        return name
    else:
        name+=' is using this program'
        return name

now instead of writing this all over the place I could simply do something like:

coming_in=input('Enter a name: ')
grade_name(coming_in)
JoshuaBurleson 23 Posting Whiz

or better yet how does this crazy ttk combobox thing work?

JoshuaBurleson 23 Posting Whiz

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:

a=Lb1.curselection()[1]
    a=int(a)
    print(Lb1[a])

Lb1 is obviously the listbox. This particular attempt claims 1 is out of range "although I know it has a string in that position". With [0] in the position when it gets to Lb1[a] it claims, can't convert type int to str implicitly, however I wouldn't want to do that, because, futilely, I'm trying to index it.

JoshuaBurleson 23 Posting Whiz

well first of all you need to think out how it should work. So, mathematically how do you find the divisors of a number? Then how would you say that in Python? Effort in effort out around here.

TrustyTony commented: Proper newbie handling, sensei ;) +13
JoshuaBurleson 23 Posting Whiz

It looks like my issue was the image, which is strange, but I'm going to just have to figure that one out I guess

JoshuaBurleson 23 Posting Whiz

REGEX

JoshuaBurleson 23 Posting Whiz

I just finished a program

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 to try to write codes that used the mechanics trying to be taught. Here, try this: write a program that takes a password and if the password is correct prints the password in a Text box, otherwise it prints the number of attempts so far in the Text box. That will be your own original code and it'll probably be easier to see where things go wrong in that as opposed to Michael Dawson's code.

JoshuaBurleson 23 Posting Whiz

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:

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

the last one actually froze the program completely, it wouldn't run. I'm sure the images are in the correct directory.

JoshuaBurleson 23 Posting Whiz

abders, I would rate it an 7-8/10, it's great for learning but I can teach some bad habits and be unclear at times, but supplemented with Daniweb it can be acceptable.

JoshuaBurleson 23 Posting Whiz

Uh oh he's using the same book I was using, lol.

This worked fine for me:

from tkinter import *

class Application(Frame):
    def __init__(self, master):
        super(Application, self).__init__(master)
        self.grid()
        self.create_widgets()
        
    def create_widgets(self):
        self.bttn1 = Button(self, text ="I do nothing!")
        self.bttn1.grid()
        self.bttn2 = Button(self, text ="Me too.")
        self.bttn2.grid()
        self.bttn3 = Button(self, text ="Same here..")
        self.bttn3.grid()
        
    
root = Tk()
root.title("Lazy buttons")
root.geometry("200x100")
app = Application(root)
root.mainloop()

your issue was primarily sloppiness, pay attention to your code, you misspelled alot and forgot to call a new instance of events like grid which should've been grid()<--() is important.

Also make sure you're using python 3

JoshuaBurleson 23 Posting Whiz

it is used to catch Errors, so you are saying try this except if an error is raised then do this.

try:
   dancing()
except BadDancerError:
   print('Please Stop Dancing')
JoshuaBurleson 23 Posting Whiz

Okay, well what do you need the dictionary to be of? Also, directly copy and paste your code into the

encapsulation so the indentation is correct.

JoshuaBurleson 23 Posting Whiz

@Valex, start your own thread.

JoshuaBurleson 23 Posting Whiz

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.


I forget who's signature it is, but may the Google be with you is an extremely well put statement.

JoshuaBurleson 23 Posting Whiz

Haven't heard of this, do you have an example?

JoshuaBurleson 23 Posting Whiz

have you seen this?

JoshuaBurleson 23 Posting Whiz

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 (from being tabbed over to, such as in the case of a search button. Also how would I make this work for multiple buttons, or even if the user hit <RETURN> in the Entry field? Ideas? I'm sure this one is way easier than it seems.

JoshuaBurleson 23 Posting Whiz

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 a VERY simple solution, and anybody who has a few minutes to spend messing with it could find it.

import pickle
useraccess={'Dad':'Mysonisawesome'}
f=open('inconspicuosfile.dat','wb+')
pickle.dump(useraccess,f)
f.close()
JoshuaBurleson 23 Posting Whiz

Post the code here next time, and if you feel it's a good quality code post it as a snippet!